Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
c4bc8f09
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看板
未验证
提交
c4bc8f09
编写于
10月 19, 2018
作者:
R
Ray Liu
提交者:
GitHub
10月 19, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into develop
上级
51cd8fc6
45446351
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
19 addition
and
13 deletion
+19
-13
src/fpga/api.cpp
src/fpga/api.cpp
+8
-7
src/fpga/bias_scale.cpp
src/fpga/bias_scale.cpp
+3
-0
src/fpga/filter.cpp
src/fpga/filter.cpp
+4
-4
src/operators/kernel/fpga/fc_relu_kernel.cpp
src/operators/kernel/fpga/fc_relu_kernel.cpp
+1
-0
src/operators/kernel/fpga/fusion_fc_kernel.cpp
src/operators/kernel/fpga/fusion_fc_kernel.cpp
+1
-0
src/operators/kernel/fpga/mul_kernel.cpp
src/operators/kernel/fpga/mul_kernel.cpp
+1
-0
src/operators/kernel/fpga/softmax_kernel.cpp
src/operators/kernel/fpga/softmax_kernel.cpp
+1
-2
未找到文件。
src/fpga/api.cpp
浏览文件 @
c4bc8f09
...
...
@@ -22,7 +22,7 @@ limitations under the License. */
#include "fpga/filter.h"
#include "fpga/image.h"
#define FPGA_TEST_MODE
#define PADDLE_MOBILE_OS_LINUX
//
#define PADDLE_MOBILE_OS_LINUX
namespace
paddle_mobile
{
namespace
fpga
{
...
...
@@ -125,6 +125,7 @@ float fp16_2_fp32(half fp16_num) {
}
int
ComputeBasicConv
(
const
struct
ConvArgs
&
args
)
{
#ifdef FPGA_TEST_MODE
DLOG
<<
"======Compute Basic Conv======"
;
DLOG
<<
" relu_enabled:"
<<
args
.
relu_enabled
<<
" sb_address:"
<<
args
.
sb_address
...
...
@@ -144,7 +145,7 @@ int ComputeBasicConv(const struct ConvArgs &args) {
<<
" stride_w:"
<<
args
.
kernel
.
stride_w
;
DLOG
<<
" out_address:"
<<
args
.
output
.
address
<<
" out_scale_address:"
<<
args
.
output
.
scale_address
;
#endif
return
do_ioctl
(
IOCTL_CONFIG_CONV
,
&
args
);
}
...
...
@@ -192,8 +193,9 @@ int ComputeFpgaPool(const struct PoolingArgs &args) {
int
ComputeFpgaEWAdd
(
const
struct
EWAddArgs
&
args
)
{
#ifdef FPGA_TEST_MODE
DLOG
<<
"=============ComputeFpgaEWAdd==========="
;
DLOG
<<
" relu_enabled:"
<<
args
.
relu_enabled
<<
" const0:"
<<
args
.
const0
<<
" const1:"
<<
args
.
const1
;
DLOG
<<
" relu_enabled:"
<<
args
.
relu_enabled
<<
" const0:"
<<
fp16_2_fp32
(
short
(
args
.
const0
))
<<
" const1:"
<<
fp16_2_fp32
(
short
(
args
.
const1
));
DLOG
<<
" image0_address:"
<<
args
.
image0
.
address
<<
" image0_scale_address:"
<<
args
.
image0
.
scale_address
<<
" image0_channels:"
<<
args
.
image0
.
channels
...
...
@@ -401,8 +403,8 @@ void fill_conv_arg(struct WrapperConvArgs *arg, framework::Tensor *input,
arg
->
concat_arg
.
image_num
=
arg
->
split_num
;
arg
->
concat_arg
.
image_out
=
out_ptr
;
arg
->
concat_arg
.
scale_out
=
out
->
scale
;
arg
->
concat_arg
.
height
=
(
uint32_t
)
filter
->
dims
()[
2
];
arg
->
concat_arg
.
width
=
(
uint32_t
)
filter
->
dims
()[
3
];
arg
->
concat_arg
.
height
=
(
uint32_t
)
out
->
dims
()[
2
];
arg
->
concat_arg
.
width
=
(
uint32_t
)
out
->
dims
()[
3
];
int
n
=
arg
->
split_num
;
arg
->
concat_arg
.
images_in
=
...
...
@@ -411,7 +413,6 @@ void fill_conv_arg(struct WrapperConvArgs *arg, framework::Tensor *input,
(
float
**
)
fpga_malloc
(
n
*
sizeof
(
float
*
));
// NOLINT
arg
->
concat_arg
.
channel_num
=
(
uint32_t
*
)
fpga_malloc
(
n
*
sizeof
(
uint32_t
));
// NOLINT
arg
->
concat_arg
.
image_out
=
out_ptr
;
auto
channel
=
(
int
)
out
->
dims
()[
1
];
// NOLINT
int
filter_num_per_div
=
get_filter_num_per_div
(
filter
,
group_num
);
...
...
src/fpga/bias_scale.cpp
浏览文件 @
c4bc8f09
...
...
@@ -27,6 +27,9 @@ void align_element(float **data_in, int num_per_div_before_alignment, int num) {
(
num
+
num_per_div_before_alignment
-
1
)
/
num_per_div_before_alignment
;
int
num_per_div_after_alignment
=
align_to_x
(
num_per_div_before_alignment
,
BS_NUM_ALIGNMENT
);
if
(
num_per_div_before_alignment
==
num_per_div_after_alignment
)
{
return
;
}
int
num_element
=
2
*
div_num
*
num_per_div_after_alignment
;
// including bias & scale
float
*
ptr_aligned
=
...
...
src/fpga/filter.cpp
浏览文件 @
c4bc8f09
...
...
@@ -210,12 +210,12 @@ void format_filter(float **data_in, int num, int channel, int height, int width,
align_to_x
(
num_per_div_before_alignment
,
FILTER_NUM_ALIGNMENT
);
int
div_num
=
(
num
+
num_per_div_before_alignment
-
1
)
/
num_per_div_before_alignment
;
int
num_after_alignment
=
num_per_div_after_alignment
*
div_num
;
int
residual
=
num
%
num_per_div_before_alignment
;
int
num_after_alignment
=
num_per_div_after_alignment
*
((
residual
==
0
)
?
div_num
:
(
div_num
-
1
))
+
align_to_x
(
residual
,
FILTER_NUM_ALIGNMENT
);
quantize
(
data_in
,
data_size
,
max
);
char
**
quantize_data
=
(
char
**
)
data_in
;
// NOLINT
convert_to_hwc
(
quantize_data
,
num
,
channel
,
height
,
width
);
align_element
(
quantize_data
,
num
,
chw
);
align_num
(
quantize_data
,
num_per_div_before_alignment
,
num
,
chw
);
...
...
src/operators/kernel/fpga/fc_relu_kernel.cpp
浏览文件 @
c4bc8f09
...
...
@@ -44,6 +44,7 @@ bool FusionFcReluKernel<FPGA, float>::Init(FusionFcReluParam<FPGA> *param) {
int
width
=
(
uint32_t
)
input_x
->
dims
()[
3
];
int
filter_channel
=
chw
/
height
/
width
;
out
->
Resize
(
framework
::
make_ddim
({
1
,
channel
,
1
,
1
}));
filter
->
Resize
(
framework
::
make_ddim
({
num
,
filter_channel
,
height
,
width
}));
float
max_value
=
fpga
::
filter_find_max
(
filter
);
fpga
::
format_fc_filter
(
filter
,
max_value
);
...
...
src/operators/kernel/fpga/fusion_fc_kernel.cpp
浏览文件 @
c4bc8f09
...
...
@@ -45,6 +45,7 @@ bool FusionFcKernel<FPGA, float>::Init(FusionFcParam<FPGA> *param) {
int
width
=
(
uint32_t
)
input_x
->
dims
()[
3
];
int
filter_channel
=
chw
/
height
/
width
;
out
->
Resize
(
framework
::
make_ddim
({
1
,
channel
,
1
,
1
}));
filter
->
Resize
(
framework
::
make_ddim
({
num
,
filter_channel
,
height
,
width
}));
float
max_value
=
fpga
::
filter_find_max
(
filter
);
fpga
::
format_fc_filter
(
filter
,
max_value
);
...
...
src/operators/kernel/fpga/mul_kernel.cpp
浏览文件 @
c4bc8f09
...
...
@@ -44,6 +44,7 @@ bool MulKernel<FPGA, float>::Init(MulParam<FPGA> *param) {
int
width
=
(
uint32_t
)
input_x
->
dims
()[
3
];
int
filter_channel
=
chw
/
height
/
width
;
out
->
Resize
(
framework
::
make_ddim
({
1
,
channel
,
1
,
1
}));
filter
->
Resize
(
framework
::
make_ddim
({
num
,
filter_channel
,
height
,
width
}));
float
max_value
=
fpga
::
filter_find_max
(
filter
);
fpga
::
format_fc_filter
(
filter
,
max_value
);
...
...
src/operators/kernel/fpga/softmax_kernel.cpp
浏览文件 @
c4bc8f09
...
...
@@ -27,7 +27,7 @@ bool SoftmaxKernel<FPGA, float>::Init(SoftmaxParam<FPGA> *param) {
auto
input
=
const_cast
<
Tensor
*>
(
param
->
InputX
());
auto
input_ptr
=
input
->
data
<
float
>
();
auto
float_input
=
new
Tensor
;
float_input
->
mutable_data
<
float
>
(
input
->
dims
()
);
float_input
->
mutable_data
<
float
>
(
{
1
,
input
->
dims
()[
1
]}
);
fpga
::
format_fp32_ofm
(
float_input
);
fpga
::
BypassArgs
args
=
{
fpga
::
DATA_TYPE_FP16
};
...
...
@@ -56,7 +56,6 @@ void SoftmaxKernel<FPGA, float>::Compute(
fpga
::
fpga_invalidate
(
(
void
*
)
in_x
->
data
<
float
>
(),
// NOLINT
fpga
::
get_align_image_cw
(
in_x
->
dims
()[
1
])
*
sizeof
(
float
));
math
::
SoftmaxFuntor
<
CPU
,
float
>
()(
in_x
,
out
);
fpga
::
fpga_flush
(
out
->
data
<
float
>
(),
out
->
memory_size
());
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录