Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
8ab543ff
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看板
提交
8ab543ff
编写于
9月 12, 2019
作者:
Z
zp7
提交者:
Yanzhan Yang
9月 12, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix gpu load memory leak,test=develop (#2027)
上级
e0b4b5c9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
89 addition
and
28 deletion
+89
-28
mobile/src/operators/kernel/cl/density_prior_box_kernel.cpp
mobile/src/operators/kernel/cl/density_prior_box_kernel.cpp
+32
-28
mobile/src/operators/kernel/cl/transpose2_kernel.cpp
mobile/src/operators/kernel/cl/transpose2_kernel.cpp
+2
-0
mobile/src/operators/kernel/prior_box_kernel.h
mobile/src/operators/kernel/prior_box_kernel.h
+9
-0
mobile/src/operators/op_param.h
mobile/src/operators/op_param.h
+46
-0
未找到文件。
mobile/src/operators/kernel/cl/density_prior_box_kernel.cpp
浏览文件 @
8ab543ff
...
...
@@ -25,6 +25,35 @@ bool DensityPriorBoxKernel<GPU_CL, float>::Init(
*
param
)
{
this
->
cl_helper_
.
AddKernel
(
"density_prior_box"
,
"density_prior_box_kernel.cl"
);
vector
<
float
>
fixed_sizes
=
param
->
FixedSizes
();
vector
<
float
>
fixed_ratios
=
param
->
FixedRatios
();
vector
<
int
>
densities
=
param
->
Densities
();
vector
<
float
>
variances
=
param
->
Variances
();
int
fix_ratio_size
=
fixed_ratios
.
size
();
int
total_size
=
densities
.
size
()
+
fixed_sizes
.
size
()
+
fix_ratio_size
;
float
*
densities_data
=
new
float
[
total_size
];
for
(
int
i
=
0
;
i
<
densities
.
size
();
++
i
)
{
float
density
=
densities
[
i
];
densities_data
[
i
]
=
density
;
}
for
(
int
k
=
0
;
k
<
fixed_sizes
.
size
();
++
k
)
{
densities_data
[
k
+
densities
.
size
()]
=
fixed_sizes
[
k
];
}
for
(
int
j
=
0
;
j
<
fixed_ratios
.
size
();
++
j
)
{
float
sqrt_ratios
=
sqrt
(
fixed_ratios
[
j
]);
densities_data
[
j
+
densities
.
size
()
+
fixed_sizes
.
size
()]
=
sqrt_ratios
;
}
framework
::
CLImage
*
new_density
=
new
framework
::
CLImage
();
new_density
->
SetTensorData
(
densities_data
,
{
1
,
1
,
1
,
total_size
});
new_density
->
InitCLImage
(
this
->
cl_helper_
.
CLContext
(),
this
->
cl_helper_
.
CLCommandQueue
());
param
->
setNewDensity
(
new_density
);
delete
[](
densities_data
);
return
true
;
}
...
...
@@ -39,6 +68,7 @@ void DensityPriorBoxKernel<GPU_CL, float>::Compute(
auto
output_boxes
=
param
.
OutputBoxes
()
->
GetCLImage
();
auto
output_var
=
param
.
OutputVariances
()
->
GetCLImage
();
auto
new_deensity
=
param
.
getNewDensity
()
->
GetCLImage
();
float
step_w
=
param
.
StepW
();
float
step_h
=
param
.
StepH
();
...
...
@@ -73,43 +103,17 @@ void DensityPriorBoxKernel<GPU_CL, float>::Compute(
auto
default_work
=
this
->
cl_helper_
.
DefaultWorkSize
(
*
param
.
OutputBoxes
());
float
*
densities_data
[
densities
.
size
()
+
fixed_sizes
.
size
()
+
fix_ratio_size
];
int
status
;
for
(
int
i
=
0
;
i
<
densities
.
size
();
++
i
)
{
float
density
=
densities
[
i
];
densities_data
[
i
]
=
&
density
;
}
for
(
int
k
=
0
;
k
<
fixed_sizes
.
size
();
++
k
)
{
densities_data
[
k
+
densities
.
size
()]
=
&
fixed_sizes
[
k
];
}
for
(
int
j
=
0
;
j
<
fixed_ratios
.
size
();
++
j
)
{
float
sqrt_ratios
=
sqrt
(
fixed_ratios
[
j
]);
densities_data
[
j
+
densities
.
size
()
+
fixed_sizes
.
size
()]
=
&
sqrt_ratios
;
}
cl_mem
densities_memobj
=
clCreateBuffer
(
this
->
cl_helper_
.
CLContext
(),
CL_MEM_READ_WRITE
,
sizeof
(
float
)
*
(
densities
.
size
()
*
2
+
fix_ratio_size
),
NULL
,
&
status
);
status
=
clEnqueueWriteBuffer
(
this
->
cl_helper_
.
CLCommandQueue
(),
densities_memobj
,
CL_FALSE
,
0
,
(
densities
.
size
()
*
2
+
fix_ratio_size
)
*
sizeof
(
float
),
densities_data
,
0
,
NULL
,
NULL
);
CL_CHECK_ERRORS
(
status
);
float
variances0
=
variances
[
0
];
float
variances1
=
variances
[
1
];
float
variances2
=
variances
[
2
];
float
variances3
=
variances
[
3
];
cl_int
status
;
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
output_boxes
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_mem
),
&
output_var
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
2
,
sizeof
(
cl_mem
),
&
densities_memobj
);
status
=
clSetKernelArg
(
kernel
,
2
,
sizeof
(
cl_mem
),
&
new_deensity
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
3
,
sizeof
(
float
),
&
step_h
);
CL_CHECK_ERRORS
(
status
);
...
...
mobile/src/operators/kernel/cl/transpose2_kernel.cpp
浏览文件 @
8ab543ff
...
...
@@ -184,6 +184,8 @@ void Transpose2Compute(const Transpose2Param<GPU_CL> ¶m, cl_context context,
output
->
InitEmptyImage
(
context
,
commandQueue
,
output_tensor
->
dims
());
framework
::
TensorToCLImage
(
output_tensor
,
output
,
context
,
commandQueue
,
kernel1
);
delete
(
input_tensor
);
delete
(
output_tensor
);
}
template
<
>
...
...
mobile/src/operators/kernel/prior_box_kernel.h
浏览文件 @
8ab543ff
...
...
@@ -77,6 +77,12 @@ class DensityPriorBoxParam : public OpParam {
densities_
=
GetAttr
<
vector
<
int
>>
(
"densities"
,
attrs
);
}
~
DensityPriorBoxParam
()
{
if
(
new_density
)
{
delete
new_density
;
}
}
const
GType
*
Input
()
const
{
return
input_
;
}
const
GType
*
InputImage
()
const
{
return
input_image_
;
}
GType
*
OutputBoxes
()
const
{
return
output_boxes_
;
}
...
...
@@ -90,6 +96,8 @@ class DensityPriorBoxParam : public OpParam {
const
vector
<
float
>
&
FixedRatios
()
const
{
return
fixed_ratios_
;
}
const
vector
<
int
>
&
Densities
()
const
{
return
densities_
;
}
const
vector
<
float
>
&
Variances
()
const
{
return
variances_
;
}
GType
*
getNewDensity
()
const
{
return
new_density
;
}
void
setNewDensity
(
GType
*
newDensity
)
{
new_density
=
newDensity
;
}
public:
GType
*
input_
;
...
...
@@ -105,6 +113,7 @@ class DensityPriorBoxParam : public OpParam {
vector
<
float
>
fixed_ratios_
;
vector
<
int
>
densities_
;
vector
<
float
>
variances_
;
GType
*
new_density
;
};
DECLARE_KERNEL
(
DensityPriorBox
,
DensityPriorBoxParam
);
...
...
mobile/src/operators/op_param.h
浏览文件 @
8ab543ff
...
...
@@ -850,6 +850,15 @@ class BatchNormParam : public OpParam {
// is_test_ = GetAttr<bool>("is_test", attrs);
}
~
BatchNormParam
()
{
if
(
new_bias_
)
{
delete
new_bias_
;
}
if
(
new_scale_
)
{
delete
new_scale_
;
}
}
const
GType
*
InputX
()
const
{
return
input_x_
;
}
GType
*
OutputY
()
const
{
return
output_y_
;
}
...
...
@@ -2076,6 +2085,16 @@ class FusionConvAddBNReluParam : public ConvParam<Dtype> {
momentum_
=
OpParam
::
GetAttr
<
float
>
(
"momentum"
,
attrs
);
this
->
output_
=
OpParam
::
OutFrom
<
GType
>
(
outputs
,
*
scope
);
}
~
FusionConvAddBNReluParam
()
{
if
(
new_bias_
)
{
delete
new_bias_
;
}
if
(
new_scale_
)
{
delete
new_scale_
;
}
}
GType
*
Bias
()
const
{
return
bias_
;
}
const
int
&
Axis
()
const
{
return
axis_
;
}
...
...
@@ -2143,6 +2162,15 @@ class FusionConvBNAddReluParam : public ConvParam<Dtype> {
}
this
->
output_
=
OpParam
::
OutFrom
<
GType
>
(
outputs
,
*
scope
);
}
~
FusionConvBNAddReluParam
()
{
if
(
new_bias_
)
{
delete
new_bias_
;
}
if
(
new_scale_
)
{
delete
new_scale_
;
}
}
GType
*
Bias
()
const
{
return
bias_
;
}
const
int
&
Axis
()
const
{
return
axis_
;
}
...
...
@@ -2315,6 +2343,15 @@ class FusionDWConvBNReluParam : public ConvParam<Dtype> {
this
->
output_
=
OpParam
::
OutFrom
<
GType
>
(
outputs
,
*
scope
);
}
~
FusionDWConvBNReluParam
()
{
if
(
new_bias_
)
{
delete
new_bias_
;
}
if
(
new_scale_
)
{
delete
new_scale_
;
}
}
const
GType
*
InputBias
()
const
{
return
input_bias_
;
}
const
GType
*
InputMean
()
const
{
return
input_mean_
;
}
...
...
@@ -2384,6 +2421,15 @@ class FusionConvBNReluParam : public ConvParam<Dtype> {
this
->
output_
=
OpParam
::
OutFrom
<
GType
>
(
outputs
,
*
scope
);
}
~
FusionConvBNReluParam
()
{
if
(
new_bias_
)
{
delete
new_bias_
;
}
if
(
new_scale_
)
{
delete
new_scale_
;
}
}
const
GType
*
InputBias
()
const
{
return
input_bias_
;
}
const
GType
*
InputMean
()
const
{
return
input_mean_
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录