Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
462f4649
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看板
提交
462f4649
编写于
9月 03, 2019
作者:
Y
Yanzhan Yang
提交者:
zp7
9月 03, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add cl status check test=develop (#1956)
上级
31ee212a
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
185 addition
and
131 deletion
+185
-131
mobile/src/framework/cl/cl_image.cpp
mobile/src/framework/cl/cl_image.cpp
+20
-10
mobile/src/operators/kernel/cl/batchnorm_kernel.cpp
mobile/src/operators/kernel/cl/batchnorm_kernel.cpp
+9
-7
mobile/src/operators/kernel/cl/fetch_kernel.cpp
mobile/src/operators/kernel/cl/fetch_kernel.cpp
+21
-13
mobile/src/operators/kernel/cl/instancenorm_kernel.cpp
mobile/src/operators/kernel/cl/instancenorm_kernel.cpp
+12
-10
mobile/src/operators/kernel/cl/pool_kernel.cpp
mobile/src/operators/kernel/cl/pool_kernel.cpp
+29
-14
mobile/src/operators/kernel/cl/relu_kernel.cpp
mobile/src/operators/kernel/cl/relu_kernel.cpp
+8
-4
mobile/src/operators/kernel/cl/scale_kernel.cpp
mobile/src/operators/kernel/cl/scale_kernel.cpp
+16
-8
mobile/src/operators/kernel/cl/tanh_kernel.cpp
mobile/src/operators/kernel/cl/tanh_kernel.cpp
+8
-4
mobile/tools/python/fluidtools/run.py
mobile/tools/python/fluidtools/run.py
+62
-61
未找到文件。
mobile/src/framework/cl/cl_image.cpp
浏览文件 @
462f4649
...
@@ -38,21 +38,31 @@ void CLImageToTensor(CLImage *cl_image, Tensor *tensor, cl_context context,
...
@@ -38,21 +38,31 @@ void CLImageToTensor(CLImage *cl_image, Tensor *tensor, cl_context context,
auto
input_image
=
cl_image
->
GetCLImage
();
auto
input_image
=
cl_image
->
GetCLImage
();
clSetKernelArg
(
kernel
,
0
,
sizeof
(
int
),
&
in_height
);
cl_int
status
;
clSetKernelArg
(
kernel
,
1
,
sizeof
(
int
),
&
in_width
);
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
int
),
&
in_height
);
clSetKernelArg
(
kernel
,
2
,
sizeof
(
cl_mem
),
&
input_image
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
3
,
sizeof
(
cl_mem
),
&
outBuffer
);
status
=
clSetKernelArg
(
kernel
,
1
,
sizeof
(
int
),
&
in_width
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
2
,
sizeof
(
cl_mem
),
&
input_image
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
3
,
sizeof
(
cl_mem
),
&
outBuffer
);
CL_CHECK_ERRORS
(
status
);
int
size_ch
=
in_height
*
in_width
;
int
size_ch
=
in_height
*
in_width
;
int
size_block
=
size_ch
*
4
;
int
size_block
=
size_ch
*
4
;
int
size_batch
=
size_ch
*
C
;
int
size_batch
=
size_ch
*
C
;
clSetKernelArg
(
kernel
,
4
,
sizeof
(
int
),
&
size_ch
);
status
=
clSetKernelArg
(
kernel
,
4
,
sizeof
(
int
),
&
size_ch
);
clSetKernelArg
(
kernel
,
5
,
sizeof
(
int
),
&
size_block
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
6
,
sizeof
(
int
),
&
size_batch
);
status
=
clSetKernelArg
(
kernel
,
5
,
sizeof
(
int
),
&
size_block
);
clSetKernelArg
(
kernel
,
7
,
sizeof
(
int
),
&
C
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
6
,
sizeof
(
int
),
&
size_batch
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
7
,
sizeof
(
int
),
&
C
);
CL_CHECK_ERRORS
(
status
);
size_t
global_work_size
[
3
]
=
{(
new_dims
[
1
]
+
3
)
/
4
,
new_dims
[
3
],
size_t
global_work_size
[
3
]
=
{(
new_dims
[
1
]
+
3
)
/
4
,
new_dims
[
3
],
new_dims
[
0
]
*
new_dims
[
2
]};
new_dims
[
0
]
*
new_dims
[
2
]};
clEnqueueNDRangeKernel
(
commandQueue
,
kernel
,
3
,
NULL
,
global_work_size
,
NULL
,
status
=
clEnqueueNDRangeKernel
(
commandQueue
,
kernel
,
3
,
NULL
,
0
,
NULL
,
NULL
);
global_work_size
,
NULL
,
0
,
NULL
,
NULL
);
CL_CHECK_ERRORS
(
status
);
memcpy
(
tensor
->
data
<
float
>
(),
out_cl_tensor
.
Data
<
float
>
(),
memcpy
(
tensor
->
data
<
float
>
(),
out_cl_tensor
.
Data
<
float
>
(),
tensor
->
memory_size
());
tensor
->
memory_size
());
}
}
...
...
mobile/src/operators/kernel/cl/batchnorm_kernel.cpp
浏览文件 @
462f4649
...
@@ -87,18 +87,20 @@ void BatchNormKernel<GPU_CL, float>::Compute(
...
@@ -87,18 +87,20 @@ void BatchNormKernel<GPU_CL, float>::Compute(
DLOG
<<
out_width
;
DLOG
<<
out_width
;
DLOG
<<
*
param
.
OutputY
();
DLOG
<<
*
param
.
OutputY
();
cl_int
status
;
cl_int
status
;
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_int
),
&
out_width
);
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_int
),
&
out_width
);
CL_CHECK_ERRORS
(
status
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_mem
),
&
input
);
status
=
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_mem
),
&
input
);
CL_CHECK_ERRORS
(
status
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
2
,
sizeof
(
cl_mem
),
&
new_scale
);
status
=
clSetKernelArg
(
kernel
,
2
,
sizeof
(
cl_mem
),
&
new_scale
);
CL_CHECK_ERRORS
(
status
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
3
,
sizeof
(
cl_mem
),
&
new_bias
);
status
=
clSetKernelArg
(
kernel
,
3
,
sizeof
(
cl_mem
),
&
new_bias
);
CL_CHECK_ERRORS
(
status
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
4
,
sizeof
(
cl_mem
),
&
out
);
status
=
clSetKernelArg
(
kernel
,
4
,
sizeof
(
cl_mem
),
&
out
);
CL_CHECK_ERRORS
(
status
);
status
=
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
3
,
NULL
,
default_work_size
.
data
(),
NULL
,
0
,
NULL
,
NULL
);
CL_CHECK_ERRORS
(
status
);
CL_CHECK_ERRORS
(
status
);
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
3
,
NULL
,
default_work_size
.
data
(),
NULL
,
0
,
NULL
,
NULL
);
}
}
template
class
BatchNormKernel
<
GPU_CL
,
float
>;
template
class
BatchNormKernel
<
GPU_CL
,
float
>;
...
...
mobile/src/operators/kernel/cl/fetch_kernel.cpp
浏览文件 @
462f4649
...
@@ -59,23 +59,31 @@ void FetchKernel<GPU_CL, float>::Compute(const FetchParam<GPU_CL> ¶m) {
...
@@ -59,23 +59,31 @@ void FetchKernel<GPU_CL, float>::Compute(const FetchParam<GPU_CL> ¶m) {
out_cl_tensor
.
Resize
(
out
->
dims
());
out_cl_tensor
.
Resize
(
out
->
dims
());
cl_mem
outBuffer
=
out_cl_tensor
.
mutable_data
<
float
>
();
cl_mem
outBuffer
=
out_cl_tensor
.
mutable_data
<
float
>
();
clSetKernelArg
(
kernel
,
0
,
sizeof
(
int
),
&
in_height
);
cl_int
status
;
clSetKernelArg
(
kernel
,
1
,
sizeof
(
int
),
&
in_width
);
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
int
),
&
in_height
);
clSetKernelArg
(
kernel
,
2
,
sizeof
(
cl_mem
),
&
input
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
3
,
sizeof
(
cl_mem
),
&
outBuffer
);
status
=
clSetKernelArg
(
kernel
,
1
,
sizeof
(
int
),
&
in_width
);
clSetKernelArg
(
kernel
,
4
,
sizeof
(
int
),
&
size_ch
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
5
,
sizeof
(
int
),
&
size_block
);
status
=
clSetKernelArg
(
kernel
,
2
,
sizeof
(
cl_mem
),
&
input
);
clSetKernelArg
(
kernel
,
6
,
sizeof
(
int
),
&
size_batch
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
7
,
sizeof
(
int
),
&
in_ch
);
status
=
clSetKernelArg
(
kernel
,
3
,
sizeof
(
cl_mem
),
&
outBuffer
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
4
,
sizeof
(
int
),
&
size_ch
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
5
,
sizeof
(
int
),
&
size_block
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
6
,
sizeof
(
int
),
&
size_batch
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
7
,
sizeof
(
int
),
&
in_ch
);
CL_CHECK_ERRORS
(
status
);
// cl_event wait_event = param.InpdutX()->GetClEvent();
// cl_event wait_event = param.InpdutX()->GetClEvent();
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
3
,
NULL
,
status
=
default_work_size
.
data
(),
NULL
,
0
,
NULL
,
NULL
);
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
3
,
NULL
,
default_work_size
.
data
(),
NULL
,
0
,
NULL
,
NULL
);
CL_CHECK_ERRORS
(
status
);
// printf(" before finish \n");
// clFlsh(this->cl_helper_.CLCommandQueue());
clFinish
(
this
->
cl_helper_
.
CLCommandQueue
());
clFinish
(
this
->
cl_helper_
.
CLCommandQueue
());
// printf(" after finish \n");
DLOG
<<
"fetch kernel out dims = "
<<
out
->
dims
();
DLOG
<<
"fetch kernel out dims = "
<<
out
->
dims
();
DLOG
<<
"fetch kernel out memory size = "
<<
out
->
memory_size
();
DLOG
<<
"fetch kernel out memory size = "
<<
out
->
memory_size
();
...
...
mobile/src/operators/kernel/cl/instancenorm_kernel.cpp
浏览文件 @
462f4649
...
@@ -76,24 +76,26 @@ void InstanceNormKernel<GPU_CL, float>::Compute(
...
@@ -76,24 +76,26 @@ void InstanceNormKernel<GPU_CL, float>::Compute(
<<
" "
<<
local_work_size
[
2
];
<<
" "
<<
local_work_size
[
2
];
cl_int
status
;
cl_int
status
;
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_int
),
&
w
);
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_int
),
&
w
);
CL_CHECK_ERRORS
(
status
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_int
),
&
h
);
status
=
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_int
),
&
h
);
CL_CHECK_ERRORS
(
status
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
2
,
sizeof
(
cl_int
),
&
c_group
);
status
=
clSetKernelArg
(
kernel
,
2
,
sizeof
(
cl_int
),
&
c_group
);
CL_CHECK_ERRORS
(
status
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
3
,
sizeof
(
cl_int
),
&
local_work_size1
);
status
=
clSetKernelArg
(
kernel
,
3
,
sizeof
(
cl_int
),
&
local_work_size1
);
CL_CHECK_ERRORS
(
status
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
4
,
sizeof
(
cl_int
),
&
local_work_size2
);
status
=
clSetKernelArg
(
kernel
,
4
,
sizeof
(
cl_int
),
&
local_work_size2
);
CL_CHECK_ERRORS
(
status
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
5
,
sizeof
(
cl_float
),
&
epsilon
);
status
=
clSetKernelArg
(
kernel
,
5
,
sizeof
(
cl_float
),
&
epsilon
);
CL_CHECK_ERRORS
(
status
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
6
,
sizeof
(
cl_mem
),
&
input
);
status
=
clSetKernelArg
(
kernel
,
6
,
sizeof
(
cl_mem
),
&
input
);
CL_CHECK_ERRORS
(
status
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
7
,
sizeof
(
cl_mem
),
&
out
);
status
=
clSetKernelArg
(
kernel
,
7
,
sizeof
(
cl_mem
),
&
out
);
CL_CHECK_ERRORS
(
status
);
status
=
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
3
,
NULL
,
work_size
,
local_work_size
,
0
,
NULL
,
NULL
);
CL_CHECK_ERRORS
(
status
);
CL_CHECK_ERRORS
(
status
);
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
3
,
NULL
,
work_size
,
local_work_size
,
0
,
NULL
,
NULL
);
}
}
template
class
InstanceNormKernel
<
GPU_CL
,
float
>;
template
class
InstanceNormKernel
<
GPU_CL
,
float
>;
...
...
mobile/src/operators/kernel/cl/pool_kernel.cpp
浏览文件 @
462f4649
...
@@ -57,23 +57,38 @@ void PoolKernel<GPU_CL, float>::Compute(const PoolParam<GPU_CL> ¶m) {
...
@@ -57,23 +57,38 @@ void PoolKernel<GPU_CL, float>::Compute(const PoolParam<GPU_CL> ¶m) {
const
int
ksize_h
=
ksize
[
0
];
const
int
ksize_h
=
ksize
[
0
];
const
int
ksize_w
=
ksize
[
1
];
const
int
ksize_w
=
ksize
[
1
];
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_int
),
&
in_height
);
cl_int
status
;
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_int
),
&
in_width
);
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_int
),
&
in_height
);
clSetKernelArg
(
kernel
,
2
,
sizeof
(
cl_int
),
&
out_height
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
3
,
sizeof
(
cl_int
),
&
out_width
);
status
=
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_int
),
&
in_width
);
clSetKernelArg
(
kernel
,
4
,
sizeof
(
cl_int
),
&
pad_top
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
5
,
sizeof
(
cl_int
),
&
pad_left
);
status
=
clSetKernelArg
(
kernel
,
2
,
sizeof
(
cl_int
),
&
out_height
);
clSetKernelArg
(
kernel
,
6
,
sizeof
(
cl_int
),
&
stride_h
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
7
,
sizeof
(
cl_int
),
&
stride_w
);
status
=
clSetKernelArg
(
kernel
,
3
,
sizeof
(
cl_int
),
&
out_width
);
clSetKernelArg
(
kernel
,
8
,
sizeof
(
cl_int
),
&
ksize_h
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
9
,
sizeof
(
cl_int
),
&
ksize_w
);
status
=
clSetKernelArg
(
kernel
,
4
,
sizeof
(
cl_int
),
&
pad_top
);
clSetKernelArg
(
kernel
,
10
,
sizeof
(
cl_mem
),
&
input
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
11
,
sizeof
(
cl_mem
),
&
out
);
status
=
clSetKernelArg
(
kernel
,
5
,
sizeof
(
cl_int
),
&
pad_left
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
6
,
sizeof
(
cl_int
),
&
stride_h
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
7
,
sizeof
(
cl_int
),
&
stride_w
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
8
,
sizeof
(
cl_int
),
&
ksize_h
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
9
,
sizeof
(
cl_int
),
&
ksize_w
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
10
,
sizeof
(
cl_mem
),
&
input
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
11
,
sizeof
(
cl_mem
),
&
out
);
CL_CHECK_ERRORS
(
status
);
// cl_event out_event = param.Output()->GetClEvent();
// cl_event out_event = param.Output()->GetClEvent();
// cl_event wait_event = param.Input()->GetClEvent();
// cl_event wait_event = param.Input()->GetClEvent();
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
3
,
NULL
,
status
=
default_work_size
.
data
(),
NULL
,
0
,
NULL
,
NULL
);
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
3
,
NULL
,
default_work_size
.
data
(),
NULL
,
0
,
NULL
,
NULL
);
CL_CHECK_ERRORS
(
status
);
}
}
template
class
PoolKernel
<
GPU_CL
,
float
>;
template
class
PoolKernel
<
GPU_CL
,
float
>;
...
...
mobile/src/operators/kernel/cl/relu_kernel.cpp
浏览文件 @
462f4649
...
@@ -43,8 +43,11 @@ void ReluKernel<GPU_CL, float>::Compute(const ReluParam<GPU_CL>& param) {
...
@@ -43,8 +43,11 @@ void ReluKernel<GPU_CL, float>::Compute(const ReluParam<GPU_CL>& param) {
auto
outputImage
=
output
->
GetCLImage
();
auto
outputImage
=
output
->
GetCLImage
();
// auto tImage =
// auto tImage =
// const_cast<ReluParam<GPU_CL>&>(param).getMidImage().GetCLImage();
// const_cast<ReluParam<GPU_CL>&>(param).getMidImage().GetCLImage();
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
inputImage
);
cl_int
status
;
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_mem
),
&
outputImage
);
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
inputImage
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_mem
),
&
outputImage
);
CL_CHECK_ERRORS
(
status
);
// clSetKernelArg(kernel_p0, 0, sizeof(cl_mem), &inputImage);
// clSetKernelArg(kernel_p0, 0, sizeof(cl_mem), &inputImage);
// clSetKernelArg(kernel_p0, 0, sizeof(cl_mem), &tImage);
// clSetKernelArg(kernel_p0, 0, sizeof(cl_mem), &tImage);
// clSetKernelArg(kernel_p1, 0, sizeof(cl_mem), &tImage);
// clSetKernelArg(kernel_p1, 0, sizeof(cl_mem), &tImage);
...
@@ -54,8 +57,9 @@ void ReluKernel<GPU_CL, float>::Compute(const ReluParam<GPU_CL>& param) {
...
@@ -54,8 +57,9 @@ void ReluKernel<GPU_CL, float>::Compute(const ReluParam<GPU_CL>& param) {
// cl_event out_event = param.Out()->GetClEvent();
// cl_event out_event = param.Out()->GetClEvent();
// cl_event wait_event = param.InputX()->GetClEvent();
// cl_event wait_event = param.InputX()->GetClEvent();
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
2
,
NULL
,
status
=
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
2
,
work_size
,
NULL
,
0
,
NULL
,
NULL
);
NULL
,
work_size
,
NULL
,
0
,
NULL
,
NULL
);
CL_CHECK_ERRORS
(
status
);
// clEnqueueNDRangeKernel(this->cl_helper_.CLCommandQueue(), kernel_p1, 3,
// clEnqueueNDRangeKernel(this->cl_helper_.CLCommandQueue(), kernel_p1, 3,
// NULL,
// NULL,
// work_size, NULL, 0, NULL, NULL);
// work_size, NULL, 0, NULL, NULL);
...
...
mobile/src/operators/kernel/cl/scale_kernel.cpp
浏览文件 @
462f4649
...
@@ -36,14 +36,22 @@ void ScaleKernel<GPU_CL, float>::Compute(const ScaleParam<GPU_CL>& param) {
...
@@ -36,14 +36,22 @@ void ScaleKernel<GPU_CL, float>::Compute(const ScaleParam<GPU_CL>& param) {
auto
inputImage
=
input
->
GetCLImage
();
auto
inputImage
=
input
->
GetCLImage
();
auto
outputImage
=
output
->
GetCLImage
();
auto
outputImage
=
output
->
GetCLImage
();
int
out_width
=
(
output
->
dims
().
size
()
==
4
)
?
output
->
dims
()[
3
]
:
1
;
int
out_width
=
(
output
->
dims
().
size
()
==
4
)
?
output
->
dims
()[
3
]
:
1
;
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
inputImage
);
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_mem
),
&
outputImage
);
cl_int
status
;
clSetKernelArg
(
kernel
,
2
,
sizeof
(
float
),
&
scale
);
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
inputImage
);
clSetKernelArg
(
kernel
,
3
,
sizeof
(
float
),
&
bias
);
CL_CHECK_ERRORS
(
status
);
clSetKernelArg
(
kernel
,
4
,
sizeof
(
int
),
&
out_width
);
status
=
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_mem
),
&
outputImage
);
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
CL_CHECK_ERRORS
(
status
);
default_work_size
.
size
(),
NULL
,
status
=
clSetKernelArg
(
kernel
,
2
,
sizeof
(
float
),
&
scale
);
default_work_size
.
data
(),
NULL
,
0
,
NULL
,
NULL
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
3
,
sizeof
(
float
),
&
bias
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
4
,
sizeof
(
int
),
&
out_width
);
CL_CHECK_ERRORS
(
status
);
status
=
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
default_work_size
.
size
(),
NULL
,
default_work_size
.
data
(),
NULL
,
0
,
NULL
,
NULL
);
CL_CHECK_ERRORS
(
status
);
}
}
template
class
ScaleKernel
<
GPU_CL
,
float
>;
template
class
ScaleKernel
<
GPU_CL
,
float
>;
...
...
mobile/src/operators/kernel/cl/tanh_kernel.cpp
浏览文件 @
462f4649
...
@@ -32,12 +32,16 @@ void TanhKernel<GPU_CL, float>::Compute(const TanhParam<GPU_CL>& param) {
...
@@ -32,12 +32,16 @@ void TanhKernel<GPU_CL, float>::Compute(const TanhParam<GPU_CL>& param) {
auto
default_work_size
=
this
->
cl_helper_
.
DefaultWorkSize
(
*
output
);
auto
default_work_size
=
this
->
cl_helper_
.
DefaultWorkSize
(
*
output
);
auto
inputImage
=
input
->
GetCLImage
();
auto
inputImage
=
input
->
GetCLImage
();
auto
outputImage
=
output
->
GetCLImage
();
auto
outputImage
=
output
->
GetCLImage
();
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
inputImage
);
cl_int
status
;
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_mem
),
&
outputImage
);
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
inputImage
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_mem
),
&
outputImage
);
CL_CHECK_ERRORS
(
status
);
const
size_t
work_size
[
2
]
=
{
input
->
ImageWidth
(),
input
->
ImageHeight
()};
const
size_t
work_size
[
2
]
=
{
input
->
ImageWidth
(),
input
->
ImageHeight
()};
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
2
,
NULL
,
status
=
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
2
,
work_size
,
NULL
,
0
,
NULL
,
NULL
);
NULL
,
work_size
,
NULL
,
0
,
NULL
,
NULL
);
CL_CHECK_ERRORS
(
status
);
}
}
template
class
TanhKernel
<
GPU_CL
,
float
>;
template
class
TanhKernel
<
GPU_CL
,
float
>;
...
...
mobile/tools/python/fluidtools/run.py
浏览文件 @
462f4649
...
@@ -482,73 +482,74 @@ def check_mobile_results(args, fuse, mem_opt):
...
@@ -482,73 +482,74 @@ def check_mobile_results(args, fuse, mem_opt):
pp_red
(
str
(
error_values1
).
replace
(
"
\n
"
,
"
\n
"
+
"
\t
"
*
1
),
1
)
pp_red
(
str
(
error_values1
).
replace
(
"
\n
"
,
"
\n
"
+
"
\t
"
*
1
),
1
)
pp_yellow
(
"paddle mobile results are : "
,
1
)
pp_yellow
(
"paddle mobile results are : "
,
1
)
pp_red
(
str
(
error_values2
).
replace
(
"
\n
"
,
"
\n
"
+
"
\t
"
*
1
),
1
)
pp_red
(
str
(
error_values2
).
replace
(
"
\n
"
,
"
\n
"
+
"
\t
"
*
1
),
1
)
if
not
fuse
and
not
mem_opt
:
if
not
fuse
and
not
mem_opt
:
error_index
=
None
pp_yellow
(
"checking individual ops : "
,
1
)
error_values1
=
None
error_index
=
None
error_values2
=
None
error_values1
=
None
checked_names
=
[]
error_values2
=
None
fetch_names
=
[]
checked_names
=
[]
for
fetch
in
fetches
:
fetch_names
=
[]
fetch_names
.
append
(
fetch
.
name
)
for
fetch
in
fetches
:
for
index
in
op_cache
:
fetch_names
.
append
(
fetch
.
name
)
op_output_var_name
,
op
=
op_cache
[
index
]
for
index
in
op_cache
:
if
mem_opt
:
op_output_var_name
,
op
=
op_cache
[
index
]
found_in_fetch
=
False
if
mem_opt
:
for
fetch
in
fetches
:
found_in_fetch
=
False
if
op_output_var_name
==
fetch
.
name
:
for
fetch
in
fetches
:
found_in_fetch
=
True
if
op_output_var_name
==
fetch
.
name
:
break
found_in_fetch
=
True
if
not
found_in_fetch
:
break
if
not
found_in_fetch
:
continue
if
not
op_output_var_name
in
output_var_cache
:
continue
continue
if
not
op_output_var_name
in
output_var_cache
:
if
not
op_output_var_name
in
mobile_var_cache
:
continue
if
not
op_output_var_name
in
mobile_var_cache
:
continue
if
fuse
or
mem_opt
:
if
op_output_var_name
not
in
fetch_names
:
continue
continue
values1
=
output_var_cache
[
op_output_var_name
]
if
fuse
or
mem_opt
:
values2
=
mobile_var_cache
[
op_output_var_name
]
if
op_output_var_name
not
in
fetch_names
:
shape
=
get_var_shape
(
op_output_var_name
)
if
check_shape
else
[]
continue
if
len
(
values1
)
+
len
(
shape
)
!=
len
(
values2
):
values1
=
output_var_cache
[
op_output_var_name
]
error_index
=
index
values2
=
mobile_var_cache
[
op_output_var_name
]
for
i
in
range
(
len
(
shape
)):
shape
=
get_var_shape
(
op_output_var_name
)
if
check_shape
else
[]
v1
=
shape
[
i
]
if
len
(
values1
)
+
len
(
shape
)
!=
len
(
values2
):
v2
=
values2
[
i
]
if
v1
!=
v2
:
error_index
=
index
error_index
=
index
break
for
i
in
range
(
len
(
shape
)):
if
error_index
==
None
:
v1
=
shape
[
i
]
for
i
in
range
(
len
(
values1
)):
v2
=
values2
[
i
]
v1
=
values1
[
i
]
if
v1
!=
v2
:
v2
=
values2
[
len
(
shape
)
+
i
]
if
abs
(
v1
-
v2
)
>
diff_threshold
:
error_index
=
index
error_index
=
index
break
break
checked_names
.
append
(
op_output_var_name
)
if
error_index
==
None
:
if
error_index
!=
None
:
for
i
in
range
(
len
(
values1
)):
error_values1
=
values1
v1
=
values1
[
i
]
error_values2
=
values2
v2
=
values2
[
len
(
shape
)
+
i
]
break
if
abs
(
v1
-
v2
)
>
diff_threshold
:
if
error_index
==
None
:
error_index
=
index
for
name
in
fetch_names
:
break
if
name
not
in
checked_names
:
checked_names
.
append
(
op_output_var_name
)
error_index
=
-
1
if
error_index
!=
None
:
error_values1
=
values1
error_values2
=
values2
break
break
if
error_index
==
None
:
if
error_index
==
None
:
pp_green
(
"outputs are all correct"
,
1
)
for
name
in
fetch_names
:
elif
error_index
==
-
1
:
if
name
not
in
checked_names
:
pp_red
(
"outputs are missing"
)
error_index
=
-
1
else
:
break
error_values1
=
np
.
array
(
error_values1
)
if
error_index
==
None
:
error_values2
=
np
.
array
(
error_values2
)
pp_green
(
"outputs are all correct"
,
1
)
# pp_red("mobile op is not correct, error occurs at {}th op, op's type is {}")
elif
error_index
==
-
1
:
pp_red
(
"corresponding fluid op is {}th op, op's type is {}, wrong var name is {}"
.
format
(
pp_red
(
"outputs are missing"
)
error_index
,
op_cache
[
error_index
][
1
].
type
,
op_output_var_name
),
1
)
else
:
pp_red
(
"fluid results are : "
,
1
)
error_values1
=
np
.
array
(
error_values1
)
pp_red
(
str
(
error_values1
).
replace
(
"
\n
"
,
"
\n
"
+
"
\t
"
*
1
),
1
)
error_values2
=
np
.
array
(
error_values2
)
pp_yellow
(
"paddle mobile results are : "
,
1
)
# pp_red("mobile op is not correct, error occurs at {}th op, op's type is {}")
pp_red
(
str
(
error_values2
).
replace
(
"
\n
"
,
"
\n
"
+
"
\t
"
*
1
),
1
)
pp_red
(
"corresponding fluid op is {}th op, op's type is {}, wrong var name is {}"
.
format
(
error_index
,
op_cache
[
error_index
][
1
].
type
,
op_output_var_name
),
1
)
pp_red
(
"fluid results are : "
,
1
)
pp_red
(
str
(
error_values1
).
replace
(
"
\n
"
,
"
\n
"
+
"
\t
"
*
1
),
1
)
pp_yellow
(
"paddle mobile results are : "
,
1
)
pp_red
(
str
(
error_values2
).
replace
(
"
\n
"
,
"
\n
"
+
"
\t
"
*
1
),
1
)
# print(output_var_cache)
# print(output_var_cache)
# print(mobile_var_cache)
# print(mobile_var_cache)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录