Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
a0a7849e
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,发现更多精彩内容 >>
提交
a0a7849e
编写于
4月 12, 2018
作者:
李
李寅
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'log_feature_map' into 'master'
Log feature map size and arguments during benchmark See merge request !380
上级
3c30428e
33d0564c
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
124 addition
and
14 deletion
+124
-14
mace/benchmark/BUILD
mace/benchmark/BUILD
+2
-0
mace/benchmark/stat_summarizer.cc
mace/benchmark/stat_summarizer.cc
+83
-12
mace/benchmark/stat_summarizer.h
mace/benchmark/stat_summarizer.h
+4
-1
mace/core/net.cc
mace/core/net.cc
+25
-1
mace/public/mace_types.h
mace/public/mace_types.h
+10
-0
未找到文件。
mace/benchmark/BUILD
浏览文件 @
a0a7849e
...
...
@@ -16,6 +16,8 @@ cc_library(
hdrs
=
[
"stat_summarizer.h"
],
linkstatic
=
1
,
deps
=
[
"//mace/core"
,
"//mace/kernels"
,
"//mace/public"
,
"//mace/utils"
,
],
...
...
mace/benchmark/stat_summarizer.cc
浏览文件 @
a0a7849e
...
...
@@ -11,7 +11,8 @@
#include "mace/public/mace.h"
#include "mace/utils/logging.h"
#include "mace/core/types.h"
#include "mace/kernels/conv_pool_2d_util.h"
namespace
mace
{
namespace
benchmark
{
...
...
@@ -55,6 +56,8 @@ void StatSummarizer::ProcessMetadata(const RunMetadata &run_metadata) {
if
(
result
.
second
)
{
detail
->
name
=
name
;
detail
->
type
=
op_type
;
detail
->
output_shape
=
ops
.
output_shape
;
detail
->
args
=
ops
.
args
;
detail
->
run_order
=
node_num
;
...
...
@@ -83,7 +86,7 @@ std::string StatSummarizer::ShortSummary() const {
}
std
::
ostream
&
InitField
(
std
::
ostream
&
stream
,
int
width
)
{
stream
<<
"
\t
"
<<
std
::
right
<<
std
::
setw
(
width
)
<<
std
::
fixed
stream
<<
std
::
right
<<
std
::
setw
(
width
)
<<
std
::
fixed
<<
std
::
setprecision
(
3
);
return
stream
;
}
...
...
@@ -98,12 +101,72 @@ std::string StatSummarizer::HeaderString(const std::string &title) const {
InitField
(
stream
,
9
)
<<
"[start]"
;
InitField
(
stream
,
9
)
<<
"[first]"
;
InitField
(
stream
,
9
)
<<
"[avg ms]"
;
InitField
(
stream
,
8
)
<<
"[%]"
;
InitField
(
stream
,
8
)
<<
"[cdf%]"
;
InitField
(
stream
,
9
)
<<
"[%]"
;
InitField
(
stream
,
9
)
<<
"[cdf%]"
;
InitField
(
stream
,
10
)
<<
"[mem KB]"
;
InitField
(
stream
,
9
)
<<
"[times called]"
;
stream
<<
"
\t
"
<<
"[Name]"
;
InitField
(
stream
,
10
)
<<
"[Name]"
;
InitField
(
stream
,
8
)
<<
"[stride]"
;
InitField
(
stream
,
10
)
<<
"[padding]"
;
InitField
(
stream
,
10
)
<<
"[dilation]"
;
InitField
(
stream
,
15
)
<<
"[kernel]"
;
stream
<<
std
::
right
<<
std
::
setw
(
45
)
<<
"[output shape]"
;
return
stream
.
str
();
}
std
::
string
PaddingTypeToString
(
int
padding_type
)
{
std
::
stringstream
stream
;
Padding
type
=
static_cast
<
Padding
>
(
padding_type
);
switch
(
type
)
{
case
VALID
:
stream
<<
"VALID"
;
break
;
case
SAME
:
stream
<<
"SAME"
;
break
;
case
FULL
:
stream
<<
"FULL"
;
break
;
default:
stream
<<
padding_type
;
break
;
}
return
stream
.
str
();
}
std
::
string
ShapeToString
(
const
std
::
vector
<
OutputShape
>
&
output_shape
)
{
if
(
output_shape
.
empty
())
{
return
""
;
}
std
::
stringstream
stream
;
stream
<<
"["
;
for
(
int
i
=
0
;
i
<
output_shape
.
size
();
++
i
)
{
const
std
::
vector
<
index_t
>
&
dims
=
output_shape
[
i
].
dims
();
for
(
int
j
=
0
;
j
<
dims
.
size
();
++
j
)
{
stream
<<
dims
[
j
];
if
(
j
!=
dims
.
size
()
-
1
)
{
stream
<<
","
;
}
}
if
(
i
!=
output_shape
.
size
()
-
1
)
{
stream
<<
":"
;
}
}
stream
<<
"]"
;
return
stream
.
str
();
}
template
<
typename
T
>
std
::
string
VectorToString
(
const
std
::
vector
<
T
>
&
vec
)
{
if
(
vec
.
empty
())
{
return
""
;
}
std
::
stringstream
stream
;
stream
<<
"["
;
for
(
int
i
=
0
;
i
<
vec
.
size
();
++
i
)
{
stream
<<
vec
[
i
];
if
(
i
!=
vec
.
size
()
-
1
)
{
stream
<<
","
;
}
}
stream
<<
"]"
;
return
stream
.
str
();
}
...
...
@@ -115,18 +178,25 @@ std::string StatSummarizer::ColumnString(const StatSummarizer::Detail &detail,
const
double
avg_time_ms
=
detail
.
rel_end_us
.
avg
()
/
1000.0
;
const
double
percentage
=
detail
.
rel_end_us
.
sum
()
*
100.0
/
stat
.
sum
();
const
double
cdf_percentage
=
(
cumulative_stat_on_node
*
100.0
f
)
/
stat
.
sum
();
const
int64_t
times_called
=
detail
.
times_called
/
num_runs
();
std
::
stringstream
stream
;
InitField
(
stream
,
24
)
<<
detail
.
type
;
InitField
(
stream
,
9
)
<<
start_ms
;
InitField
(
stream
,
9
)
<<
first_time_ms
;
InitField
(
stream
,
9
)
<<
avg_time_ms
;
InitField
(
stream
,
7
)
<<
percentage
<<
"%"
;
InitField
(
stream
,
7
)
<<
cdf_percentage
<<
"%"
;
InitField
(
stream
,
8
)
<<
percentage
<<
"%"
;
InitField
(
stream
,
8
)
<<
cdf_percentage
<<
"%"
;
InitField
(
stream
,
10
)
<<
detail
.
mem_used
.
newest
()
/
1000.0
;
InitField
(
stream
,
9
)
<<
times_called
;
stream
<<
"
\t
"
<<
detail
.
name
;
InitField
(
stream
,
10
)
<<
detail
.
name
;
InitField
(
stream
,
8
)
<<
VectorToString
<
int
>
(
detail
.
args
.
strides
);
if
(
detail
.
args
.
padding_type
!=
-
1
)
{
InitField
(
stream
,
10
)
<<
PaddingTypeToString
(
detail
.
args
.
padding_type
);
}
else
{
InitField
(
stream
,
10
)
<<
VectorToString
<
int
>
(
detail
.
args
.
paddings
);
}
InitField
(
stream
,
10
)
<<
VectorToString
<
int
>
(
detail
.
args
.
dilations
);
InitField
(
stream
,
15
)
<<
VectorToString
<
index_t
>
(
detail
.
args
.
kernels
);
stream
<<
std
::
right
<<
std
::
setw
(
45
)
<<
ShapeToString
(
detail
.
output_shape
);
return
stream
.
str
();
}
...
...
@@ -138,6 +208,7 @@ void StatSummarizer::OrderNodesByMetric(
for
(
const
auto
&
det
:
details_
)
{
const
Detail
*
detail
=
&
(
det
.
second
);
std
::
stringstream
stream
;
stream
<<
std
::
setw
(
20
)
<<
std
::
right
<<
std
::
setprecision
(
10
)
<<
std
::
fixed
;
...
...
mace/benchmark/stat_summarizer.h
浏览文件 @
a0a7849e
...
...
@@ -14,6 +14,8 @@
#include <string>
#include <vector>
#include "mace/public/mace_types.h"
namespace
mace
{
class
RunMetadata
;
...
...
@@ -175,6 +177,8 @@ class StatSummarizer {
struct
Detail
{
std
::
string
name
;
std
::
string
type
;
std
::
vector
<
mace
::
OutputShape
>
output_shape
;
ConvPoolArgs
args
;
int64_t
run_order
;
Stat
<
int64_t
>
start_us
;
Stat
<
int64_t
>
rel_end_us
;
...
...
@@ -189,7 +193,6 @@ class StatSummarizer {
std
::
string
ColumnString
(
const
Detail
&
detail
,
const
int64_t
cumulative_stat_on_node
,
const
Stat
<
int64_t
>
&
stat
)
const
;
Stat
<
int64_t
>
run_total_us_
;
Stat
<
int64_t
>
memory_
;
...
...
mace/core/net.cc
浏览文件 @
a0a7849e
...
...
@@ -67,8 +67,32 @@ bool SerialNet::Run(RunMetadata *run_metadata) {
}
if
(
run_metadata
!=
nullptr
)
{
std
::
vector
<
int
>
strides
;
int
padding_type
=
-
1
;
std
::
vector
<
int
>
paddings
;
std
::
vector
<
int
>
dilations
;
std
::
vector
<
index_t
>
kernels
;
std
::
string
type
=
op
->
debug_def
().
type
();
if
(
type
.
compare
(
"Conv2D"
)
==
0
||
type
.
compare
(
"FusedConv2D"
)
==
0
||
type
.
compare
(
"DepthwiseConv2d"
)
==
0
||
type
.
compare
(
"Pooling"
)
==
0
)
{
strides
=
op
->
GetRepeatedArgument
<
int
>
(
"strides"
);
padding_type
=
op
->
GetSingleArgument
<
int
>
(
"padding"
,
-
1
);
paddings
=
op
->
GetRepeatedArgument
<
int
>
(
"padding_values"
);
dilations
=
op
->
GetRepeatedArgument
<
int
>
(
"dilations"
);
if
(
type
.
compare
(
"Pooling"
)
==
0
)
{
kernels
=
op
->
GetRepeatedArgument
<
index_t
>
(
"kernels"
);
}
else
{
kernels
=
op
->
Input
(
1
)
->
shape
();
}
}
OperatorStats
op_stats
=
{
op
->
debug_def
().
name
(),
op
->
debug_def
().
type
(),
call_stats
};
op
->
debug_def
().
output_shape
(),
{
strides
,
padding_type
,
paddings
,
dilations
,
kernels
},
call_stats
};
run_metadata
->
op_stats
.
emplace_back
(
op_stats
);
}
...
...
mace/public/mace_types.h
浏览文件 @
a0a7849e
...
...
@@ -326,9 +326,19 @@ struct CallStats {
int64_t
end_micros
;
};
struct
ConvPoolArgs
{
std
::
vector
<
int
>
strides
;
int
padding_type
;
std
::
vector
<
int
>
paddings
;
std
::
vector
<
int
>
dilations
;
std
::
vector
<
int64_t
>
kernels
;
};
struct
OperatorStats
{
std
::
string
operator_name
;
std
::
string
type
;
std
::
vector
<
OutputShape
>
output_shape
;
ConvPoolArgs
args
;
CallStats
stats
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录