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

Function Backward

oneflow/api/python/autograd/autograd.cpp:105–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103} // namespace
104
105Maybe<one::TensorTuple> Backward(const one::TensorTuple& outputs, const one::TensorTuple& out_grads,
106 bool retain_graph, bool create_graph) {
107 PythonFrameGuard pf;
108 BackwardPassScopeGuard backward_guard;
109 if (create_graph) { retain_graph = true; }
110 std::shared_ptr<one::TensorTuple> gradients =
111 JUST(CheckAndInitOutGrads(outputs, out_grads, /*is_grads_batched=*/false));
112 JUST(one::GetThreadLocalAutogradEngine()->RunBackwardAndSaveGrads4LeafTensorIf(
113 outputs, *gradients, retain_graph, create_graph));
114 return std::make_shared<one::TensorTuple>(0);
115}
116
117Maybe<one::TensorTuple> Grad(const one::TensorTuple& outputs, const one::TensorTuple& inputs,
118 const one::TensorTuple& out_grads, bool retain_graph,

Callers 10

ComputeMethod · 0.85
ComputeMethod · 0.85
ComputeMethod · 0.85
ComputeMethod · 0.85
ComputeMethod · 0.85
ComputeMethod · 0.85
ComputeMethod · 0.85
BatchGatherBackwardFunction · 0.85
ComputeMethod · 0.85
GradFunction · 0.85

Tested by

no test coverage detected