Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
8d2351c3
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
8d2351c3
编写于
9月 20, 2020
作者:
W
weihaoji
提交者:
GitHub
9月 20, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[XPU] add resnet50-D fusion (#4276)
上级
7fb2261d
变更
6
展开全部
显示空白变更内容
内联
并排
Showing
6 changed file
with
897 addition
and
17 deletion
+897
-17
lite/api/paddle_use_passes.h
lite/api/paddle_use_passes.h
+1
-0
lite/core/mir/fusion/__xpu__resnet_fuse_pass.cc
lite/core/mir/fusion/__xpu__resnet_fuse_pass.cc
+835
-17
lite/core/optimizer.h
lite/core/optimizer.h
+1
-0
lite/kernels/xpu/__xpu__resnet50_compute.cc
lite/kernels/xpu/__xpu__resnet50_compute.cc
+44
-0
lite/kernels/xpu/__xpu__resnet50_compute.h
lite/kernels/xpu/__xpu__resnet50_compute.h
+15
-0
lite/operators/__xpu__resnet50_op.cc
lite/operators/__xpu__resnet50_op.cc
+1
-0
未找到文件。
lite/api/paddle_use_passes.h
浏览文件 @
8d2351c3
...
...
@@ -62,6 +62,7 @@ USE_MIR_PASS(quantized_op_attributes_inference_pass);
USE_MIR_PASS
(
control_flow_op_unused_inputs_and_outputs_eliminate_pass
)
USE_MIR_PASS
(
lite_scale_activation_fuse_pass
);
USE_MIR_PASS
(
__xpu__resnet_fuse_pass
);
USE_MIR_PASS
(
__xpu__resnet_d_fuse_pass
);
USE_MIR_PASS
(
__xpu__resnet_cbam_fuse_pass
);
USE_MIR_PASS
(
__xpu__multi_encoder_fuse_pass
);
USE_MIR_PASS
(
__xpu__embedding_with_eltwise_add_fuse_pass
);
...
...
lite/core/mir/fusion/__xpu__resnet_fuse_pass.cc
浏览文件 @
8d2351c3
此差异已折叠。
点击以展开。
lite/core/optimizer.h
浏览文件 @
8d2351c3
...
...
@@ -108,6 +108,7 @@ class Optimizer {
#endif
"identity_dropout_eliminate_pass"
,
"__xpu__resnet_fuse_pass"
,
"__xpu__resnet_d_fuse_pass"
,
"__xpu__resnet_cbam_fuse_pass"
,
"__xpu__conv2d_fuse_pass"
,
"__xpu__conv2d_link_previous_out_max_pass"
,
...
...
lite/kernels/xpu/__xpu__resnet50_compute.cc
浏览文件 @
8d2351c3
...
...
@@ -34,6 +34,21 @@ void XPUResNet50Compute::PrepareForRun() {
}
}
void
XPUResNet50DtypeCompute
::
PrepareForRun
()
{
auto
&
param
=
this
->
Param
<
param_t
>
();
for
(
auto
*
filter
:
param
.
filter
)
{
arg_filter_
.
push_back
(
reinterpret_cast
<
const
int16_t
*>
(
filter
->
data
<
float
>
()));
}
for
(
auto
*
bias
:
param
.
bias
)
{
arg_bias_
.
push_back
(
bias
->
data
<
float
>
());
}
for
(
auto
*
max_filter
:
param
.
max_filter
)
{
arg_max_filter_
.
push_back
(
max_filter
->
data
<
float
>
());
}
}
void
XPUResNet50Compute
::
Run
()
{
auto
&
param
=
this
->
Param
<
param_t
>
();
auto
&
ctx
=
this
->
ctx_
->
As
<
XPUContext
>
();
...
...
@@ -50,6 +65,22 @@ void XPUResNet50Compute::Run() {
CHECK_EQ
(
r
,
0
);
}
void
XPUResNet50DtypeCompute
::
Run
()
{
auto
&
param
=
this
->
Param
<
param_t
>
();
auto
&
ctx
=
this
->
ctx_
->
As
<
XPUContext
>
();
int
batch_size
=
param
.
input
->
dims
()[
0
];
int
r
=
xdnn
::
conv2d_int16_resnet_d
<
float
,
int16_t
>
(
ctx
.
GetRawContext
(),
/* context */
batch_size
,
/* num */
param
.
input
->
data
<
float
>
(),
/* bottom */
&
arg_filter_
[
0
],
/* weight_list */
param
.
output
->
mutable_data
<
float
>
(
TARGET
(
kXPU
)),
/* top */
&
arg_bias_
[
0
],
/* bias_list */
&
arg_max_filter_
[
0
]
/* max_filter_list */
);
CHECK_EQ
(
r
,
0
);
}
}
// namespace xpu
}
// namespace kernels
}
// namespace lite
...
...
@@ -67,3 +98,16 @@ REGISTER_LITE_KERNEL(__xpu__resnet50,
.
BindInput
(
"MaxFilter"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kXPU
))})
.
BindOutput
(
"Output"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kXPU
))})
.
Finalize
();
REGISTER_LITE_KERNEL
(
__xpu__resnet50_d
,
kXPU
,
kFloat
,
kNCHW
,
paddle
::
lite
::
kernels
::
xpu
::
XPUResNet50DtypeCompute
,
def
)
.
BindInput
(
"Input"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kXPU
))})
.
BindInput
(
"Filter"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kXPU
))})
.
BindInput
(
"Bias"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kXPU
))})
.
BindInput
(
"MaxFilter"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kXPU
))})
.
BindOutput
(
"Output"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kXPU
))})
.
Finalize
();
lite/kernels/xpu/__xpu__resnet50_compute.h
浏览文件 @
8d2351c3
...
...
@@ -38,6 +38,21 @@ class XPUResNet50Compute : public KernelLite<TARGET(kXPU), PRECISION(kFloat)> {
std
::
vector
<
const
float
*>
arg_bias_
;
};
class
XPUResNet50DtypeCompute
:
public
KernelLite
<
TARGET
(
kXPU
),
PRECISION
(
kFloat
)
>
{
public:
using
param_t
=
operators
::
XPUResNet50Param
;
virtual
void
PrepareForRun
();
virtual
void
Run
();
private:
std
::
vector
<
const
int16_t
*>
arg_filter_
;
std
::
vector
<
const
float
*>
arg_max_filter_
;
std
::
vector
<
const
float
*>
arg_bias_
;
};
}
// namespace xpu
}
// namespace kernels
}
// namespace lite
...
...
lite/operators/__xpu__resnet50_op.cc
浏览文件 @
8d2351c3
...
...
@@ -62,3 +62,4 @@ bool XPUResNet50Op::AttachImpl(const cpp::OpDesc& op_desc, lite::Scope* scope) {
}
// namespace paddle
REGISTER_LITE_OP
(
__xpu__resnet50
,
paddle
::
lite
::
operators
::
XPUResNet50Op
);
REGISTER_LITE_OP
(
__xpu__resnet50_d
,
paddle
::
lite
::
operators
::
XPUResNet50Op
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录