Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
c45f1eb2
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
403
Star
4705
Fork
582
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
c45f1eb2
编写于
3月 16, 2021
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mge/tools): improve `module_visualize` result's robustness and beauty
GitOrigin-RevId: ef7b57377619fabcf50d4a48235b8d196659f1d4
上级
786c36ff
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
2 deletion
+14
-2
imperative/python/megengine/tools/network_visualize.py
imperative/python/megengine/tools/network_visualize.py
+11
-1
imperative/python/megengine/utils/module_stats.py
imperative/python/megengine/utils/module_stats.py
+3
-1
未找到文件。
imperative/python/megengine/tools/network_visualize.py
浏览文件 @
c45f1eb2
...
...
@@ -7,11 +7,12 @@
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import
argparse
import
logging
import
numpy
as
np
from
megengine.core.tensor.dtype
import
is_quantize
from
megengine.logger
import
get_logger
from
megengine.logger
import
_imperative_rt_logger
,
get_logger
,
set_mgb_log_level
from
megengine.utils.module_stats
import
(
print_flops_stats
,
print_params_stats
,
...
...
@@ -58,6 +59,8 @@ def visualize(
"TensorBoard and TensorboardX are required for visualize."
,
exc_info
=
True
)
return
# FIXME: remove this after resolving "span dist too large" warning
old_level
=
set_mgb_log_level
(
logging
.
ERROR
)
graph
=
Network
.
load
(
model_path
)
writer
=
SummaryWriter
(
log_path
)
...
...
@@ -126,6 +129,9 @@ def visualize(
std
=
"{:.2g}"
.
format
(
node
.
numpy
().
std
()),
)
)
# FIXME(MGE-2165): nodes outside network module may lead to unknown display bug
if
not
len
(
node
.
name
.
split
(
"."
))
>
2
and
not
node
in
graph
.
input_vars
:
continue
node_list
.
append
(
NodeDef
(
name
=
process_name
(
node
.
name
),
op
=
node
.
type
,
input
=
inp_list
,
attr
=
attr
,
...
...
@@ -145,6 +151,10 @@ def visualize(
step_stats
=
StepStats
(
dev_stats
=
[
DeviceStepStats
(
device
=
device
)])
)
writer
.
_get_file_writer
().
add_graph
((
graph_def
,
stepstats
))
# FIXME: remove this after resolving "span dist too large" warning
_imperative_rt_logger
.
set_log_level
(
old_level
)
return
total_params
,
total_flops
...
...
imperative/python/megengine/utils/module_stats.py
浏览文件 @
c45f1eb2
...
...
@@ -135,7 +135,9 @@ def print_flops_stats(flops, bar_length_max=20):
]
total_flops_str
=
sizeof_fmt
(
total_flops_num
,
suffix
=
"OPs"
)
total_var_size
=
sum
(
sum
(
s
[
1
]
for
s
in
i
[
"output_shapes"
])
for
i
in
flops
)
total_var_size
=
sum
(
sum
(
s
[
1
]
if
len
(
s
)
>
1
else
0
for
s
in
i
[
"output_shapes"
])
for
i
in
flops
)
flops
.
append
(
dict
(
name
=
"total"
,
flops
=
total_flops_str
,
output_shapes
=
total_var_size
)
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录