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

Method backward

imperative/python/src/grad.cpp:50–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50void GradKeyWrapper::backward(GradKeyWrapper* self, py::list tensors, py::list grads) {
51 std::vector<ValueRef> args;
52 mgb_assert(tensors.size() == grads.size());
53 for (auto&& tensor : tensors) {
54 auto* tw = TensorWrapper::try_cast(tensor.ptr());
55 mgb_assert(tw, "expect Tensor");
56 args.push_back(tw->m_tensor->data());
57 }
58 for (auto&& grad : grads) {
59 auto* tw = TensorWrapper::try_cast(grad.ptr());
60 mgb_assert(tw, "expect Tensor");
61 args.push_back(tw->m_tensor->data());
62 }
63 imperative::apply(GradBackward(self->m_key), {args.data(), args.size()});
64}
65
66pybind11::function GradKeyWrapper::get_backward_closure(
67 GradKeyWrapper* self, py::list tensors) {

Callers 15

matrix_mul_grad_ruleFunction · 0.45
elemwise_grad_ruleFunction · 0.45
reshape_grad_ruleFunction · 0.45
broadcast_grad_ruleFunction · 0.45
subtensor_grad_ruleFunction · 0.45
reduce_grad_ruleFunction · 0.45
addAxis_grad_ruleFunction · 0.45
removeAxis_grad_ruleFunction · 0.45
pixelShuffle_grad_ruleFunction · 0.45
indexing_grad_ruleFunction · 0.45

Calls 7

try_castFunction · 0.85
GradBackwardClass · 0.85
applyFunction · 0.50
sizeMethod · 0.45
ptrMethod · 0.45
push_backMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected