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

Function _backward

python/oneflow/framework/tensor.py:32–44  ·  view source on GitHub ↗
(self, gradient=None, retain_graph=False, create_graph=False)

Source from the content-addressed store, hash-verified

30
31
32def _backward(self, gradient=None, retain_graph=False, create_graph=False):
33 if lazy_mode.is_enabled():
34 assert (
35 self.is_lazy
36 ), "nn.Graph only accept lazy tensor to call backward() in lazy mode."
37 assert (
38 not retain_graph
39 ), "nn.Graph donot accept 'retain_graph' argument in backward() at the moment."
40 assert (
41 not create_graph
42 ), "nn.Graph donot accept 'create_graph' argument in backward() at the moment."
43 flow._oneflow_internal.nn.graph.AddTensorAsGraphLoss(self)
44 flow.autograd.backward(self, gradient, retain_graph, create_graph)
45
46
47def _str(self):

Callers

nothing calls this directly

Calls 2

is_enabledMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected