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

Method __call__

imperative/python/megengine/core/autodiff/grad.py:51–75  ·  view source on GitHub ↗
(self, ys, dys)

Source from the content-addressed store, hash-verified

49 return self
50
51 def __call__(self, ys, dys):
52 from collections.abc import Sequence
53
54 if not isinstance(ys, Sequence):
55 ys = [ys]
56
57 if not isinstance(dys, Sequence):
58 dys = [dys]
59
60 group = [ref() for ref in self._group]
61
62 for grad in group:
63 if grad is self:
64 continue
65 grad.suppress()
66
67 self._impl.backward(ys, dys)
68
69 for grad in group:
70 if grad is self:
71 continue
72 grad.resume()
73
74 self._refkeeper = None
75 return None
76
77 def __enter__(self):
78 ref = weakref.ref(self)

Callers

nothing calls this directly

Calls 4

refFunction · 0.50
suppressMethod · 0.45
backwardMethod · 0.45
resumeMethod · 0.45

Tested by

no test coverage detected