Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
408407f4
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看板
提交
408407f4
编写于
10月 15, 2018
作者:
R
Ray Liu
提交者:
GitHub
10月 15, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1090 from codeWorm2015/opencl
update batch norm
上级
60c7e84b
94e70a44
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
15 addition
and
10 deletion
+15
-10
src/framework/executor.cpp
src/framework/executor.cpp
+1
-1
src/operators/kernel/cl/batchnorm_kernel.cpp
src/operators/kernel/cl/batchnorm_kernel.cpp
+8
-3
src/operators/kernel/cl/cl_kernel/batchnorm_kernel.cl
src/operators/kernel/cl/cl_kernel/batchnorm_kernel.cl
+5
-5
src/operators/kernel/cl/feed_kernel.cpp
src/operators/kernel/cl/feed_kernel.cpp
+1
-1
未找到文件。
src/framework/executor.cpp
浏览文件 @
408407f4
...
...
@@ -37,7 +37,7 @@ limitations under the License. */
#include "framework/cl/cl_image.h"
#endif
int
debug_to
=
2
;
int
debug_to
=
4
;
namespace
paddle_mobile
{
namespace
framework
{
...
...
src/operators/kernel/cl/batchnorm_kernel.cpp
浏览文件 @
408407f4
...
...
@@ -47,15 +47,20 @@ bool BatchNormKernel<GPU_CL, float>::Init(BatchNormParam<GPU_CL> *param) {
new_bias_ptr
[
i
]
=
bias_ptr
[
i
]
-
mean_ptr
[
i
]
*
inv_std_ptr
[
i
]
*
scale_ptr
[
i
];
}
delete
[](
new_scale_ptr
);
delete
[](
new_bias_ptr
);
framework
::
CLImage
*
new_scale
=
new
framework
::
CLImage
();
new_scale
->
SetTensorData
(
new_scale_ptr
,
variance
->
dims
());
new_scale
->
InitCLImage
(
this
->
cl_helper_
.
CLContext
());
framework
::
CLImage
*
new_bias
=
new
framework
::
CLImage
();
new_bias
->
SetTensorData
(
new_bias_ptr
,
variance
->
dims
());
new_bias
->
InitCLImage
(
this
->
cl_helper_
.
CLContext
());
param
->
SetNewScale
(
new_scale
);
param
->
SetNewBias
(
new_bias
);
delete
[](
new_scale_ptr
);
delete
[](
new_bias_ptr
);
return
true
;
}
...
...
src/operators/kernel/cl/cl_kernel/batchnorm_kernel.cl
浏览文件 @
408407f4
...
...
@@ -3,8 +3,8 @@
__kernel
void
batchnorm
(
__private
const
int
out_height,
__private
const
int
out_width,
__read_only
image2d_t
input,
__read_only
image2d_t
new_scale,
__read_only
image2d_t
new_bias,
__read_only
image2d_t
new_scale
_image
,
__read_only
image2d_t
new_bias
_image
,
__write_only
image2d_t
output
)
{
const
int
out_c
=
get_global_id
(
0
)
;
const
int
out_w
=
get_global_id
(
1
)
;
...
...
@@ -13,12 +13,12 @@ __kernel void batchnorm(__private const int out_height,
const
sampler_t
sampler
=
CLK_NORMALIZED_COORDS_TRUE
| CLK_ADDRESS_CLAMP |
CLK_FILTER_NEAREST
;
half4
new_scale
=
read_imageh
(
bn_scal
e,
sampler,
(
int2
)(
out_c,
0
))
;
half4
new_bias
=
read_imageh
(
bn_bias
,
sampler,
(
int2
)(
out_c,
0
))
;
half4
new_scale
=
read_imageh
(
new_scale_imag
e,
sampler,
(
int2
)(
out_c,
0
))
;
half4
new_bias
=
read_imageh
(
new_bias_image
,
sampler,
(
int2
)(
out_c,
0
))
;
int
pos_x
=
mad24
(
out_c,
out_width,
out_w
)
;
half4
in
=
read_imageh
(
input,
sampler,
(
int2
)(
pos_x,
out_nh
))
;
half4
out
=
mad
(
in,
new_scale,
new_bias
)
;
write_imageh
(
output,
(
int2
)(
pos_x,
nh
)
,
out
)
;
write_imageh
(
output,
(
int2
)(
pos_x,
out_
nh
)
,
out
)
;
}
src/operators/kernel/cl/feed_kernel.cpp
浏览文件 @
408407f4
...
...
@@ -61,7 +61,7 @@ void FeedKernel<GPU_CL, float>::Compute(const FeedParam<GPU_CL> ¶m) {
size_t
region
[
3
]
=
{
height
,
width
,
1
};
clEnqueueReadImage
(
commandQueue
,
cl_image
,
CL_TRUE
,
origin
,
region
,
0
,
0
,
out
,
0
,
NULL
,
NULL
);
for
(
int
i
=
0
;
i
<
numel
;
i
++
)
DLOG
<<
Half2Float
(
out
[
i
]);
//
for (int i = 0; i < numel; i++) DLOG << Half2Float(out[i]);
}
template
class
FeedKernel
<
GPU_CL
,
float
>;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录