Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
项目经理老王
Mace
提交
1b4a95e7
Mace
项目概览
项目经理老王
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
1b4a95e7
编写于
6月 10, 2019
作者:
Y
yejianwu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add b2i and i2b benchmark
上级
be56d6a3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
148 addition
and
42 deletion
+148
-42
test/ccbenchmark/mace/ops/buffer_to_image_benchmark.cc
test/ccbenchmark/mace/ops/buffer_to_image_benchmark.cc
+148
-42
未找到文件。
test/ccbenchmark/mace/ops/buffer_to_image_benchmark.cc
浏览文件 @
1b4a95e7
...
...
@@ -14,8 +14,8 @@
#ifdef MACE_ENABLE_OPENCL
#include "mace/core/runtime/opencl/opencl_runtime.h"
#include "mace/benchmark_utils/test_benchmark.h"
#include "mace/core/runtime/opencl/opencl_runtime.h"
#include "mace/ops/opencl/buffer_transformer.h"
#include "mace/ops/ops_test_util.h"
...
...
@@ -25,29 +25,88 @@ namespace test {
namespace
{
template
<
DeviceType
D
,
typename
T
>
void
FilterBufferToImage
(
int
iters
,
int
out_channel
,
int
in_channel
,
int
height
,
int
width
)
{
void
FilterBufferToImage
(
int
iters
,
int
out_channel
,
int
in_channel
,
int
height
,
int
width
)
{
mace
::
testing
::
StopTiming
();
OpsTestNet
net
;
OpContext
context
(
net
.
ws
(),
OpTestContext
::
Get
()
->
GetDevice
(
DeviceType
::
GPU
));
// Add input data
net
.
AddRandomInput
<
D
,
T
>
(
"Input"
,
{
out_channel
,
in_channel
,
height
,
width
});
// Create output
Tensor
*
b2i_output
=
net
.
ws
()
->
CreateTensor
(
"B2IOutput"
,
context
.
device
()
->
allocator
(),
DataTypeToEnum
<
T
>::
value
);
auto
transform_func
=
[
&
]()
{
OpenCLBufferTransformer
(
MemoryType
::
GPU_BUFFER
,
MemoryType
::
GPU_IMAGE
)
.
Transform
(
&
context
,
net
.
ws
()
->
GetTensor
(
"Input"
),
OpenCLBufferType
::
CONV2D_FILTER
,
MemoryType
::
GPU_IMAGE
,
0
,
b2i_output
);
};
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
transform_func
();
}
net
.
Sync
();
mace
::
testing
::
StartTiming
();
while
(
iters
--
)
{
transform_func
();
}
net
.
Sync
();
}
}
// namespace
#define MACE_BM_FILTER_B2I_MACRO(O, I, H, W, TYPE, DEVICE) \
static void MACE_BM_FILTER_B2I_##O##_##I##_##H##_##W##_##TYPE##_##DEVICE( \
int iters) { \
const int64_t tot = static_cast<int64_t>(iters) * O * I * H * W; \
mace::testing::BytesProcessed(tot *(sizeof(TYPE))); \
FilterBufferToImage<DEVICE, TYPE>(iters, O, I, H, W); \
} \
MACE_BENCHMARK(MACE_BM_FILTER_B2I_##O##_##I##_##H##_##W##_##TYPE##_##DEVICE)
#define MACE_BM_FILTER_B2I(O, I, H, W) \
MACE_BM_FILTER_B2I_MACRO(O, I, H, W, float, GPU); \
MACE_BM_FILTER_B2I_MACRO(O, I, H, W, half, GPU);
MACE_BM_FILTER_B2I
(
5
,
3
,
3
,
3
);
MACE_BM_FILTER_B2I
(
5
,
3
,
7
,
7
);
MACE_BM_FILTER_B2I
(
32
,
16
,
1
,
1
);
MACE_BM_FILTER_B2I
(
32
,
16
,
3
,
3
);
MACE_BM_FILTER_B2I
(
32
,
16
,
5
,
5
);
MACE_BM_FILTER_B2I
(
32
,
16
,
7
,
7
);
MACE_BM_FILTER_B2I
(
64
,
32
,
1
,
1
);
MACE_BM_FILTER_B2I
(
64
,
32
,
3
,
3
);
MACE_BM_FILTER_B2I
(
64
,
32
,
5
,
5
);
MACE_BM_FILTER_B2I
(
64
,
32
,
7
,
7
);
MACE_BM_FILTER_B2I
(
128
,
64
,
1
,
1
);
MACE_BM_FILTER_B2I
(
128
,
64
,
3
,
3
);
MACE_BM_FILTER_B2I
(
128
,
32
,
1
,
1
);
MACE_BM_FILTER_B2I
(
128
,
32
,
3
,
3
);
MACE_BM_FILTER_B2I
(
256
,
32
,
1
,
1
);
MACE_BM_FILTER_B2I
(
256
,
32
,
3
,
3
);
namespace
{
template
<
DeviceType
D
,
typename
T
>
void
InOutBufferToImage
(
int
iters
,
int
batch
,
int
height
,
int
width
,
int
channel
)
{
mace
::
testing
::
StopTiming
();
OpsTestNet
net
;
OpContext
context
(
net
.
ws
(),
OpTestContext
::
Get
()
->
GetDevice
(
DeviceType
::
GPU
));
OpContext
context
(
net
.
ws
(),
OpTestContext
::
Get
()
->
GetDevice
(
DeviceType
::
GPU
));
// Add input data
net
.
AddRandomInput
<
D
,
T
>
(
"Input"
,
{
out_channel
,
in_channel
,
height
,
width
});
net
.
AddRandomInput
<
D
,
T
>
(
"Input"
,
{
batch
,
height
,
width
,
channel
});
// Create output
Tensor
*
b2i_output
=
net
.
ws
()
->
CreateTensor
(
"B2IOutput"
,
context
.
device
()
->
allocator
(),
DataTypeToEnum
<
T
>::
value
);
auto
transform_func
=
[
&
]()
{
OpenCLBufferTransformer
(
MemoryType
::
GPU_BUFFER
,
MemoryType
::
GPU_IMAGE
)
.
Transform
(
&
context
,
net
.
ws
()
->
GetTensor
(
"Input"
),
OpenCLBufferType
::
IN_OUT_CHANNEL
,
MemoryType
::
GPU_IMAGE
,
0
,
.
Transform
(
&
context
,
net
.
ws
()
->
GetTensor
(
"Input"
),
OpenCLBufferType
::
IN_OUT_CHANNEL
,
MemoryType
::
GPU_IMAGE
,
0
,
b2i_output
);
};
...
...
@@ -64,36 +123,83 @@ void FilterBufferToImage(int iters,
}
}
// namespace
#define MACE_BM_B2I_MACRO(O, I, H, W, TYPE, DEVICE) \
static void MACE_BM_B2I_##O##_##I##_##H##_##W##_##TYPE##_##DEVICE( \
int iters) { \
const int64_t tot = static_cast<int64_t>(iters) * O * I * H * W; \
mace::testing::BytesProcessed(tot *(sizeof(TYPE))); \
FilterBufferToImage<DEVICE, TYPE>(iters, O, I, H, W); \
} \
MACE_BENCHMARK(MACE_BM_B2I_##O##_##I##_##H##_##W##_##TYPE##_##DEVICE)
#define MACE_BM_B2I(O, I, H, W) \
MACE_BM_B2I_MACRO(O, I, H, W, float, GPU); \
MACE_BM_B2I_MACRO(O, I, H, W, half, GPU);
MACE_BM_B2I
(
5
,
3
,
3
,
3
);
MACE_BM_B2I
(
5
,
3
,
7
,
7
);
MACE_BM_B2I
(
32
,
16
,
1
,
1
);
MACE_BM_B2I
(
32
,
16
,
3
,
3
);
MACE_BM_B2I
(
32
,
16
,
5
,
5
);
MACE_BM_B2I
(
32
,
16
,
7
,
7
);
MACE_BM_B2I
(
64
,
32
,
1
,
1
);
MACE_BM_B2I
(
64
,
32
,
3
,
3
);
MACE_BM_B2I
(
64
,
32
,
5
,
5
);
MACE_BM_B2I
(
64
,
32
,
7
,
7
);
MACE_BM_B2I
(
128
,
64
,
1
,
1
);
MACE_BM_B2I
(
128
,
64
,
3
,
3
);
MACE_BM_B2I
(
128
,
32
,
1
,
1
);
MACE_BM_B2I
(
128
,
32
,
3
,
3
);
MACE_BM_B2I
(
256
,
32
,
1
,
1
);
MACE_BM_B2I
(
256
,
32
,
3
,
3
);
#define MACE_BM_IN_OUT_B2I_MACRO(N, H, W, C, TYPE, DEVICE) \
static void MACE_BM_IN_OUT_B2I_##N##_##H##_##W##_##C##_##TYPE##_##DEVICE( \
int iters) { \
const int64_t tot = static_cast<int64_t>(iters) * N * H * W * C; \
mace::testing::BytesProcessed(tot *(sizeof(TYPE))); \
InOutBufferToImage<DEVICE, TYPE>(iters, N, H, W, C); \
} \
MACE_BENCHMARK(MACE_BM_IN_OUT_B2I_##N##_##H##_##W##_##C##_##TYPE##_##DEVICE)
#define MACE_BM_IN_OUT_B2I(N, H, W, C) \
MACE_BM_IN_OUT_B2I_MACRO(N, H, W, C, float, GPU); \
MACE_BM_IN_OUT_B2I_MACRO(N, H, W, C, half, GPU);
MACE_BM_IN_OUT_B2I
(
256
,
1
,
1
,
32
);
MACE_BM_IN_OUT_B2I
(
256
,
3
,
3
,
32
);
MACE_BM_IN_OUT_B2I
(
1
,
4096
,
4096
,
3
);
namespace
{
template
<
DeviceType
D
,
typename
T
>
void
InOutImageToBuffer
(
int
iters
,
int
batch
,
int
height
,
int
width
,
int
channel
)
{
mace
::
testing
::
StopTiming
();
OpsTestNet
net
;
OpContext
context
(
net
.
ws
(),
OpTestContext
::
Get
()
->
GetDevice
(
DeviceType
::
GPU
));
// Add input data
net
.
AddRandomInput
<
D
,
T
>
(
"Input"
,
{
batch
,
height
,
width
,
channel
});
// Create output
Tensor
*
b2i_output
=
net
.
ws
()
->
CreateTensor
(
"B2IOutput"
,
context
.
device
()
->
allocator
(),
DataTypeToEnum
<
T
>::
value
);
auto
transform_func_b2i
=
[
&
]()
{
OpenCLBufferTransformer
(
MemoryType
::
GPU_BUFFER
,
MemoryType
::
GPU_IMAGE
)
.
Transform
(
&
context
,
net
.
ws
()
->
GetTensor
(
"Input"
),
OpenCLBufferType
::
IN_OUT_CHANNEL
,
MemoryType
::
GPU_IMAGE
,
0
,
b2i_output
);
};
transform_func_b2i
();
Tensor
*
i2b_output
=
net
.
ws
()
->
CreateTensor
(
"I2BOutput"
,
context
.
device
()
->
allocator
(),
DataTypeToEnum
<
T
>::
value
);
auto
transform_func_i2b
=
[
&
]()
{
OpenCLBufferTransformer
(
MemoryType
::
GPU_IMAGE
,
MemoryType
::
GPU_BUFFER
)
.
Transform
(
&
context
,
b2i_output
,
OpenCLBufferType
::
IN_OUT_CHANNEL
,
MemoryType
::
GPU_BUFFER
,
0
,
i2b_output
);
};
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
transform_func_i2b
();
}
net
.
Sync
();
mace
::
testing
::
StartTiming
();
while
(
iters
--
)
{
transform_func_i2b
();
}
net
.
Sync
();
}
}
// namespace
#define MACE_BM_IN_OUT_I2B_MACRO(N, H, W, C, TYPE, DEVICE) \
static void MACE_BM_IN_OUT_I2B_##N##_##H##_##W##_##C##_##TYPE##_##DEVICE( \
int iters) { \
const int64_t tot = static_cast<int64_t>(iters) * N * H * W * C; \
mace::testing::BytesProcessed(tot *(sizeof(TYPE))); \
InOutImageToBuffer<DEVICE, TYPE>(iters, N, H, W, C); \
} \
MACE_BENCHMARK(MACE_BM_IN_OUT_I2B_##N##_##H##_##W##_##C##_##TYPE##_##DEVICE)
#define MACE_BM_IN_OUT_I2B(N, H, W, C) \
MACE_BM_IN_OUT_I2B_MACRO(N, H, W, C, float, GPU); \
MACE_BM_IN_OUT_I2B_MACRO(N, H, W, C, half, GPU);
MACE_BM_IN_OUT_I2B
(
256
,
1
,
1
,
32
);
MACE_BM_IN_OUT_I2B
(
256
,
3
,
3
,
32
);
MACE_BM_IN_OUT_I2B
(
1
,
4096
,
4096
,
3
);
}
// namespace test
}
// namespace ops
}
// namespace mace
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录