MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / prof_details

Function prof_details

imperative/python/megengine/tools/profile_analyze.py:250–408  ·  view source on GitHub ↗
(prof_type, tot_time)

Source from the content-addressed store, hash-verified

248 return tab_str, tot_dev_time, tot_host_time
249
250 def prof_details(prof_type, tot_time):
251 tab = []
252
253 def func(
254 opr,
255 *,
256 f0=TimeFuncHelper.eval_time_func(prof_type, args.top_end_key, np.max)
257 ):
258 t = f0(opr)
259 if t is not None and (t < args.min_time or t > args.max_time):
260 return None
261 return t
262
263 records = analyzer.select(
264 func,
265 aggregate=args.aggregate,
266 aggregate_by=args.aggregate_by,
267 top_k=args.top,
268 sort_by=args.order_by,
269 )
270
271 if args.dump_only_opr:
272 ret = []
273 for i in records:
274 ret.append(" ".join(i.info.values()))
275 return "\n".join(ret)
276
277 def format_shapes(shapes, layouts=None, sep="\n"):
278 if isinstance(shapes, NonExistNum) or shapes is None:
279 return repr(shapes)
280 if layouts is None:
281 layouts = [None] * len(shapes)
282
283 comp = []
284 for i, j in zip(shapes, layouts):
285 i = "{" + ",".join(map(str, i)) + "}"
286 if j:
287 i += "\n -[" + ",".join(map(str, j)) + "]"
288 comp.append(i)
289 return sep.join(comp)
290
291 def fix_num_and_find_unit(x, base):
292 if isinstance(x, NonExistNum) or (
293 isinstance(x, float) and not np.isfinite(x)
294 ):
295 return x, ""
296 unit = iter(["", "K", "M", "G", "T", "P"])
297 while x >= base:
298 x /= base
299 next(unit)
300 return x, next(unit)
301
302 def get_number_with_unit(num, unit, base, sep="\n"):
303 num, unit_prefix = fix_num_and_find_unit(num, base)
304 if isinstance(unit, list):
305 unit = unit[int(unit_prefix != "")]
306 return ("{:.2f}" + sep + "{}{}").format(num, unit_prefix, unit)
307

Callers 1

mainFunction · 0.85

Calls 15

maxFunction · 0.85
format_shapesFunction · 0.85
listFunction · 0.85
_tabulate_confluenceFunction · 0.85
strFunction · 0.85
get_number_with_unitFunction · 0.85
_tabulate_mlFunction · 0.85
joinMethod · 0.80
valuesMethod · 0.80
itemsMethod · 0.80
keysMethod · 0.80
selectMethod · 0.45

Tested by

no test coverage detected