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

Function get_op_stats

imperative/python/megengine/utils/module_stats.py:224–254  ·  view source on GitHub ↗
(module, inputs, outputs)

Source from the content-addressed store, hash-verified

222
223
224def get_op_stats(module, inputs, outputs):
225 if not isinstance(outputs, tuple) and not isinstance(outputs, list):
226 outputs = (outputs,)
227 rst = {
228 "input_shapes": [i.shape for i in inputs],
229 "output_shapes": [o.shape for o in outputs],
230 }
231 valid_flag = False
232 for key, _dict, fallback in _iter_list:
233 for _type in _dict:
234 if isinstance(module, _type):
235 value = _dict[_type](module, inputs, outputs)
236 valid_flag = True
237 break
238 else:
239 if fallback is not None:
240 value = fallback(module, inputs, outputs)
241 continue
242
243 if isinstance(key, tuple):
244 assert isinstance(value, tuple)
245 for k, v in zip(key, value):
246 rst[k] = v
247 else:
248 rst[key] = value
249
250 if valid_flag:
251 return rst
252 else:
253 return None
254 return
255
256
257def sum_op_stats(flops, bar_length_max=20):

Callers 2

visualizeFunction · 0.90
module_stats_hookFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected