提交 955095c1 编写于 作者: M Megvii Engine Team 提交者: Xinran Xu

docs(mge/utils): refine docstring in utils module

GitOrigin-RevId: b2bc163e1519571a9233f6baefae28149e684dfa
上级 b2ed2630
......@@ -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)
......
......@@ -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
......@@ -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` .
"""Analyses profile info from :mod:`~.utils.profile_analyzer` .
Run this file with ``--help`` to get more usage.
"""
......
......@@ -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 initialization, 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
"""Updates 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
"""Updates 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
"""Updates 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
"""Initializes 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
"""extracts 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]:
"""aggragate operation
"""Aggregate operation
:param records: records that selected:
:param aop: aggragate operation, if aop is str, we would replace it
:param records: selected records
:param aop: aggregate operation, if aop is str, we would replace it
with associated numpy function wth aop name"
:param atype: the type aggragte by, None for aggragte all into single
:param atype: the type aggregated 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):
"""eval time
"""Eval 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'
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册