Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
3a8d22a4
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看板
提交
3a8d22a4
编写于
2月 15, 2019
作者:
qnqinan
提交者:
GitHub
2月 15, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1438 from zhangyang0701/develop
Avoid memory leakage for FPGA track close
#1372
上级
73a623d0
9fcd5954
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
33 addition
and
14 deletion
+33
-14
src/fpga/V1/api.cpp
src/fpga/V1/api.cpp
+8
-5
src/fpga/V1/deconv_filter.cpp
src/fpga/V1/deconv_filter.cpp
+1
-0
src/fpga/common/fpga_common.h
src/fpga/common/fpga_common.h
+2
-0
src/operators/kernel/fpga/V1/conv_add_bn_kernel.cpp
src/operators/kernel/fpga/V1/conv_add_bn_kernel.cpp
+3
-2
src/operators/kernel/fpga/V1/conv_add_bn_relu_kernel.cpp
src/operators/kernel/fpga/V1/conv_add_bn_relu_kernel.cpp
+4
-2
src/operators/kernel/fpga/V1/conv_bn_kernel.cpp
src/operators/kernel/fpga/V1/conv_bn_kernel.cpp
+2
-2
src/operators/kernel/fpga/V1/conv_bn_relu_kernel.cpp
src/operators/kernel/fpga/V1/conv_bn_relu_kernel.cpp
+3
-2
src/operators/kernel/fpga/V1/split_kernel.cpp
src/operators/kernel/fpga/V1/split_kernel.cpp
+8
-0
test/fpga/test_rfcn.cpp
test/fpga/test_rfcn.cpp
+2
-1
未找到文件。
src/fpga/V1/api.cpp
浏览文件 @
3a8d22a4
...
...
@@ -623,7 +623,7 @@ void fill_deconv_arg(struct DeconvArgs *arg, framework::Tensor *input,
fpga
::
format_fp16_ofm
(
out
,
dims_out_new
);
auto
out_ptr
=
out
->
data
<
half
>
();
arg
->
output
.
address
=
(
half
*
)
out_ptr
+
// NOLINT
out_ptr
+
omit_size
*
sizeof
(
half
)
*
(
align_to_x
(
real_out_width
*
arg
->
filter_num
,
IMAGE_ALIGNMENT
));
arg
->
output
.
scale_address
=
out
->
scale
;
...
...
@@ -713,7 +713,6 @@ void fill_deconv_arg(struct DeconvArgs *arg, framework::Tensor *input,
}
for
(
int
j
=
0
;
j
<
split_num
;
++
j
)
{
// arg->split_conv_args[i]->conv_arg[j].relu_enabled = relu_enabled;
arg
->
split_conv_args
[
i
]
->
conv_arg
[
j
].
output
.
activation
.
activation_type
=
activation_enable
;
arg
->
split_conv_args
[
i
]
...
...
@@ -759,9 +758,9 @@ void fill_deconv_arg(struct DeconvArgs *arg, framework::Tensor *input,
align_to_x
(
arg
->
split_conv_args
[
i
]
->
conv_arg
[
j
].
filter_num
,
FILTER_NUM_ALIGNMENT
)
*
sizeof
(
int8_t
);
auto
filter_head
=
&
((
int8_t
*
)
filter_ptr
)
[
j
*
element_num
*
filter_num_per_div
+
// NOLINT
i
*
filter_sub_conv_offset
];
auto
filter_head
=
&
filter_ptr
[
j
*
element_num
*
filter_num_per_div
+
// NOLINT
i
*
filter_sub_conv_offset
];
arg
->
split_conv_args
[
i
]
->
conv_arg
[
j
].
filter_address
=
fpga_malloc
(
filter_size
);
arg
->
split_conv_args
[
i
]
->
vector_conv_space
.
push_back
(
...
...
@@ -836,6 +835,10 @@ void fill_dwconv_arg(struct DWconvArgs *arg, framework::Tensor *input,
int16_t
leaky_relu_negative_slope
,
int
stride_h
,
int
stride_w
,
int
padding_h
,
int
padding_w
,
float
*
bias_ptr
)
{
auto
deleter
=
[](
void
*
p
)
{
fpga_free
(
p
);
};
arg
->
vector_dwconv_space
.
push_back
(
std
::
shared_ptr
<
char
>
(
reinterpret_cast
<
char
*>
(
bias_ptr
),
deleter
));
auto
filter_ptr
=
filter
->
data
<
uint8_t
>
();
auto
input_ptr
=
input
->
data
<
half
>
();
auto
output_ptr
=
out
->
mutable_data
<
half
>
();
...
...
src/fpga/V1/deconv_filter.cpp
浏览文件 @
3a8d22a4
...
...
@@ -247,6 +247,7 @@ void deconv_format_filter(float** data_in, int num, int channel, int height,
fpga_copy
(
ptr_space
+
i
*
align_offset
,
ptr_tmp
,
align_offset
);
fpga_free
(
ptr_tmp
);
}
fpga_free
(
ptr_ptr_data
);
*
data_in
=
reinterpret_cast
<
float
*>
(
ptr_space
);
/* {
...
...
src/fpga/common/fpga_common.h
浏览文件 @
3a8d22a4
...
...
@@ -187,6 +187,7 @@ struct SplitArgs {
uint32_t
*
out_channel_nums
;
uint32_t
height
;
uint32_t
width
;
std
::
vector
<
std
::
shared_ptr
<
char
>>
vector_split_space
;
};
struct
PoolingArgs
{
...
...
@@ -236,6 +237,7 @@ struct DWconvArgs {
struct
KernelArgs
kernel
;
struct
ImageInputArgs
image
;
struct
ImageOutputArgs
output
;
std
::
vector
<
std
::
shared_ptr
<
char
>>
vector_dwconv_space
;
};
struct
DWDeconvArgs
{
...
...
src/operators/kernel/fpga/V1/conv_add_bn_kernel.cpp
浏览文件 @
3a8d22a4
...
...
@@ -59,8 +59,6 @@ bool ConvAddBNKernel<FPGA, float>::Init(FusionConvAddBNParam<FPGA> *param) {
bs_ptr
[
i
+
channel
]
=
new_scale_ptr
[
i
];
bs_ptr
[
i
]
=
new_bias_ptr
[
i
];
}
param
->
SetNewScale
(
new_scale
);
param
->
SetNewBias
(
new_bias
);
fpga
::
format_conv_data
(
filter
,
out
,
&
bs_ptr
,
param
->
Groups
());
fpga
::
SplitConvArgs
conv_arg
=
{
0
};
...
...
@@ -70,6 +68,9 @@ bool ConvAddBNKernel<FPGA, float>::Init(FusionConvAddBNParam<FPGA> *param) {
param
->
Paddings
()[
0
],
param
->
Paddings
()[
1
],
bs_ptr
);
param
->
SetFpgaArgs
(
conv_arg
);
delete
new_scale
;
delete
new_bias
;
return
true
;
}
...
...
src/operators/kernel/fpga/V1/conv_add_bn_relu_kernel.cpp
浏览文件 @
3a8d22a4
...
...
@@ -60,8 +60,6 @@ bool ConvAddBNReluKernel<FPGA, float>::Init(
bs_ptr
[
i
+
channel
]
=
new_scale_ptr
[
i
];
bs_ptr
[
i
]
=
new_bias_ptr
[
i
];
}
param
->
SetNewScale
(
new_scale
);
param
->
SetNewBias
(
new_bias
);
const
int
groups
=
param
->
Groups
();
if
(
groups
==
channel
)
{
...
...
@@ -71,6 +69,8 @@ bool ConvAddBNReluKernel<FPGA, float>::Init(
leaky_relu_negative_slope
,
strides
[
0
],
strides
[
1
],
paddings
[
0
],
paddings
[
1
],
new_bias_ptr
);
param
->
SetFpgaArgs
(
dwconv_arg
);
fpga
::
fpga_free
(
new_scale_ptr
);
fpga
::
fpga_free
(
bs_ptr
);
}
else
{
fpga
::
format_conv_data
(
filter
,
out
,
&
bs_ptr
,
param
->
Groups
());
fpga
::
SplitConvArgs
conv_arg
=
{
0
};
...
...
@@ -78,6 +78,8 @@ bool ConvAddBNReluKernel<FPGA, float>::Init(
leaky_relu_negative_slope
,
param
->
Groups
(),
strides
[
0
],
strides
[
1
],
paddings
[
0
],
paddings
[
1
],
bs_ptr
);
param
->
SetFpgaArgs
(
conv_arg
);
delete
new_scale
;
delete
new_bias
;
}
return
true
;
}
...
...
src/operators/kernel/fpga/V1/conv_bn_kernel.cpp
浏览文件 @
3a8d22a4
...
...
@@ -51,8 +51,6 @@ bool ConvBNKernel<FPGA, float>::Init(FusionConvBNParam<FPGA> *param) {
bs_ptr
[
i
+
channel
]
=
new_scale_ptr
[
i
];
bs_ptr
[
i
]
=
new_bias_ptr
[
i
];
}
param
->
SetNewScale
(
new_scale
);
param
->
SetNewBias
(
new_bias
);
fpga
::
format_conv_data
(
filter
,
out
,
&
bs_ptr
,
param
->
Groups
());
fpga
::
SplitConvArgs
conv_arg
=
{
0
};
...
...
@@ -61,6 +59,8 @@ bool ConvBNKernel<FPGA, float>::Init(FusionConvBNParam<FPGA> *param) {
param
->
Strides
()[
0
],
param
->
Strides
()[
1
],
param
->
Paddings
()[
0
],
param
->
Paddings
()[
1
],
bs_ptr
);
param
->
SetFpgaArgs
(
conv_arg
);
delete
new_scale
;
delete
new_bias
;
return
true
;
}
...
...
src/operators/kernel/fpga/V1/conv_bn_relu_kernel.cpp
浏览文件 @
3a8d22a4
...
...
@@ -51,8 +51,6 @@ bool ConvBNReluKernel<FPGA, float>::Init(FusionConvBNReluParam<FPGA> *param) {
bs_ptr
[
i
+
channel
]
=
new_scale_ptr
[
i
];
bs_ptr
[
i
]
=
new_bias_ptr
[
i
];
}
param
->
SetNewScale
(
new_scale
);
param
->
SetNewBias
(
new_bias
);
fpga
::
format_conv_data
(
filter
,
out
,
&
bs_ptr
,
param
->
Groups
());
fpga
::
SplitConvArgs
conv_arg
=
{
0
};
...
...
@@ -61,6 +59,9 @@ bool ConvBNReluKernel<FPGA, float>::Init(FusionConvBNReluParam<FPGA> *param) {
param
->
Strides
()[
0
],
param
->
Strides
()[
1
],
param
->
Paddings
()[
0
],
param
->
Paddings
()[
1
],
bs_ptr
);
param
->
SetFpgaArgs
(
conv_arg
);
delete
new_scale
;
delete
new_bias
;
return
true
;
}
...
...
src/operators/kernel/fpga/V1/split_kernel.cpp
浏览文件 @
3a8d22a4
...
...
@@ -43,6 +43,8 @@ bool SplitKernel<FPGA, float>::Init(SplitParam<FPGA> *param) {
out_channels
[
i
]
=
(
uint32_t
)
sections
[
i
];
}
auto
deleter
=
[](
void
*
p
)
{
fpga
::
fpga_free
(
p
);
};
fpga
::
SplitArgs
arg
=
{
0
};
arg
.
image_num
=
image_num
;
arg
.
image_in
=
in
->
data
<
half
>
();
...
...
@@ -52,6 +54,12 @@ bool SplitKernel<FPGA, float>::Init(SplitParam<FPGA> *param) {
arg
.
out_channel_nums
=
out_channels
;
arg
.
height
=
(
uint32_t
)
in
->
dims
()[
2
];
arg
.
width
=
(
uint32_t
)
in
->
dims
()[
3
];
arg
.
vector_split_space
.
push_back
(
std
::
shared_ptr
<
char
>
(
reinterpret_cast
<
char
*>
(
images_out
),
deleter
));
arg
.
vector_split_space
.
push_back
(
std
::
shared_ptr
<
char
>
(
reinterpret_cast
<
char
*>
(
scales_out
),
deleter
));
arg
.
vector_split_space
.
push_back
(
std
::
shared_ptr
<
char
>
(
reinterpret_cast
<
char
*>
(
out_channels
),
deleter
));
param
->
SetFpgaArgs
(
arg
);
return
true
;
...
...
test/fpga/test_rfcn.cpp
浏览文件 @
3a8d22a4
...
...
@@ -39,7 +39,7 @@ void readStream(std::string filename, uint8_t *buf) {
}
static
const
char
*
g_rfcn_combine
=
"../models/rfcn"
;
const
std
::
string
g_image_src_float
=
"../models/rfcn/data.bin"
;
static
const
char
*
g_image_src_float
=
"../models/rfcn/data.bin"
;
int
main
()
{
paddle_mobile
::
fpga
::
open_device
();
paddle_mobile
::
PaddleMobile
<
paddle_mobile
::
FPGA
>
paddle_mobile
;
...
...
@@ -55,6 +55,7 @@ int main() {
paddle_mobile
.
Predict_To
(
-
1
);
paddle_mobile
.
GetResults
(
&
v
);
DLOG
<<
"Computation done"
;
fpga
::
fpga_free
(
img
);
}
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录