MCPcopy Create free account
hub / github.com/pytorch/pytorch / _retain_grad

Method _retain_grad

test/test_modules.py:308–314  ·  view source on GitHub ↗
(self, obj)

Source from the content-addressed store, hash-verified

306 return func(obj)
307
308 def _retain_grad(self, obj):
309 # gradients needs to be retained to check for grad. This is useful when
310 # non-leafs are present in the graph.
311 def inner_retain_grad(obj):
312 if obj.requires_grad:
313 obj.retain_grad()
314 self._traverse_obj(obj, inner_retain_grad)
315
316 def _get_grads(self, obj):
317 def inner_get_grad(obj):

Callers 2

test_cpu_gpu_parityMethod · 0.95

Calls 1

_traverse_objMethod · 0.95

Tested by

no test coverage detected