Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OAID
Tengine
提交
737e7c3c
T
Tengine
项目概览
OAID
/
Tengine
大约 1 年 前同步成功
通知
53
Star
4429
Fork
1032
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Tengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
737e7c3c
编写于
1月 20, 2022
作者:
D
Dahan Gong
提交者:
GitHub
1月 21, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
benchmark: support a new argument: device (#1262)
上级
44af3fdf
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
29 addition
and
1 deletion
+29
-1
benchmark/tm_benchmark.cc
benchmark/tm_benchmark.cc
+29
-1
未找到文件。
benchmark/tm_benchmark.cc
浏览文件 @
737e7c3c
...
...
@@ -37,12 +37,14 @@ int benchmark_threads = 1;
int
benchmark_model
=
-
1
;
int
benchmark_cluster
=
0
;
int
benchmark_mask
=
0xFFFF
;
std
::
string
benchmark_device
=
""
;
context_t
s_context
;
int
benchmark_graph
(
options_t
*
opt
,
const
char
*
name
,
const
char
*
file
,
int
height
,
int
width
,
int
channel
,
int
batch
)
{
// create graph, load tengine model xxx.tmfile
graph_t
graph
=
create_graph
(
nullptr
,
"tengine"
,
file
);
graph_t
graph
=
create_graph
(
s_context
,
"tengine"
,
file
);
if
(
nullptr
==
graph
)
{
fprintf
(
stderr
,
"Tengine Benchmark: Create graph failed.
\n
"
);
...
...
@@ -144,6 +146,7 @@ int main(int argc, char* argv[])
cmd
.
add
<
int
>
(
"cpu_cluster"
,
'p'
,
"cpu cluster [0:auto, 1:big, 2:middle, 3:little]"
,
false
,
0
);
cmd
.
add
<
int
>
(
"model"
,
's'
,
"benchmark which model,
\"
-1
\"
means all models"
,
false
,
-
1
);
cmd
.
add
<
int
>
(
"cpu_mask"
,
'a'
,
"benchmark on masked cpu core(s)"
,
false
,
-
1
);
cmd
.
add
<
std
::
string
>
(
"device"
,
'd'
,
"device name (should be upper-case)"
,
false
);
cmd
.
parse_check
(
argc
,
argv
);
...
...
@@ -152,12 +155,25 @@ int main(int argc, char* argv[])
benchmark_model
=
cmd
.
get
<
int
>
(
"model"
);
benchmark_cluster
=
cmd
.
get
<
int
>
(
"cpu_cluster"
);
benchmark_mask
=
cmd
.
get
<
int
>
(
"cpu_mask"
);
benchmark_device
=
cmd
.
get
<
std
::
string
>
(
"device"
);
if
(
benchmark_device
.
empty
())
{
benchmark_device
=
"CPU"
;
}
else
{
for
(
int
i
=
0
;
i
<
benchmark_device
.
length
();
i
++
)
{
benchmark_device
[
i
]
=
::
toupper
(
benchmark_device
[
i
]);
}
}
fprintf
(
stdout
,
"Tengine benchmark:
\n
"
);
fprintf
(
stdout
,
" loops: %d
\n
"
,
benchmark_loop
);
fprintf
(
stdout
,
" threads: %d
\n
"
,
benchmark_threads
);
fprintf
(
stdout
,
" cluster: %d
\n
"
,
benchmark_cluster
);
fprintf
(
stdout
,
" affinity: 0x%X
\n
"
,
benchmark_mask
);
fprintf
(
stdout
,
" device: %s
\n
"
,
benchmark_device
.
c_str
());
// initialize tengine
if
(
0
!=
init_tengine
())
...
...
@@ -167,6 +183,17 @@ int main(int argc, char* argv[])
}
fprintf
(
stdout
,
"Tengine-lite library version: %s
\n
"
,
get_tengine_version
());
s_context
=
create_context
(
"ctx"
,
benchmark_device
.
empty
()
?
0
:
1
);
if
(
!
benchmark_device
.
empty
())
{
int
ret
=
set_context_device
(
s_context
,
benchmark_device
.
c_str
(),
nullptr
,
0
);
if
(
0
!=
ret
)
{
fprintf
(
stderr
,
"Set context device failed: %d.
\n
"
,
ret
);
return
false
;
}
}
struct
options
opt
;
opt
.
num_thread
=
benchmark_threads
;
opt
.
precision
=
TENGINE_MODE_FP32
;
...
...
@@ -253,6 +280,7 @@ int main(int argc, char* argv[])
}
/* release tengine */
destroy_context
(
s_context
);
release_tengine
();
fprintf
(
stderr
,
"ALL TEST DONE.
\n
"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录