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

Method get_grad_var

src/opr/impl/loop/grad.cpp:947–959  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

945}
946
947VarNode* LoopGrad::get_grad_var(size_t inp_idx) {
948 auto&& cache = m_grad_result_cache.at(inp_idx);
949 if (!cache.first) {
950 if (static_cast<GradDesc*>(m_desc.get())
951 ->bind_grad_var(m_fwd_loop_opr->input(inp_idx), output(inp_idx))) {
952 cache.second = output(inp_idx);
953 } else {
954 cache.second = nullptr;
955 }
956 cache.first = true;
957 }
958 return cache.second;
959}
960
961void LoopGrad::scn_do_execute() {
962 mgb_assert(m_nr_scn_do_execute_run + 1 == m_fwd_loop_opr->m_nr_scn_do_execute_run);

Callers 2

gradMethod · 0.80
shallow_copyMethod · 0.80

Calls 4

bind_grad_varMethod · 0.80
atMethod · 0.45
getMethod · 0.45
inputMethod · 0.45

Tested by

no test coverage detected