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

Function wrapper

imperative/python/megengine/utils/module_stats.py:544–567  ·  view source on GitHub ↗
(fun)

Source from the content-addressed store, hash-verified

542 @contextmanager
543 def param_stat_context():
544 def wrapper(fun):
545 @functools.wraps(fun)
546 def param_access_record(module, item):
547 member = fun(module, item)
548 if (
549 item in ["weight", "bias"]
550 and member is not None
551 and member not in recorded_parameters
552 ):
553 name = module_to_name[module]
554 if item == "weight":
555 suffix = "-w"
556 elif item == "bias":
557 suffix = "-b"
558
559 param_name = name + suffix
560 param_stats = get_param_stats(member)
561 param_stats["name"] = param_name
562 params.append(param_stats)
563 recorded_parameters.add(member)
564
565 return member
566
567 return param_access_record
568
569 origin_get_attr = object.__getattribute__
570 try:

Callers 1

param_stat_contextFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected