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

Function sum_param_stats

imperative/python/megengine/utils/module_stats.py:315–334  ·  view source on GitHub ↗
(params, bar_length_max=20)

Source from the content-addressed store, hash-verified

313
314
315def sum_param_stats(params, bar_length_max=20):
316 max_size = max([d["size"] for d in params] + [0])
317 total_param_dims, total_param_size = 0, 0
318 for d in params:
319 total_param_dims += int(d["param_dim"])
320 total_param_size += int(d["size"])
321 d["size_cum"] = sizeof_fmt(total_param_size)
322
323 for d in params:
324 ratio = d["size"] / total_param_size
325 d["ratio"] = ratio
326 d["percentage"] = "{:.2f}%".format(ratio * 100)
327 bar_length = int(d["size"] / max_size * bar_length_max)
328 d["size_bar"] = "#" * bar_length
329 d["size"] = sizeof_fmt(d["size"])
330
331 param_size = sizeof_fmt(total_param_size)
332 params.append(dict(name="total", param_dim=total_param_dims, size=param_size,))
333
334 return total_param_dims, total_param_size, params
335
336
337def print_param_stats(params):

Callers 2

visualizeFunction · 0.90
module_statsFunction · 0.85

Calls 4

maxFunction · 0.85
sizeof_fmtFunction · 0.85
formatMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected