Zha0q1 commented on a change in pull request #15132: Profiler API Enhancements
URL: https://github.com/apache/incubator-mxnet/pull/15132#discussion_r293516116
##########
File path: python/mxnet/profiler.py
##########
@@ -148,17 +148,35 @@ def dump_profile():
dump(True)
-def dumps(reset=False):
+def dumps(reset=False, format='table', sort_by='avg', ascending=False):
"""Return a printable string of aggregate profile stats.
Parameters
----------
reset: boolean
- Indicates whether to clean aggeregate statistical data collected up to
this point
+ indicates whether to clean aggeregate statistical data collected up to
this point
+ format: string
+ whether to return the aggregate stats in table of json format
+ can take 'table' or 'json'
+ defaults to 'table'
+ sort_by: string
+ can take 'avg', 'min', 'max', or 'count'
+ by which stat to sort the entries in each category
+ defaults to 'avg'
+ ascending: boolean
+ whether to sort ascendingly
+ defaults to False
"""
debug_str = ctypes.c_char_p()
- do_reset = 1 if reset is True else 0
- check_call(_LIB.MXAggregateProfileStatsPrint(ctypes.byref(debug_str),
int(do_reset)))
+ reset_to_int = {False: 0, True: 1}
+ format_to_int = {'table': 0, 'json': 1}
+ sort_by_to_int = {'avg': 0, 'min': 1, 'max': 2, 'count': 3}
+ asc_to_int = {False: 0, True: 1}
+ check_call(_LIB.MXAggregateProfileStatsPrintEx(ctypes.byref(debug_str),
+ reset_to_int[reset],
+ format_to_int[format],
+ sort_by_to_int[sort_by],
Review comment:
Error will happen because key does not exist in the dict
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services