Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
955095c1
MegEngine
项目概览
MegEngine 天元
/
MegEngine
大约 1 年 前同步成功
通知
396
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
955095c1
编写于
5月 06, 2020
作者:
M
Megvii Engine Team
提交者:
Xinran Xu
5月 06, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs(mge/utils): refine docstring in utils module
GitOrigin-RevId: b2bc163e1519571a9233f6baefae28149e684dfa
上级
b2ed2630
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
27 addition
and
20 deletion
+27
-20
python_module/megengine/utils/http_download.py
python_module/megengine/utils/http_download.py
+8
-1
python_module/megengine/utils/max_recursion_limit.py
python_module/megengine/utils/max_recursion_limit.py
+1
-1
python_module/megengine/utils/profile_analyze.py
python_module/megengine/utils/profile_analyze.py
+1
-1
python_module/megengine/utils/profile_analyzer.py
python_module/megengine/utils/profile_analyzer.py
+16
-16
python_module/megengine/utils/types.py
python_module/megengine/utils/types.py
+1
-1
未找到文件。
python_module/megengine/utils/http_download.py
浏览文件 @
955095c1
...
...
@@ -26,7 +26,14 @@ class HTTPDownloadError(BaseException):
"""The class that represents http request error"""
def
download_from_url
(
url
,
dst
,
http_read_timeout
=
120
):
def
download_from_url
(
url
:
str
,
dst
:
str
,
http_read_timeout
=
120
):
"""
Downloads file from given url to ``dst``
:param url: source URL
:param dst: saving path
:param http_read_timeout: how many seconds to wait for data before giving up
"""
dst
=
os
.
path
.
expanduser
(
dst
)
dst_dir
=
os
.
path
.
dirname
(
dst
)
...
...
python_module/megengine/utils/max_recursion_limit.py
浏览文件 @
955095c1
...
...
@@ -55,6 +55,6 @@ _max_recursion_limit_context_manager = AlternativeRecursionLimit(2 ** 31 - 1)
def
max_recursion_limit
():
r
"""
set recursion limit to
max possible value
r
"""
Sets recursion limit to the
max possible value
"""
return
_max_recursion_limit_context_manager
python_module/megengine/utils/profile_analyze.py
浏览文件 @
955095c1
...
...
@@ -57,7 +57,7 @@ def _tabulate_confluence(tab, **kwargs):
def
main
(
passed_args
=
None
):
# pylint: disable=too-many-statements
"""Analyse profile info from :mod:`~.utils.profile_analyzer` .
"""Analyse
s
profile info from :mod:`~.utils.profile_analyzer` .
Run this file with ``--help`` to get more usage.
"""
...
...
python_module/megengine/utils/profile_analyzer.py
浏览文件 @
955095c1
...
...
@@ -72,7 +72,7 @@ class OprProfRst:
of corresponding operations"""
def
__init__
(
self
,
entry
:
dict
):
"""Opr profiling init
, setup name, id, type
of opr_info.
"""Opr profiling init
ialization, which sets up name, type and id
of opr_info.
:param entry: profiling json exec_graph items
"""
...
...
@@ -84,7 +84,7 @@ class OprProfRst:
self
.
footprint
=
collections
.
defaultdict
(
NonExistNum
)
def
update_device_prof_info
(
self
,
dev_time
:
dict
):
"""Update
device prof
info
"""Update
s device profiling
info
:param dev_time: device time for single opr,
is an attribute of profiling result.
...
...
@@ -93,7 +93,7 @@ class OprProfRst:
self
.
time_dict
[
"device"
].
append
(
copy
.
deepcopy
(
dev_time
))
def
update_host_prof_info
(
self
,
host_time
:
dict
):
"""Update host profiling info
"""Update
s
host profiling info
:param host_time: host time for single opr,
is an attribute of profiling result.
...
...
@@ -102,7 +102,7 @@ class OprProfRst:
self
.
time_dict
[
"host"
].
append
(
copy
.
deepcopy
(
host_time
))
def
update_footprint
(
self
,
footprint
:
dict
):
"""Update opr footprint
"""Update
s
opr footprint
:param footprint: footprint for single opr,
is an attribute of profiling result.
...
...
@@ -128,7 +128,7 @@ class Record:
]
def
__init__
(
self
,
time
:
float
,
info
:
dict
,
footprint
:
dict
):
"""Init single record
"""Init
ializes
single record
:param time: opr running time, evaluated by applying users providing
function to OprProfRst.
...
...
@@ -153,7 +153,7 @@ class Record:
self
.
opr_id
=
int
(
self
.
opr_id
)
def
get_column_by_name
(
self
,
name
:
str
=
None
):
"""extract column value by its column name
"""extract
s
column value by its column name
:param name: column name, None for time.
"""
...
...
@@ -165,7 +165,7 @@ class Record:
class
ProfileAnalyzer
:
def
__init__
(
self
,
obj
:
dict
,
opr_filter
:
Callable
=
lambda
opr
,
inp
,
out
:
True
):
"""
initialize
ProfileAnalyzer
"""
Initializes
ProfileAnalyzer
:param obj: dict dumped from json str.
:param opr_filter: function that filter oprs.
...
...
@@ -202,12 +202,12 @@ class ProfileAnalyzer:
def
_aggregate
(
self
,
records
:
List
[
Record
],
aop
:
Union
[
str
,
Callable
],
atype
:
Optional
[
str
]
)
->
List
[
Record
]:
"""
aggra
gate operation
"""
Aggre
gate operation
:param records:
records that selected:
:param aop: aggr
a
gate operation, if aop is str, we would replace it
:param records:
selected records
:param aop: aggr
e
gate operation, if aop is str, we would replace it
with associated numpy function wth aop name"
:param atype: the type aggr
agte by, None for aggragte
all into single
:param atype: the type aggr
egated by, None for aggregating
all into single
record.
"""
if
aop
is
None
:
...
...
@@ -304,7 +304,7 @@ class TimeFuncHelper:
@
staticmethod
def
_eval_time
(
prof_type
,
end_key
,
func
,
opr_prof
):
"""
e
val time
"""
E
val time
:type prof_type: str
:param prof_type: 'host' or 'device'
...
...
@@ -338,7 +338,7 @@ class TimeFuncHelper:
def
_min_start
(
prof_type
,
end_key
,
func
,
opr_prof
):
# pylint: disable=unused-argument
"""
eval
time
"""
Eval minimum start
time
:type prof_type: str
:param prof_type: 'host' or 'device'
...
...
@@ -360,7 +360,7 @@ class TimeFuncHelper:
def
min_start_func
(
prof_type
:
str
,
end_key
:
str
,
func
:
Callable
)
->
float
:
# pylint: disable=unused-argument
"""Eval oprerator profile
time with ``np.min``.
"""Eval oprerator profile
min start time
:param prof_type: 'host' or 'device'
:param end_key: 'kern' or 'end'
...
...
@@ -371,7 +371,7 @@ class TimeFuncHelper:
@
staticmethod
def
_max_end
(
prof_type
,
end_key
,
func
,
opr_prof
):
# pylint: disable=unused-argument
"""
eval
time
"""
Eval maximum end
time
:type prof_type: str
:param prof_type: 'host' or 'device'
...
...
@@ -391,7 +391,7 @@ class TimeFuncHelper:
@
staticmethod
def
max_end_func
(
prof_type
:
str
,
end_key
:
str
,
func
:
Callable
)
->
float
:
"""Eval max end time
"""Eval
oprerator profile
max end time
:param prof_type: 'host' or 'device'
:param end_key: 'kern' or 'end'
...
...
python_module/megengine/utils/types.py
浏览文件 @
955095c1
...
...
@@ -11,7 +11,7 @@ import functools
def
get_ndtuple
(
value
,
*
,
n
,
allow_zero
=
True
):
r
"""
convert
possibly 1D tuple to nd tuple
r
"""
Converts
possibly 1D tuple to nd tuple
:type allow_zero: bool
:param allow_zero: whether to allow zero tuple value"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录