Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
4dd645b8
Mace
项目概览
Xiaomi
/
Mace
通知
106
Star
40
Fork
27
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Mace
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4dd645b8
编写于
10月 31, 2017
作者:
L
liuqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Vectorization batch norm opencl kernel.
上级
aeb4c35e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
13 addition
and
11 deletion
+13
-11
mace/kernels/opencl/cl/batch_norm.cl
mace/kernels/opencl/cl/batch_norm.cl
+5
-5
mace/utils/BUILD
mace/utils/BUILD
+1
-0
mace/utils/tuner.h
mace/utils/tuner.h
+5
-5
mace/utils/tuner_test.cc
mace/utils/tuner_test.cc
+2
-1
未找到文件。
mace/kernels/opencl/cl/batch_norm.cl
浏览文件 @
4dd645b8
...
...
@@ -22,12 +22,12 @@ void kernel batch_norm(global const float *input,
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
const
int
sampl
e_offset
=
(
batch
*
channels
+
channel
)
*
pixels
+
pixel_offset*4
;
const
float
*input_ptr
=
input
+
sampl
e_offset
;
float
*output_ptr
=
output
+
sampl
e_offset
;
const
int
imag
e_offset
=
(
batch
*
channels
+
channel
)
*
pixels
+
pixel_offset*4
;
const
float
*input_ptr
=
input
+
imag
e_offset
;
float
*output_ptr
=
output
+
imag
e_offset
;
const
int
end
=
(
batch
*
channels
+
channel
+
1
)
*
pixels
;
if
((
sampl
e_offset+4
)
>
end
)
{
for
(
int
i
=
sampl
e_offset
; i < end; ++i) {
if
((
imag
e_offset+4
)
>
end
)
{
for
(
int
i
=
imag
e_offset
; i < end; ++i) {
*output_ptr
=
new_scale[local_channel].x
*
*input_ptr
+
new_offset[local_channel].x
;
++input_ptr
;
++output_ptr
;
...
...
mace/utils/BUILD
浏览文件 @
4dd645b8
...
...
@@ -39,6 +39,7 @@ cc_library(
copts
=
[
"-std=c++11"
],
deps
=
[
"//mace/core"
,
"//mace/core:opencl_runtime"
,
],
)
...
...
mace/utils/tuner.h
浏览文件 @
4dd645b8
...
...
@@ -33,7 +33,7 @@ class Tuner {
const
std
::
function
<
std
::
vector
<
std
::
vector
<
param_type
>>
()
>
&
param_generator
,
const
std
::
function
<
RetType
(
const
std
::
vector
<
param_type
>
&
)
>
&
func
)
{
if
(
IsTuning
())
{
if
(
IsTuning
()
&&
param_generator
!=
nullptr
)
{
// tune
std
::
vector
<
param_type
>
opt_param
=
default_param
;
RetType
res
=
Tune
<
RetType
>
(
param_generator
,
func
,
opt_param
);
...
...
@@ -68,7 +68,7 @@ class Tuner {
}
inline
void
WriteRunParameters
()
{
VLOG
(
0
)
<<
path_
;
VLOG
(
1
)
<<
path_
;
if
(
path_
!=
nullptr
)
{
std
::
ofstream
ofs
(
path_
,
std
::
ios
::
binary
|
std
::
ios
::
out
);
if
(
ofs
.
is_open
())
{
...
...
@@ -78,14 +78,14 @@ class Tuner {
int32_t
key_size
=
kp
.
first
.
size
();
ofs
.
write
(
reinterpret_cast
<
char
*>
(
&
key_size
),
sizeof
(
key_size
));
ofs
.
write
(
kp
.
first
.
c_str
(),
key_size
);
VLOG
(
0
)
<<
kp
.
first
.
c_str
();
VLOG
(
1
)
<<
kp
.
first
.
c_str
();
auto
&
params
=
kp
.
second
;
int32_t
params_size
=
params
.
size
()
*
sizeof
(
param_type
);
ofs
.
write
(
reinterpret_cast
<
char
*>
(
&
params_size
),
sizeof
(
params_size
));
for
(
auto
&
param
:
params
)
{
ofs
.
write
(
reinterpret_cast
<
char
*>
(
&
param
),
sizeof
(
params_size
));
VLOG
(
0
)
<<
param
;
VLOG
(
1
)
<<
param
;
}
}
ofs
.
close
();
...
...
@@ -144,7 +144,7 @@ class Tuner {
}
template
<
typename
RetType
>
inline
RetType
Tune
(
std
::
function
<
std
::
vector
<
std
::
vector
<
param_type
>>
()
>
param_generator
,
inline
RetType
Tune
(
const
std
::
function
<
std
::
vector
<
std
::
vector
<
param_type
>>
()
>
&
param_generator
,
const
std
::
function
<
RetType
(
const
std
::
vector
<
param_type
>
&
)
>
&
func
,
std
::
vector
<
param_type
>
&
opt_params
)
{
RetType
res
;
...
...
mace/utils/tuner_test.cc
浏览文件 @
4dd645b8
...
...
@@ -13,7 +13,8 @@ class TunerTest: public ::testing::Test {
protected:
virtual
void
SetUp
()
{
remove
(
"/data/local/tmp/mace.config"
);
setenv
(
"MACE_RUN_PARAMTER_PATH"
,
"/data/local/tmp/mace.config"
,
1
);
setenv
(
"MACE_RUN_PARAMETER_PATH"
,
"/data/local/tmp/mace.config"
,
1
);
setenv
(
"MACE_TUNING"
,
"1"
,
1
);
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录