diff --git a/python_module/megengine/utils/http_download.py b/python_module/megengine/utils/http_download.py index f48c62933de14d7591d2b8918799325edc6b80c3..add2a649e815eff774ff5ad43bf01a86b931881c 100644 --- a/python_module/megengine/utils/http_download.py +++ b/python_module/megengine/utils/http_download.py @@ -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) diff --git a/python_module/megengine/utils/max_recursion_limit.py b/python_module/megengine/utils/max_recursion_limit.py index 6901269c7c54177b98d9488f1a78cb51d5437e2e..0870b7fa0e48bff3bc53aa98d2206ae81b1d2aaa 100644 --- a/python_module/megengine/utils/max_recursion_limit.py +++ b/python_module/megengine/utils/max_recursion_limit.py @@ -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 diff --git a/python_module/megengine/utils/profile_analyze.py b/python_module/megengine/utils/profile_analyze.py index e7a868b185425347e9d4bce6fa53aec78f010931..8041c0d8fc66a696f4d6fe5011f1fb63bbe280bf 100755 --- a/python_module/megengine/utils/profile_analyze.py +++ b/python_module/megengine/utils/profile_analyze.py @@ -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. """ diff --git a/python_module/megengine/utils/profile_analyzer.py b/python_module/megengine/utils/profile_analyzer.py index 2d1cc753400c49f1dfa9302f2276008e8f707f6d..75cc0c0c7c6511dd0e5b232b0acd102e4ffe456d 100644 --- a/python_module/megengine/utils/profile_analyzer.py +++ b/python_module/megengine/utils/profile_analyzer.py @@ -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' diff --git a/python_module/megengine/utils/types.py b/python_module/megengine/utils/types.py index 160f505f954bcb5e1824bbc9b8cc8fa14944d009..465ca03ce68f02d3944ddb87f5b0d4abde5ef9f9 100644 --- a/python_module/megengine/utils/types.py +++ b/python_module/megengine/utils/types.py @@ -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"""