| 248 | } |
| 249 | |
| 250 | VarNode* Loop::grad(Loop& opr, size_t wrt_idx, const VarNodeArray& out_grad) { |
| 251 | LoopGrad*& gopr = |
| 252 | opr.m_loss2grad_opr[cg::current_grad_target(*opr.owner_graph()).node()]; |
| 253 | if (!gopr) { |
| 254 | // extra output is counter var |
| 255 | mgb_assert( |
| 256 | out_grad.size() == opr.m_desc->output_record_spec().size() + 1 && |
| 257 | !out_grad.back()); |
| 258 | VarNodeArray out_grad_used(out_grad); |
| 259 | out_grad_used.pop_back(); |
| 260 | gopr = LoopGrad::make(&opr, out_grad_used); |
| 261 | } |
| 262 | return gopr->get_grad_var(wrt_idx); |
| 263 | } |
| 264 | |
| 265 | #if MGB_ENABLE_GRAD |
| 266 | MGB_IMPL_OPR_GRAD(Loop) { |
nothing calls this directly
no test coverage detected