Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
dc318170
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
337
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看板
提交
dc318170
编写于
8月 03, 2018
作者:
qnqinan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update types and op kernels
上级
e662b4d8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
37 addition
and
11 deletion
+37
-11
src/common/types.cpp
src/common/types.cpp
+2
-2
src/operators/kernel/fpga/elementwise_add_relu_kernel.cpp
src/operators/kernel/fpga/elementwise_add_relu_kernel.cpp
+6
-3
src/operators/kernel/fpga/fc_relu_kernel.cpp
src/operators/kernel/fpga/fc_relu_kernel.cpp
+14
-3
src/operators/kernel/fpga/fusion_fc_kernel.cpp
src/operators/kernel/fpga/fusion_fc_kernel.cpp
+14
-3
src/operators/kernel/fpga/pool_kernel.cpp
src/operators/kernel/fpga/pool_kernel.cpp
+1
-0
未找到文件。
src/common/types.cpp
浏览文件 @
dc318170
...
@@ -81,8 +81,8 @@ std::unordered_map<
...
@@ -81,8 +81,8 @@ std::unordered_map<
{
G_OP_TYPE_FUSION_CONV_ADD_RELU
,
{{
"Input"
},
{
"Out"
}}},
{
G_OP_TYPE_FUSION_CONV_ADD_RELU
,
{{
"Input"
},
{
"Out"
}}},
{
G_OP_TYPE_IM2SEQUENCE
,
{{
"X"
},
{
"Out"
}}},
{
G_OP_TYPE_IM2SEQUENCE
,
{{
"X"
},
{
"Out"
}}},
{
G_OP_TYPE_DROPOUT
,
{{
"X"
},
{
"Out"
}}},
{
G_OP_TYPE_DROPOUT
,
{{
"X"
},
{
"Out"
}}},
{
G_OP_TYPE_FUSION_CONV_ADD_BN
,
{{
"Input"
},
{
"
Out
"
}}},
{
G_OP_TYPE_FUSION_CONV_ADD_BN
,
{{
"Input"
},
{
"
Y
"
}}},
{
G_OP_TYPE_FUSION_POOL_BN
,
{{
"X"
},
{
"
Out
"
}}},
{
G_OP_TYPE_FUSION_POOL_BN
,
{{
"X"
},
{
"
Y
"
}}},
{
G_OP_TYPE_FUSION_ELEMENTWISE_ADD_RELU
,
{{
"X"
,
"Y"
},
{
"Out"
}}},
{
G_OP_TYPE_FUSION_ELEMENTWISE_ADD_RELU
,
{{
"X"
,
"Y"
},
{
"Out"
}}},
{
G_OP_TYPE_FUSION_FC_RELU
,
{{
"X"
,
"Y"
,
"Z"
},
{
"Out"
}}},
{
G_OP_TYPE_FUSION_FC_RELU
,
{{
"X"
,
"Y"
,
"Z"
},
{
"Out"
}}},
{
G_OP_TYPE_REGION
,
{{
"X"
},
{
"Out"
}}}};
{
G_OP_TYPE_REGION
,
{{
"X"
},
{
"Out"
}}}};
...
...
src/operators/kernel/fpga/elementwise_add_relu_kernel.cpp
浏览文件 @
dc318170
...
@@ -29,25 +29,28 @@ bool ElementwiseAddReluKernel<FPGA, float>::Init(
...
@@ -29,25 +29,28 @@ bool ElementwiseAddReluKernel<FPGA, float>::Init(
auto
input_x_ptr
=
input_x
->
data
<
float
>
();
auto
input_x_ptr
=
input_x
->
data
<
float
>
();
auto
input_y_ptr
=
input_y
->
data
<
float
>
();
auto
input_y_ptr
=
input_y
->
data
<
float
>
();
auto
out_ptr
=
out
->
data
<
float
>
();
auto
out_ptr
=
out
->
data
<
float
>
();
fpga
::
EWAddArgs
ewaddArgs
;
fpga
::
EWAddArgs
ewaddArgs
;
ewaddArgs
.
relu_enabled
=
relu_enabled
;
ewaddArgs
.
relu_enabled
=
relu_enabled
;
ewaddArgs
.
const0
=
1
;
ewaddArgs
.
const0
=
1
;
ewaddArgs
.
const1
=
1
;
ewaddArgs
.
const1
=
1
;
ewaddArgs
.
image0
.
address
=
(
void
*
)
input_x_ptr
;
ewaddArgs
.
image0
.
address
=
(
void
*
)
input_x_ptr
;
ewaddArgs
.
image0
.
channels
=
input_x
->
dims
()[
1
];
ewaddArgs
.
image0
.
channels
=
input_x
->
dims
()[
1
];
ewaddArgs
.
image0
.
scale_address
=
nullptr
;
// ew has scale attribute??
ewaddArgs
.
image0
.
scale_address
=
input_x
->
fpga_args
().
scale_pointer
();
// ew has scale attribute??
ewaddArgs
.
image0
.
height
=
input_x
->
dims
()[
2
];
ewaddArgs
.
image0
.
height
=
input_x
->
dims
()[
2
];
ewaddArgs
.
image0
.
width
=
input_x
->
dims
()[
3
];
ewaddArgs
.
image0
.
width
=
input_x
->
dims
()[
3
];
ewaddArgs
.
image0
.
pad_height
=
1
;
ewaddArgs
.
image0
.
pad_height
=
1
;
ewaddArgs
.
image0
.
pad_width
=
1
;
ewaddArgs
.
image0
.
pad_width
=
1
;
ewaddArgs
.
image1
.
address
=
(
void
*
)
input_y_ptr
;
ewaddArgs
.
image1
.
address
=
(
void
*
)
input_y_ptr
;
ewaddArgs
.
image1
.
channels
=
input_y
->
dims
()[
1
];
ewaddArgs
.
image1
.
channels
=
input_y
->
dims
()[
1
];
ewaddArgs
.
image1
.
scale_address
=
nullptr
;
// ew has scale attribute??
ewaddArgs
.
image1
.
scale_address
=
input_y
->
fpga_args
().
scale_pointer
();
// ew has scale attribute??
ewaddArgs
.
image1
.
height
=
input_y
->
dims
()[
2
];
ewaddArgs
.
image1
.
height
=
input_y
->
dims
()[
2
];
ewaddArgs
.
image1
.
width
=
input_y
->
dims
()[
3
];
ewaddArgs
.
image1
.
width
=
input_y
->
dims
()[
3
];
ewaddArgs
.
image1
.
pad_height
=
1
;
ewaddArgs
.
image1
.
pad_height
=
1
;
ewaddArgs
.
image1
.
pad_width
=
1
;
ewaddArgs
.
image1
.
pad_width
=
1
;
ewaddArgs
.
output
.
scale_address
=
nullptr
;
ewaddArgs
.
output
.
scale_address
=
out
->
fpga_args
().
scale_pointer
()
;
ewaddArgs
.
output
.
address
=
(
void
*
)
out_ptr
;
ewaddArgs
.
output
.
address
=
(
void
*
)
out_ptr
;
param
->
SetFpgaArgs
(
ewaddArgs
);
param
->
SetFpgaArgs
(
ewaddArgs
);
return
true
;
return
true
;
...
...
src/operators/kernel/fpga/fc_relu_kernel.cpp
浏览文件 @
dc318170
...
@@ -31,13 +31,22 @@ bool FusionFcReluKernel<FPGA, float>::Init(FusionFcReluParam *param) {
...
@@ -31,13 +31,22 @@ bool FusionFcReluKernel<FPGA, float>::Init(FusionFcReluParam *param) {
Tensor
*
out
=
param
->
Out
();
Tensor
*
out
=
param
->
Out
();
auto
out_ptr
=
out
->
mutable_data
<
float
>
();
auto
out_ptr
=
out
->
mutable_data
<
float
>
();
PADDLE_MOBILE_ENFORCE
(
input_x
->
dims
()[
1
]
==
input_z
->
dims
()[
0
],
"Image channel should be equal to bias number"
);
int
channel
=
input_x
->
dims
()[
1
];
float
*
bs_ptr
=
(
float
*
)
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
));
for
(
int
i
=
0
;
i
<
channel
;
i
++
)
{
bs_ptr
[
i
*
2
]
=
1
;
bs_ptr
[
i
*
2
+
1
]
=
input_z_ptr
[
i
];
}
fpga
::
ConvArgs
convArgs
;
fpga
::
ConvArgs
convArgs
;
convArgs
.
relu_enabled
=
relu_enabled
;
convArgs
.
relu_enabled
=
relu_enabled
;
convArgs
.
bias_address
=
(
void
*
)
input_z_ptr
;
convArgs
.
bias_address
=
(
void
*
)
input_z_ptr
;
convArgs
.
filter_address
=
(
void
*
)
input_y_ptr
;
convArgs
.
filter_address
=
(
void
*
)
input_y_ptr
;
convArgs
.
filter_num
=
out
->
dims
()[
1
];
convArgs
.
filter_num
=
out
->
dims
()[
1
];
convArgs
.
group_num
=
1
;
convArgs
.
group_num
=
1
;
convArgs
.
bn
.
enabled
=
bn_enabled
;
convArgs
.
sb_address
=
(
void
*
)
bs_ptr
;
convArgs
.
kernel
.
stride_w
=
1
;
convArgs
.
kernel
.
stride_w
=
1
;
convArgs
.
kernel
.
stride_h
=
1
;
convArgs
.
kernel
.
stride_h
=
1
;
convArgs
.
kernel
.
height
=
input_x
->
dims
()[
2
];
convArgs
.
kernel
.
height
=
input_x
->
dims
()[
2
];
...
@@ -48,9 +57,11 @@ bool FusionFcReluKernel<FPGA, float>::Init(FusionFcReluParam *param) {
...
@@ -48,9 +57,11 @@ bool FusionFcReluKernel<FPGA, float>::Init(FusionFcReluParam *param) {
convArgs
.
image
.
width
=
input_x
->
dims
()[
3
];
convArgs
.
image
.
width
=
input_x
->
dims
()[
3
];
convArgs
.
image
.
pad_height
=
1
;
convArgs
.
image
.
pad_height
=
1
;
convArgs
.
image
.
pad_width
=
1
;
convArgs
.
image
.
pad_width
=
1
;
convArgs
.
image
.
scale_address
=
nullptr
;
// fc input has scale attribute??
convArgs
.
image
.
scale_address
=
input_x
->
fpga_args
().
scale_pointer
();
// fc input has scale attribute??
convArgs
.
output
.
address
=
(
void
*
)
out_ptr
;
convArgs
.
output
.
address
=
(
void
*
)
out_ptr
;
convArgs
.
output
.
scale_address
=
nullptr
;
// fc output has scale attribute??
convArgs
.
output
.
scale_address
=
out
->
fpga_args
().
scale_pointer
();
// fc output has scale attribute??
param
->
SetFpgaArgs
(
convArgs
);
param
->
SetFpgaArgs
(
convArgs
);
return
true
;
return
true
;
...
...
src/operators/kernel/fpga/fusion_fc_kernel.cpp
浏览文件 @
dc318170
...
@@ -31,13 +31,22 @@ bool FusionFcKernel<FPGA, float>::Init(FusionFcParam *param) {
...
@@ -31,13 +31,22 @@ bool FusionFcKernel<FPGA, float>::Init(FusionFcParam *param) {
Tensor
*
out
=
param
->
Out
();
Tensor
*
out
=
param
->
Out
();
auto
out_ptr
=
out
->
mutable_data
<
float
>
();
auto
out_ptr
=
out
->
mutable_data
<
float
>
();
PADDLE_MOBILE_ENFORCE
(
input_x
->
dims
()[
1
]
==
input_z
->
dims
()[
0
],
"Image channel should be equal to bias number"
);
int
channel
=
input_x
->
dims
()[
1
];
float
*
bs_ptr
=
(
float
*
)
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
));
for
(
int
i
=
0
;
i
<
channel
;
i
++
)
{
bs_ptr
[
i
*
2
]
=
1
;
bs_ptr
[
i
*
2
+
1
]
=
input_z_ptr
[
i
];
}
fpga
::
ConvArgs
convArgs
;
fpga
::
ConvArgs
convArgs
;
convArgs
.
relu_enabled
=
relu_enabled
;
convArgs
.
relu_enabled
=
relu_enabled
;
convArgs
.
bias_address
=
(
void
*
)
input_z_ptr
;
convArgs
.
bias_address
=
(
void
*
)
input_z_ptr
;
convArgs
.
filter_address
=
(
void
*
)
input_y_ptr
;
convArgs
.
filter_address
=
(
void
*
)
input_y_ptr
;
convArgs
.
filter_num
=
out
->
dims
()[
1
];
convArgs
.
filter_num
=
out
->
dims
()[
1
];
convArgs
.
group_num
=
1
;
convArgs
.
group_num
=
1
;
convArgs
.
bn
.
enabled
=
bn_enabled
;
convArgs
.
sb_address
=
(
void
*
)
bs_ptr
;
convArgs
.
kernel
.
stride_w
=
1
;
convArgs
.
kernel
.
stride_w
=
1
;
convArgs
.
kernel
.
stride_h
=
1
;
convArgs
.
kernel
.
stride_h
=
1
;
convArgs
.
kernel
.
height
=
input_x
->
dims
()[
2
];
convArgs
.
kernel
.
height
=
input_x
->
dims
()[
2
];
...
@@ -48,9 +57,11 @@ bool FusionFcKernel<FPGA, float>::Init(FusionFcParam *param) {
...
@@ -48,9 +57,11 @@ bool FusionFcKernel<FPGA, float>::Init(FusionFcParam *param) {
convArgs
.
image
.
width
=
input_x
->
dims
()[
3
];
convArgs
.
image
.
width
=
input_x
->
dims
()[
3
];
convArgs
.
image
.
pad_height
=
1
;
convArgs
.
image
.
pad_height
=
1
;
convArgs
.
image
.
pad_width
=
1
;
convArgs
.
image
.
pad_width
=
1
;
convArgs
.
image
.
scale_address
=
nullptr
;
// fc input has scale attribute??
convArgs
.
image
.
scale_address
=
input_x
->
fpga_args
().
scale_pointer
();
// fc input has scale attribute??
convArgs
.
output
.
address
=
(
void
*
)
out_ptr
;
convArgs
.
output
.
address
=
(
void
*
)
out_ptr
;
convArgs
.
output
.
scale_address
=
nullptr
;
// fc output has scale attribute??
convArgs
.
output
.
scale_address
=
out
->
fpga_args
().
scale_pointer
();
// fc output has scale attribute??
param
->
SetFpgaArgs
(
convArgs
);
param
->
SetFpgaArgs
(
convArgs
);
return
true
;
return
true
;
}
}
...
...
src/operators/kernel/fpga/pool_kernel.cpp
浏览文件 @
dc318170
...
@@ -29,6 +29,7 @@ bool PoolKernel<FPGA, float>::Init(PoolParam *param) {
...
@@ -29,6 +29,7 @@ bool PoolKernel<FPGA, float>::Init(PoolParam *param) {
vector
<
int
>
ksize
=
param
->
Ksize
();
vector
<
int
>
ksize
=
param
->
Ksize
();
vector
<
int
>
strides
=
param
->
Strides
();
vector
<
int
>
strides
=
param
->
Strides
();
vector
<
int
>
paddings
=
param
->
Paddings
();
vector
<
int
>
paddings
=
param
->
Paddings
();
fpga
::
PoolingArgs
poolArgs
;
fpga
::
PoolingArgs
poolArgs
;
poolArgs
.
image
.
address
=
(
void
*
)
input_ptr
;
poolArgs
.
image
.
address
=
(
void
*
)
input_ptr
;
poolArgs
.
image
.
channels
=
input
->
dims
()[
1
];
poolArgs
.
image
.
channels
=
input
->
dims
()[
1
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录