Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
1794dae4
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,发现更多精彩内容 >>
提交
1794dae4
编写于
5月 03, 2018
作者:
L
liuqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add more strategy for convolution opencl default lws.
上级
cf5cae14
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
17 addition
and
16 deletion
+17
-16
mace/kernels/opencl/concat.cc
mace/kernels/opencl/concat.cc
+2
-2
mace/kernels/opencl/conv_2d_1x1.cc
mace/kernels/opencl/conv_2d_1x1.cc
+6
-2
mace/kernels/opencl/conv_2d_3x3.cc
mace/kernels/opencl/conv_2d_3x3.cc
+1
-2
mace/kernels/opencl/conv_2d_general.cc
mace/kernels/opencl/conv_2d_general.cc
+1
-1
mace/kernels/opencl/depthwise_conv.cc
mace/kernels/opencl/depthwise_conv.cc
+1
-1
mace/kernels/opencl/helper.cc
mace/kernels/opencl/helper.cc
+0
-1
mace/kernels/opencl/helper.h
mace/kernels/opencl/helper.h
+0
-1
mace/kernels/opencl/matmul.cc
mace/kernels/opencl/matmul.cc
+1
-1
mace/kernels/opencl/pooling.cc
mace/kernels/opencl/pooling.cc
+1
-1
mace/kernels/opencl/resize_bilinear.cc
mace/kernels/opencl/resize_bilinear.cc
+1
-1
mace/kernels/opencl/softmax.cc
mace/kernels/opencl/softmax.cc
+1
-1
mace/kernels/opencl/winograd_transform.cc
mace/kernels/opencl/winograd_transform.cc
+2
-2
未找到文件。
mace/kernels/opencl/concat.cc
浏览文件 @
1794dae4
...
...
@@ -25,7 +25,7 @@ namespace {
std
::
vector
<
uint32_t
>
LocalWS
(
const
uint32_t
*
gws
,
const
uint32_t
kwg_size
)
{
std
::
vector
<
uint32_t
>
lws
(
4
,
0
);
uint64_t
cache_size
=
uint64_t
cache_size
=
OpenCLRuntime
::
Global
()
->
device_global_mem_cache_size
();
uint32_t
base
=
cache_size
/
kBaseGPUMemCacheSize
;
lws
[
1
]
=
std
::
min
<
uint32_t
>
(
gws
[
1
],
kwg_size
);
...
...
@@ -114,7 +114,7 @@ static void Concat2(cl::Kernel *kernel,
const
std
::
vector
<
uint32_t
>
lws
=
LocalWS
(
gws
,
*
kwg_size
);
std
::
string
tuning_key
=
Concat
(
"concat_opencl_kernel"
,
output
->
dim
(
0
),
Concat
(
"concat_opencl_kernel"
,
output
->
dim
(
0
),
output
->
dim
(
1
),
output
->
dim
(
2
),
output
->
dim
(
3
));
TuningOrRun3DKernel
(
*
kernel
,
tuning_key
,
gws
,
lws
,
future
);
...
...
mace/kernels/opencl/conv_2d_1x1.cc
浏览文件 @
1794dae4
...
...
@@ -23,16 +23,20 @@ namespace kernels {
namespace
{
// (inputs + weights + outputs) * array_size * sizeof(float)
const
uint32_t
kernel_cache_size
=
(
4
+
4
+
4
)
*
4
*
4
;
// TODO(liuqi): Fix the specific value.
const
uint32_t
lws_limit
=
128
;
std
::
vector
<
uint32_t
>
LocalWS
(
const
uint32_t
*
gws
,
const
uint32_t
kwg_size
)
{
std
::
vector
<
uint32_t
>
lws
(
4
,
0
);
uint64_t
cache_size
=
uint64_t
cache_size
=
OpenCLRuntime
::
Global
()
->
device_global_mem_cache_size
();
uint32_t
compute_units
=
OpenCLRuntime
::
Global
()
->
device_compute_units
();
uint32_t
base
=
cache_size
/
kBaseGPUMemCacheSize
;
lws
[
1
]
=
std
::
min
<
uint32_t
>
(
gws
[
1
],
kwg_size
);
if
(
lws
[
1
]
>=
base
)
{
lws
[
0
]
=
std
::
min
<
uint32_t
>
(
gws
[
0
],
base
);
}
else
if
((
1
<
lws
[
1
]
&&
lws
[
1
]
<
base
)
&&
gws
[
0
]
>=
lws_limit
)
{
lws
[
0
]
=
std
::
min
<
uint32_t
>
(
gws
[
0
],
base
);
}
else
{
lws
[
0
]
=
gws
[
0
]
/
8
;
if
(
lws
[
0
]
<
base
)
{
...
...
@@ -165,7 +169,7 @@ extern void Conv2dOpenclK1x1(cl::Kernel *kernel,
std
::
vector
<
uint32_t
>
lws
=
LocalWS
(
gws
,
*
kwg_size
);
std
::
string
tuning_key
=
Concat
(
"conv2d_1x1_opencl_kernel"
,
output
->
dim
(
0
),
Concat
(
"conv2d_1x1_opencl_kernel"
,
output
->
dim
(
0
),
output
->
dim
(
1
),
output
->
dim
(
2
),
output
->
dim
(
3
));
TuningOrRun3DKernel
(
*
kernel
,
tuning_key
,
gws
,
lws
,
future
);
...
...
mace/kernels/opencl/conv_2d_3x3.cc
浏览文件 @
1794dae4
...
...
@@ -21,7 +21,6 @@
namespace
mace
{
namespace
kernels
{
namespace
{
// (inputs + weights + outputs) * array_size * sizeof(float)
const
uint32_t
kernel_cache_size
=
(
5
+
4
+
5
)
*
4
*
4
;
...
...
@@ -157,7 +156,7 @@ extern void Conv2dOpenclK3x3(cl::Kernel *kernel,
*
prev_input_shape
=
input
->
shape
();
}
const
std
::
vector
<
uint32_t
>
lws
=
LocalWS
(
gws
,
*
kwg_size
);
std
::
vector
<
uint32_t
>
lws
=
LocalWS
(
gws
,
*
kwg_size
);
std
::
string
tuning_key
=
Concat
(
"conv2d_3x3_opencl_kernel"
,
output
->
dim
(
0
),
output
->
dim
(
1
),
output
->
dim
(
2
),
output
->
dim
(
3
));
...
...
mace/kernels/opencl/conv_2d_general.cc
浏览文件 @
1794dae4
...
...
@@ -168,7 +168,7 @@ extern void Conv2dOpencl(cl::Kernel *kernel,
std
::
string
tuning_key
=
Concat
(
"conv2d_general_opencl_kernel"
,
output
->
dim
(
0
),
output
->
dim
(
1
),
output
->
dim
(
2
),
output
->
dim
(
3
),
output
->
dim
(
1
),
output
->
dim
(
2
),
output
->
dim
(
3
),
filter
->
dim
(
0
),
filter
->
dim
(
1
));
std
::
vector
<
uint32_t
>
lws
=
LocalWS
(
gws
,
filter
->
dim
(
0
)
*
filter
->
dim
(
1
),
*
kwg_size
);
...
...
mace/kernels/opencl/depthwise_conv.cc
浏览文件 @
1794dae4
...
...
@@ -32,7 +32,7 @@ std::vector<uint32_t> LocalWS(const uint32_t *gws,
lws
[
1
]
=
std
::
min
<
uint32_t
>
(
gws
[
1
],
kwg_size
);
if
(
lws
[
1
]
>=
min_lws0
)
{
lws
[
0
]
=
std
::
min
<
uint32_t
>
(
gws
[
0
],
min_lws0
);
}
else
{
}
else
{
lws
[
0
]
=
std
::
min
<
uint32_t
>
(
gws
[
0
]
/
8
,
kwg_size
/
lws
[
1
]);
if
(
lws
[
0
]
<
min_lws0
)
{
lws
[
0
]
=
std
::
min
<
uint32_t
>
(
std
::
max
<
uint32_t
>
(
gws
[
0
]
/
4
,
min_lws0
),
...
...
mace/kernels/opencl/helper.cc
浏览文件 @
1794dae4
...
...
@@ -215,7 +215,6 @@ std::vector<uint32_t> Default2DLocalWS(const uint32_t *gws,
lws
[
0
]
=
std
::
min
<
uint32_t
>
(
base
,
kwg_size
);
lws
[
1
]
=
kwg_size
/
lws
[
1
];
return
lws
;
}
std
::
vector
<
uint32_t
>
Default3DLocalWS
(
const
uint32_t
*
gws
,
...
...
mace/kernels/opencl/helper.h
浏览文件 @
1794dae4
...
...
@@ -118,7 +118,6 @@ std::vector<uint32_t> Default2DLocalWS(const uint32_t *gws,
const
uint32_t
kwg_size
);
std
::
vector
<
uint32_t
>
Default3DLocalWS
(
const
uint32_t
*
gws
,
const
uint32_t
kwg_size
);
}
// namespace kernels
}
// namespace mace
#endif // MACE_KERNELS_OPENCL_HELPER_H_
mace/kernels/opencl/matmul.cc
浏览文件 @
1794dae4
...
...
@@ -86,7 +86,7 @@ void MatMulFunctor<DeviceType::GPU, T>::operator()(const Tensor *A,
const
std
::
vector
<
uint32_t
>
lws
=
{
kwg_size_
/
64
,
64
,
0
};
std
::
string
tuning_key
=
Concat
(
"matmul_opencl_kernel"
,
C
->
dim
(
0
),
Concat
(
"matmul_opencl_kernel"
,
C
->
dim
(
0
),
C
->
dim
(
1
),
C
->
dim
(
2
),
C
->
dim
(
3
));
TuningOrRun2DKernel
(
kernel_
,
tuning_key
,
gws
,
lws
,
future
);
...
...
mace/kernels/opencl/pooling.cc
浏览文件 @
1794dae4
...
...
@@ -158,7 +158,7 @@ void PoolingFunctor<DeviceType::GPU, T>::operator()(const Tensor *input,
const
std
::
vector
<
uint32_t
>
lws
=
LocalWS
(
gws
.
data
(),
kwg_size_
);
std
::
string
tuning_key
=
Concat
(
"pooling_opencl_kernel_"
,
output
->
dim
(
0
),
Concat
(
"pooling_opencl_kernel_"
,
output
->
dim
(
0
),
output
->
dim
(
1
),
output
->
dim
(
2
),
output
->
dim
(
3
));
TuningOrRun3DKernel
(
kernel_
,
tuning_key
,
gws
.
data
(),
lws
,
future
);
...
...
mace/kernels/opencl/resize_bilinear.cc
浏览文件 @
1794dae4
...
...
@@ -129,7 +129,7 @@ void ResizeBilinearFunctor<DeviceType::GPU, T>::operator()(
const
std
::
vector
<
uint32_t
>
lws
=
LocalWS
(
gws
,
kwg_size_
);
std
::
string
tuning_key
=
Concat
(
"resize_bilinear_opencl_kernel"
,
output
->
dim
(
0
),
Concat
(
"resize_bilinear_opencl_kernel"
,
output
->
dim
(
0
),
output
->
dim
(
1
),
output
->
dim
(
2
),
output
->
dim
(
3
));
TuningOrRun3DKernel
(
kernel_
,
tuning_key
,
gws
,
lws
,
future
);
...
...
mace/kernels/opencl/softmax.cc
浏览文件 @
1794dae4
...
...
@@ -104,7 +104,7 @@ void SoftmaxFunctor<DeviceType::GPU, T>::operator()(const Tensor *logits,
std
::
vector
<
uint32_t
>
lws
=
LocalWS
(
gws
,
kwg_size_
);
std
::
string
tuning_key
=
Concat
(
"softmax_opencl_kernel"
,
output
->
dim
(
0
),
Concat
(
"softmax_opencl_kernel"
,
output
->
dim
(
0
),
output
->
dim
(
1
),
output
->
dim
(
2
),
output
->
dim
(
3
));
TuningOrRun3DKernel
(
kernel_
,
tuning_key
,
gws
,
lws
,
future
);
...
...
mace/kernels/opencl/winograd_transform.cc
浏览文件 @
1794dae4
...
...
@@ -103,7 +103,7 @@ void WinogradTransformFunctor<DeviceType::GPU, T>::operator()(
const
std
::
vector
<
uint32_t
>
lws
=
{
kwg_size_
/
8
,
8
,
0
};
std
::
string
tuning_key
=
Concat
(
"winograd_transform_kernel"
,
output_tensor
->
dim
(
0
),
Concat
(
"winograd_transform_kernel"
,
output_tensor
->
dim
(
0
),
output_tensor
->
dim
(
1
),
output_tensor
->
dim
(
2
),
output_tensor
->
dim
(
3
));
TuningOrRun2DKernel
(
kernel_
,
tuning_key
,
gws
,
lws
,
future
);
...
...
@@ -217,7 +217,7 @@ void WinogradInverseTransformFunctor<DeviceType::GPU, T>::operator()(
const
std
::
vector
<
uint32_t
>
lws
=
{
kwg_size_
/
8
,
8
,
0
};
std
::
string
tuning_key
=
Concat
(
"winograd_inverse_transform_kernel"
,
output_tensor
->
dim
(
0
),
Concat
(
"winograd_inverse_transform_kernel"
,
output_tensor
->
dim
(
0
),
output_tensor
->
dim
(
1
),
output_tensor
->
dim
(
2
),
output_tensor
->
dim
(
3
),
input_tensor
->
dim
(
2
));
TuningOrRun2DKernel
(
kernel_
,
tuning_key
,
gws
,
lws
,
future
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录