Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
8f2e11bb
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看板
未验证
提交
8f2e11bb
编写于
8月 16, 2018
作者:
qnqinan
提交者:
GitHub
8月 16, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #790 from zhangyang0701/develop
Correct FPGA kernels. close
#789
上级
a73884e5
7d228ed0
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
23 addition
and
17 deletion
+23
-17
src/operators/kernel/fpga/conv_add_bn_kernel.cpp
src/operators/kernel/fpga/conv_add_bn_kernel.cpp
+3
-3
src/operators/kernel/fpga/conv_add_bn_relu_kernel.cpp
src/operators/kernel/fpga/conv_add_bn_relu_kernel.cpp
+3
-3
src/operators/kernel/fpga/conv_add_relu_kernel.cpp
src/operators/kernel/fpga/conv_add_relu_kernel.cpp
+3
-3
src/operators/kernel/fpga/conv_bn_kernel.cpp
src/operators/kernel/fpga/conv_bn_kernel.cpp
+3
-3
src/operators/kernel/fpga/conv_bn_relu_kernel.cpp
src/operators/kernel/fpga/conv_bn_relu_kernel.cpp
+3
-3
src/operators/kernel/fpga/fc_relu_kernel.cpp
src/operators/kernel/fpga/fc_relu_kernel.cpp
+1
-1
src/operators/kernel/fpga/fusion_fc_kernel.cpp
src/operators/kernel/fpga/fusion_fc_kernel.cpp
+1
-1
test/net/test_resnet.cpp
test/net/test_resnet.cpp
+6
-0
未找到文件。
src/operators/kernel/fpga/conv_add_bn_kernel.cpp
浏览文件 @
8f2e11bb
...
@@ -37,11 +37,11 @@ bool ConvAddBNKernel<FPGA, float>::Init(FusionConvAddBNParam *param) {
...
@@ -37,11 +37,11 @@ bool ConvAddBNKernel<FPGA, float>::Init(FusionConvAddBNParam *param) {
auto
bn_scale_ptr
=
param
->
InputScale
()
->
data
<
float
>
();
auto
bn_scale_ptr
=
param
->
InputScale
()
->
data
<
float
>
();
auto
bn_bias_ptr
=
param
->
InputBias
()
->
data
<
float
>
();
auto
bn_bias_ptr
=
param
->
InputBias
()
->
data
<
float
>
();
const
float
epsilon
=
param
->
Epsilon
();
const
float
epsilon
=
param
->
Epsilon
();
PADDLE_MOBILE_ENFORCE
(
inp
ut
->
dims
()[
1
]
==
bias
->
dims
()[
0
]
&&
PADDLE_MOBILE_ENFORCE
(
o
ut
->
dims
()[
1
]
==
bias
->
dims
()[
0
]
&&
bias
->
dims
()[
0
]
==
param
->
InputBias
()
->
dims
()[
0
],
bias
->
dims
()[
0
]
==
param
->
InputBias
()
->
dims
()[
0
],
"
Image
channel should be equal to bias number"
);
"
Output
channel should be equal to bias number"
);
const
int
channel
=
inp
ut
->
dims
()[
1
];
const
int
channel
=
o
ut
->
dims
()[
1
];
float
*
bs_ptr
=
float
*
bs_ptr
=
reinterpret_cast
<
float
*>
(
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
)));
reinterpret_cast
<
float
*>
(
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
)));
Tensor
*
new_scale
=
new
Tensor
();
Tensor
*
new_scale
=
new
Tensor
();
...
...
src/operators/kernel/fpga/conv_add_bn_relu_kernel.cpp
浏览文件 @
8f2e11bb
...
@@ -35,11 +35,11 @@ bool ConvAddBNReluKernel<FPGA, float>::Init(FusionConvAddBNReluParam *param) {
...
@@ -35,11 +35,11 @@ bool ConvAddBNReluKernel<FPGA, float>::Init(FusionConvAddBNReluParam *param) {
auto
bn_scale_ptr
=
param
->
InputScale
()
->
data
<
float
>
();
auto
bn_scale_ptr
=
param
->
InputScale
()
->
data
<
float
>
();
auto
bn_bias_ptr
=
param
->
InputBias
()
->
data
<
float
>
();
auto
bn_bias_ptr
=
param
->
InputBias
()
->
data
<
float
>
();
const
float
epsilon
=
param
->
Epsilon
();
const
float
epsilon
=
param
->
Epsilon
();
PADDLE_MOBILE_ENFORCE
(
inp
ut
->
dims
()[
1
]
==
bias
->
dims
()[
0
]
&&
PADDLE_MOBILE_ENFORCE
(
o
ut
->
dims
()[
1
]
==
bias
->
dims
()[
0
]
&&
bias
->
dims
()[
0
]
==
param
->
InputBias
()
->
dims
()[
0
],
bias
->
dims
()[
0
]
==
param
->
InputBias
()
->
dims
()[
0
],
"
Image
channel should be equal to bias number"
);
"
Output
channel should be equal to bias number"
);
const
int
channel
=
inp
ut
->
dims
()[
1
];
const
int
channel
=
o
ut
->
dims
()[
1
];
float
*
bs_ptr
=
(
float
*
)
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
));
float
*
bs_ptr
=
(
float
*
)
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
));
Tensor
*
new_scale
=
new
Tensor
();
Tensor
*
new_scale
=
new
Tensor
();
Tensor
*
new_bias
=
new
Tensor
();
Tensor
*
new_bias
=
new
Tensor
();
...
...
src/operators/kernel/fpga/conv_add_relu_kernel.cpp
浏览文件 @
8f2e11bb
...
@@ -31,9 +31,9 @@ bool ConvAddReluKernel<FPGA, float>::Init(FusionConvAddReluParam *param) {
...
@@ -31,9 +31,9 @@ bool ConvAddReluKernel<FPGA, float>::Init(FusionConvAddReluParam *param) {
Tensor
*
out
=
param
->
Output
();
Tensor
*
out
=
param
->
Output
();
auto
out_ptr
=
out
->
mutable_data
<
half
>
();
auto
out_ptr
=
out
->
mutable_data
<
half
>
();
PADDLE_MOBILE_ENFORCE
(
inp
ut
->
dims
()[
1
]
==
bias
->
dims
()[
0
],
PADDLE_MOBILE_ENFORCE
(
o
ut
->
dims
()[
1
]
==
bias
->
dims
()[
0
],
"
Image
channel should be equal to bias number"
);
"
Output
channel should be equal to bias number"
);
int
channel
=
inp
ut
->
dims
()[
1
];
int
channel
=
o
ut
->
dims
()[
1
];
float
*
bs_ptr
=
(
float
*
)
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
));
float
*
bs_ptr
=
(
float
*
)
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
));
for
(
int
i
=
0
;
i
<
channel
;
i
++
)
{
for
(
int
i
=
0
;
i
<
channel
;
i
++
)
{
bs_ptr
[
i
*
2
]
=
1
;
bs_ptr
[
i
*
2
]
=
1
;
...
...
src/operators/kernel/fpga/conv_bn_kernel.cpp
浏览文件 @
8f2e11bb
...
@@ -35,10 +35,10 @@ bool ConvBNKernel<FPGA, float>::Init(FusionConvBNParam *param) {
...
@@ -35,10 +35,10 @@ bool ConvBNKernel<FPGA, float>::Init(FusionConvBNParam *param) {
auto
bn_scale_ptr
=
param
->
InputScale
()
->
data
<
float
>
();
auto
bn_scale_ptr
=
param
->
InputScale
()
->
data
<
float
>
();
auto
bn_bias_ptr
=
param
->
InputBias
()
->
data
<
float
>
();
auto
bn_bias_ptr
=
param
->
InputBias
()
->
data
<
float
>
();
const
float
epsilon
=
param
->
Epsilon
();
const
float
epsilon
=
param
->
Epsilon
();
PADDLE_MOBILE_ENFORCE
(
inp
ut
->
dims
()[
1
]
==
param
->
InputBias
()
->
dims
()[
0
],
PADDLE_MOBILE_ENFORCE
(
o
ut
->
dims
()[
1
]
==
param
->
InputBias
()
->
dims
()[
0
],
"
Image
channel should be equal to bias number"
);
"
Output
channel should be equal to bias number"
);
const
int
channel
=
inp
ut
->
dims
()[
1
];
const
int
channel
=
o
ut
->
dims
()[
1
];
float
*
bs_ptr
=
float
*
bs_ptr
=
reinterpret_cast
<
float
*>
(
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
)));
reinterpret_cast
<
float
*>
(
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
)));
Tensor
*
new_scale
=
new
Tensor
();
Tensor
*
new_scale
=
new
Tensor
();
...
...
src/operators/kernel/fpga/conv_bn_relu_kernel.cpp
浏览文件 @
8f2e11bb
...
@@ -33,10 +33,10 @@ bool ConvBNReluKernel<FPGA, float>::Init(FusionConvBNReluParam *param) {
...
@@ -33,10 +33,10 @@ bool ConvBNReluKernel<FPGA, float>::Init(FusionConvBNReluParam *param) {
auto
bn_scale_ptr
=
param
->
InputScale
()
->
data
<
float
>
();
auto
bn_scale_ptr
=
param
->
InputScale
()
->
data
<
float
>
();
auto
bn_bias_ptr
=
param
->
InputBias
()
->
data
<
float
>
();
auto
bn_bias_ptr
=
param
->
InputBias
()
->
data
<
float
>
();
const
float
epsilon
=
param
->
Epsilon
();
const
float
epsilon
=
param
->
Epsilon
();
PADDLE_MOBILE_ENFORCE
(
inp
ut
->
dims
()[
1
]
==
param
->
InputBias
()
->
dims
()[
0
],
PADDLE_MOBILE_ENFORCE
(
o
ut
->
dims
()[
1
]
==
param
->
InputBias
()
->
dims
()[
0
],
"
Image
channel should be equal to bias number"
);
"
Output
channel should be equal to bias number"
);
const
int
channel
=
inp
ut
->
dims
()[
1
];
const
int
channel
=
o
ut
->
dims
()[
1
];
float
*
bs_ptr
=
(
float
*
)
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
));
float
*
bs_ptr
=
(
float
*
)
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
));
Tensor
*
new_scale
=
new
Tensor
();
Tensor
*
new_scale
=
new
Tensor
();
Tensor
*
new_bias
=
new
Tensor
();
Tensor
*
new_bias
=
new
Tensor
();
...
...
src/operators/kernel/fpga/fc_relu_kernel.cpp
浏览文件 @
8f2e11bb
...
@@ -33,7 +33,7 @@ bool FusionFcReluKernel<FPGA, float>::Init(FusionFcReluParam *param) {
...
@@ -33,7 +33,7 @@ bool FusionFcReluKernel<FPGA, float>::Init(FusionFcReluParam *param) {
PADDLE_MOBILE_ENFORCE
(
input_x
->
dims
()[
1
]
==
input_y
->
dims
()[
0
],
PADDLE_MOBILE_ENFORCE
(
input_x
->
dims
()[
1
]
==
input_y
->
dims
()[
0
],
"Image channel should be equal to weight number"
);
"Image channel should be equal to weight number"
);
int
channel
=
input_x
->
dims
()[
1
];
int
channel
=
out
->
dims
()[
1
];
float
*
bs_ptr
=
(
float
*
)
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
));
float
*
bs_ptr
=
(
float
*
)
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
));
for
(
int
i
=
0
;
i
<
channel
;
i
++
)
{
for
(
int
i
=
0
;
i
<
channel
;
i
++
)
{
bs_ptr
[
i
*
2
]
=
1
;
bs_ptr
[
i
*
2
]
=
1
;
...
...
src/operators/kernel/fpga/fusion_fc_kernel.cpp
浏览文件 @
8f2e11bb
...
@@ -32,7 +32,7 @@ bool FusionFcKernel<FPGA, float>::Init(FusionFcParam *param) {
...
@@ -32,7 +32,7 @@ bool FusionFcKernel<FPGA, float>::Init(FusionFcParam *param) {
PADDLE_MOBILE_ENFORCE
(
input_x
->
dims
()[
1
]
==
input_y
->
dims
()[
0
],
PADDLE_MOBILE_ENFORCE
(
input_x
->
dims
()[
1
]
==
input_y
->
dims
()[
0
],
"Image channel should be equal to weight number"
);
"Image channel should be equal to weight number"
);
int
channel
=
input_x
->
dims
()[
1
];
int
channel
=
out
->
dims
()[
1
];
float
*
bs_ptr
=
(
float
*
)
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
));
float
*
bs_ptr
=
(
float
*
)
fpga
::
fpga_malloc
(
2
*
channel
*
sizeof
(
float
));
for
(
int
i
=
0
;
i
<
channel
;
i
++
)
{
for
(
int
i
=
0
;
i
<
channel
;
i
++
)
{
bs_ptr
[
i
*
2
]
=
1
;
bs_ptr
[
i
*
2
]
=
1
;
...
...
test/net/test_resnet.cpp
浏览文件 @
8f2e11bb
...
@@ -17,7 +17,13 @@ limitations under the License. */
...
@@ -17,7 +17,13 @@ limitations under the License. */
#include "../test_include.h"
#include "../test_include.h"
int
main
()
{
int
main
()
{
#ifdef PADDLE_MOBILE_FPGA
paddle_mobile
::
PaddleMobile
<
paddle_mobile
::
FPGA
>
paddle_mobile
;
#endif
#ifdef PADDLE_MOBILE_CPU
paddle_mobile
::
PaddleMobile
<
paddle_mobile
::
CPU
>
paddle_mobile
;
paddle_mobile
::
PaddleMobile
<
paddle_mobile
::
CPU
>
paddle_mobile
;
#endif
paddle_mobile
.
SetThreadNum
(
4
);
paddle_mobile
.
SetThreadNum
(
4
);
auto
time1
=
time
();
auto
time1
=
time
();
if
(
paddle_mobile
.
Load
(
g_resnet
,
true
))
{
if
(
paddle_mobile
.
Load
(
g_resnet
,
true
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录