MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / __init__

Method __init__

python/oneflow/nn/modules/module.py:143–163  ·  view source on GitHub ↗

Calls super().__setattr__('a', a) instead of the typical self.a = a to avoid Module.__setattr__ overhead. Module's __setattr__ has special handling for parameters, submodules, and buffers but simply calls into super().__setattr__ for all other attributes.

(self)

Source from the content-addressed store, hash-verified

141 """
142
143 def __init__(self):
144 """
145 Calls super().__setattr__('a', a) instead of the typical self.a = a
146 to avoid Module.__setattr__ overhead. Module's __setattr__ has special
147 handling for parameters, submodules, and buffers but simply calls into
148 super().__setattr__ for all other attributes.
149 """
150 super().__setattr__("training", True)
151 super().__setattr__("_parameters", OrderedDict())
152 super().__setattr__("_buffers", OrderedDict())
153 super().__setattr__("_non_persistent_buffers_set", set())
154 super().__setattr__("_backward_hooks", OrderedDict())
155 super().__setattr__("_is_full_backward_hook", None)
156 super().__setattr__("_forward_hooks", OrderedDict())
157 super().__setattr__("_forward_pre_hooks", OrderedDict())
158 super().__setattr__("_state_dict_hooks", OrderedDict())
159 super().__setattr__("_load_state_dict_pre_hooks", OrderedDict())
160 super().__setattr__("_modules", OrderedDict())
161 super().__setattr__("_is_ddp_module", False)
162 super().__setattr__("_oneflow_internal_module_tensor_applied_dict__", None)
163 super().__setattr__("cpg", None)
164
165 def __getstate__(self):
166 if not self._is_ddp_module:

Callers

nothing calls this directly

Calls 1

__setattr__Method · 0.45

Tested by

no test coverage detected