Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
004c7a94
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看板
未验证
提交
004c7a94
编写于
8月 14, 2018
作者:
S
smilejames
提交者:
GitHub
8月 14, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into develop
上级
85dad965
3c348eb4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
12 deletion
+27
-12
src/fpga/fpga_quantilization.cpp
src/fpga/fpga_quantilization.cpp
+3
-3
src/fpga/fpga_quantilization.h
src/fpga/fpga_quantilization.h
+2
-2
src/operators/kernel/fpga/conv_add_bn_kernel.cpp
src/operators/kernel/fpga/conv_add_bn_kernel.cpp
+6
-6
src/operators/op_param.h
src/operators/op_param.h
+16
-1
未找到文件。
src/fpga/fpga_quantilization.cpp
浏览文件 @
004c7a94
...
@@ -46,8 +46,8 @@ static Dtype find_max(Dtype* data, int num) {
...
@@ -46,8 +46,8 @@ static Dtype find_max(Dtype* data, int num) {
return
max
;
return
max
;
}
}
template
<
typename
Dtype
>
//
template <typename Dtype>
framework
::
Tensor
*
quanti
lize
_filter
(
framework
::
Tensor
*
filter
)
{
framework
::
Tensor
*
quanti
fy
_filter
(
framework
::
Tensor
*
filter
)
{
float
scale
=
0
;
float
scale
=
0
;
float
fix_range
=
static_cast
<
float
>
((
1
<<
(
8
-
1
))
-
1
);
float
fix_range
=
static_cast
<
float
>
((
1
<<
(
8
-
1
))
-
1
);
...
@@ -57,7 +57,7 @@ framework::Tensor* quantilize_filter(framework::Tensor* filter) {
...
@@ -57,7 +57,7 @@ framework::Tensor* quantilize_filter(framework::Tensor* filter) {
const
int
width
=
filter
->
dims
()[
3
];
const
int
width
=
filter
->
dims
()[
3
];
int8_t
*
int_data
=
nullptr
;
int8_t
*
int_data
=
nullptr
;
int8_t
*
tmp_data
=
new
int
[
filter
->
numel
()];
int8_t
*
tmp_data
=
new
int
8_t
[
filter
->
numel
()];
// 32bit filter -> 8bit filter;
// 32bit filter -> 8bit filter;
if
(
filter
->
type
()
==
typeid
(
float
))
{
if
(
filter
->
type
()
==
typeid
(
float
))
{
...
...
src/fpga/fpga_quantilization.h
浏览文件 @
004c7a94
...
@@ -24,7 +24,7 @@ template <typename Dtype>
...
@@ -24,7 +24,7 @@ template <typename Dtype>
static
void
chw_to_hwc
(
Dtype
*
data_in
,
Dtype
*
data_out
,
int
num
,
int
channel
,
static
void
chw_to_hwc
(
Dtype
*
data_in
,
Dtype
*
data_out
,
int
num
,
int
channel
,
int
height
,
int
width
);
int
height
,
int
width
);
template
<
typename
Dtype
>
//
template <typename Dtype>
framework
::
Tensor
*
quanti
lize
_filter
(
framework
::
Tensor
*
filter
);
framework
::
Tensor
*
quanti
fy
_filter
(
framework
::
Tensor
*
filter
);
}
// namespace fpga
}
// namespace fpga
}
// namespace paddle_mobile
}
// namespace paddle_mobile
src/operators/kernel/fpga/conv_add_bn_kernel.cpp
浏览文件 @
004c7a94
...
@@ -28,7 +28,7 @@ bool ConvAddBNKernel<FPGA, float>::Init(FusionConvAddBNParam *param) {
...
@@ -28,7 +28,7 @@ bool ConvAddBNKernel<FPGA, float>::Init(FusionConvAddBNParam *param) {
auto
input_ptr
=
input
->
data
<
half
>
();
auto
input_ptr
=
input
->
data
<
half
>
();
const
Tensor
*
bias
=
param
->
Bias
();
const
Tensor
*
bias
=
param
->
Bias
();
auto
bias_ptr
=
bias
->
data
<
float
>
();
auto
bias_ptr
=
bias
->
data
<
float
>
();
const
Tensor
*
filter
=
param
->
Filter
();
Tensor
*
filter
=
param
->
Filter
();
Tensor
*
out
=
param
->
Output
();
Tensor
*
out
=
param
->
Output
();
auto
out_ptr
=
out
->
mutable_data
<
half
>
();
auto
out_ptr
=
out
->
mutable_data
<
half
>
();
...
@@ -60,7 +60,7 @@ bool ConvAddBNKernel<FPGA, float>::Init(FusionConvAddBNParam *param) {
...
@@ -60,7 +60,7 @@ bool ConvAddBNKernel<FPGA, float>::Init(FusionConvAddBNParam *param) {
param
->
SetNewScale
(
new_scale
);
param
->
SetNewScale
(
new_scale
);
param
->
SetNewBias
(
new_bias
);
param
->
SetNewBias
(
new_bias
);
const
Tensor
*
quant_filter
=
quantilize
_filter
(
filter
);
Tensor
*
quant_filter
=
fpga
::
quantify
_filter
(
filter
);
// delete original filter?
// delete original filter?
filter
=
quant_filter
;
filter
=
quant_filter
;
...
@@ -68,22 +68,22 @@ bool ConvAddBNKernel<FPGA, float>::Init(FusionConvAddBNParam *param) {
...
@@ -68,22 +68,22 @@ bool ConvAddBNKernel<FPGA, float>::Init(FusionConvAddBNParam *param) {
auto
filter_ptr
=
filter
->
data
<
float
>
();
auto
filter_ptr
=
filter
->
data
<
float
>
();
fpga
::
ConvArgs
convArgs
;
fpga
::
ConvArgs
convArgs
;
convArgs
.
relu_enabled
=
relu_enabled
;
convArgs
.
relu_enabled
=
relu_enabled
;
convArgs
.
filter_address
=
reinterpret_cast
<
void
*>
filter_ptr
;
convArgs
.
filter_address
=
(
void
*
)
filter_ptr
;
convArgs
.
filter_num
=
filter
->
dims
()[
0
];
convArgs
.
filter_num
=
filter
->
dims
()[
0
];
convArgs
.
group_num
=
param
->
Groups
();
convArgs
.
group_num
=
param
->
Groups
();
convArgs
.
sb_address
=
reinterpret_cast
<
void
*>
bs_ptr
;
convArgs
.
sb_address
=
(
void
*
)
bs_ptr
;
convArgs
.
kernel
.
stride_h
=
param
->
Strides
()[
0
];
convArgs
.
kernel
.
stride_h
=
param
->
Strides
()[
0
];
convArgs
.
kernel
.
stride_w
=
param
->
Strides
()[
1
];
convArgs
.
kernel
.
stride_w
=
param
->
Strides
()[
1
];
convArgs
.
kernel
.
height
=
filter
->
dims
()[
2
];
convArgs
.
kernel
.
height
=
filter
->
dims
()[
2
];
convArgs
.
kernel
.
width
=
filter
->
dims
()[
3
];
convArgs
.
kernel
.
width
=
filter
->
dims
()[
3
];
convArgs
.
image
.
address
=
reinterpret_cast
<
void
*>
input_ptr
;
convArgs
.
image
.
address
=
(
void
*
)
input_ptr
;
convArgs
.
image
.
channels
=
input
->
dims
()[
1
];
convArgs
.
image
.
channels
=
input
->
dims
()[
1
];
convArgs
.
image
.
height
=
input
->
dims
()[
2
];
convArgs
.
image
.
height
=
input
->
dims
()[
2
];
convArgs
.
image
.
width
=
input
->
dims
()[
3
];
convArgs
.
image
.
width
=
input
->
dims
()[
3
];
convArgs
.
image
.
pad_height
=
param
->
Paddings
()[
0
];
convArgs
.
image
.
pad_height
=
param
->
Paddings
()[
0
];
convArgs
.
image
.
pad_width
=
param
->
Paddings
()[
1
];
convArgs
.
image
.
pad_width
=
param
->
Paddings
()[
1
];
convArgs
.
image
.
scale_address
=
input
->
fpga_args
().
scale_pointer
();
convArgs
.
image
.
scale_address
=
input
->
fpga_args
().
scale_pointer
();
convArgs
.
output
.
address
=
reinterpret_cast
<
void
*>
out_ptr
;
convArgs
.
output
.
address
=
(
void
*
)
out_ptr
;
convArgs
.
output
.
scale_address
=
out
->
fpga_args
().
scale_pointer
();
convArgs
.
output
.
scale_address
=
out
->
fpga_args
().
scale_pointer
();
param
->
SetFpgaArgs
(
convArgs
);
param
->
SetFpgaArgs
(
convArgs
);
...
...
src/operators/op_param.h
浏览文件 @
004c7a94
...
@@ -920,7 +920,11 @@ class FusionFcParam : public OpParam {
...
@@ -920,7 +920,11 @@ class FusionFcParam : public OpParam {
}
}
const
Tensor
*
InputX
()
const
{
return
input_x_
;
}
const
Tensor
*
InputX
()
const
{
return
input_x_
;
}
#ifdef PADDLE_MOBILE_FPGA
Tensor
*
InputY
()
const
{
return
input_y_
;
}
#else
const
Tensor
*
InputY
()
const
{
return
input_y_
;
}
const
Tensor
*
InputY
()
const
{
return
input_y_
;
}
#endif
const
Tensor
*
InputZ
()
const
{
return
input_z_
;
}
const
Tensor
*
InputZ
()
const
{
return
input_z_
;
}
...
@@ -976,7 +980,11 @@ class FusionConvAddParam : public OpParam {
...
@@ -976,7 +980,11 @@ class FusionConvAddParam : public OpParam {
const
Tensor
*
Input
()
const
{
return
input_
;
}
const
Tensor
*
Input
()
const
{
return
input_
;
}
#ifdef PADDLE_MOBILE_FPGA
Tensor
*
Filter
()
const
{
return
filter_
;
}
#else
const
Tensor
*
Filter
()
const
{
return
filter_
;
}
const
Tensor
*
Filter
()
const
{
return
filter_
;
}
#endif
Tensor
*
Output
()
const
{
return
output_
;
}
Tensor
*
Output
()
const
{
return
output_
;
}
...
@@ -1050,7 +1058,11 @@ class FusionConvAddBNReluParam : public OpParam {
...
@@ -1050,7 +1058,11 @@ class FusionConvAddBNReluParam : public OpParam {
const
Tensor
*
Input
()
const
{
return
input_
;
}
const
Tensor
*
Input
()
const
{
return
input_
;
}
#ifdef PADDLE_MOBILE_FPGA
Tensor
*
Filter
()
const
{
return
filter_
;
}
#else
const
Tensor
*
Filter
()
const
{
return
filter_
;
}
const
Tensor
*
Filter
()
const
{
return
filter_
;
}
#endif
Tensor
*
Output
()
const
{
return
output_
;
}
Tensor
*
Output
()
const
{
return
output_
;
}
...
@@ -1144,8 +1156,11 @@ class FusionConvAddBNParam : public OpParam {
...
@@ -1144,8 +1156,11 @@ class FusionConvAddBNParam : public OpParam {
const
Tensor
*
Input
()
const
{
return
input_
;
}
const
Tensor
*
Input
()
const
{
return
input_
;
}
#ifdef PADDLE_MOBILE_FPGA
Tensor
*
Filter
()
const
{
return
filter_
;
}
#else
const
Tensor
*
Filter
()
const
{
return
filter_
;
}
const
Tensor
*
Filter
()
const
{
return
filter_
;
}
#endif
Tensor
*
Output
()
const
{
return
output_y_
;
}
Tensor
*
Output
()
const
{
return
output_y_
;
}
const
vector
<
int
>
&
Strides
()
const
{
return
strides_
;
}
const
vector
<
int
>
&
Strides
()
const
{
return
strides_
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录