Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
94e70a44
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看板
提交
94e70a44
编写于
10月 15, 2018
作者:
L
liuruilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update batch norm
上级
b41fcacc
变更
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
浏览文件 @
94e70a44
...
@@ -37,7 +37,7 @@ limitations under the License. */
...
@@ -37,7 +37,7 @@ limitations under the License. */
#include "framework/cl/cl_image.h"
#include "framework/cl/cl_image.h"
#endif
#endif
int
debug_to
=
2
;
int
debug_to
=
4
;
namespace
paddle_mobile
{
namespace
paddle_mobile
{
namespace
framework
{
namespace
framework
{
...
...
src/operators/kernel/cl/batchnorm_kernel.cpp
浏览文件 @
94e70a44
...
@@ -47,15 +47,20 @@ bool BatchNormKernel<GPU_CL, float>::Init(BatchNormParam<GPU_CL> *param) {
...
@@ -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
];
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
();
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
();
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
->
SetNewScale
(
new_scale
);
param
->
SetNewBias
(
new_bias
);
param
->
SetNewBias
(
new_bias
);
delete
[](
new_scale_ptr
);
delete
[](
new_bias_ptr
);
return
true
;
return
true
;
}
}
...
...
src/operators/kernel/cl/cl_kernel/batchnorm_kernel.cl
浏览文件 @
94e70a44
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
__kernel
void
batchnorm
(
__private
const
int
out_height,
__kernel
void
batchnorm
(
__private
const
int
out_height,
__private
const
int
out_width,
__private
const
int
out_width,
__read_only
image2d_t
input,
__read_only
image2d_t
input,
__read_only
image2d_t
new_scale,
__read_only
image2d_t
new_scale
_image
,
__read_only
image2d_t
new_bias,
__read_only
image2d_t
new_bias
_image
,
__write_only
image2d_t
output
)
{
__write_only
image2d_t
output
)
{
const
int
out_c
=
get_global_id
(
0
)
;
const
int
out_c
=
get_global_id
(
0
)
;
const
int
out_w
=
get_global_id
(
1
)
;
const
int
out_w
=
get_global_id
(
1
)
;
...
@@ -13,12 +13,12 @@ __kernel void batchnorm(__private const int out_height,
...
@@ -13,12 +13,12 @@ __kernel void batchnorm(__private const int out_height,
const
sampler_t
sampler
=
const
sampler_t
sampler
=
CLK_NORMALIZED_COORDS_TRUE
| CLK_ADDRESS_CLAMP |
CLK_FILTER_NEAREST
;
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_scale
=
read_imageh
(
new_scale_imag
e,
sampler,
(
int2
)(
out_c,
0
))
;
half4
new_bias
=
read_imageh
(
bn_bias
,
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
)
;
int
pos_x
=
mad24
(
out_c,
out_width,
out_w
)
;
half4
in
=
read_imageh
(
input,
sampler,
(
int2
)(
pos_x,
out_nh
))
;
half4
in
=
read_imageh
(
input,
sampler,
(
int2
)(
pos_x,
out_nh
))
;
half4
out
=
mad
(
in,
new_scale,
new_bias
)
;
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
浏览文件 @
94e70a44
...
@@ -61,7 +61,7 @@ void FeedKernel<GPU_CL, float>::Compute(const FeedParam<GPU_CL> ¶m) {
...
@@ -61,7 +61,7 @@ void FeedKernel<GPU_CL, float>::Compute(const FeedParam<GPU_CL> ¶m) {
size_t
region
[
3
]
=
{
height
,
width
,
1
};
size_t
region
[
3
]
=
{
height
,
width
,
1
};
clEnqueueReadImage
(
commandQueue
,
cl_image
,
CL_TRUE
,
origin
,
region
,
0
,
0
,
out
,
clEnqueueReadImage
(
commandQueue
,
cl_image
,
CL_TRUE
,
origin
,
region
,
0
,
0
,
out
,
0
,
NULL
,
NULL
);
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
>;
template
class
FeedKernel
<
GPU_CL
,
float
>;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录