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

Function MGB_IMPL_OPR_GRAD

src/opr/impl/cond.cpp:805–828  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

803
804#if MGB_ENABLE_GRAD
805MGB_IMPL_OPR_GRAD(CondExecMark) {
806 if (wrt_idx == opr.input().size() - 1 || !out_grad.at(wrt_idx)) {
807 return nullptr;
808 }
809 using GradMode = CondExecMark::Param::GradMode;
810 using MergeMode = CondExecMerge::Param::Mode;
811 MergeMode grad_mode;
812 SymbolVarArray grad_shapes;
813 switch (opr.param().grad_mode) {
814 case GradMode::SUM:
815 grad_mode = MergeMode::SUM;
816 grad_shapes.emplace_back(SymbolVar{opr.input(wrt_idx)}.symshape());
817 break;
818 case GradMode::SUM_COND_OUT:
819 grad_mode = MergeMode::SUM_COND_OUT;
820 break;
821 default:
822 mgb_throw(MegBrainError, "invalid grad_mode");
823 }
824 return CondExecMerge::make_opr(
825 {out_grad[wrt_idx]}, grad_shapes, {1, grad_mode},
826 OperatorNodeConfig{})
827 ->output(0);
828}
829#endif
830
831/* ============================= CondExecMerge ============================= */

Callers

nothing calls this directly

Calls 12

proxy_var_from_maskFunction · 0.85
emplace_backMethod · 0.80
symshapeMethod · 0.80
makeFunction · 0.50
sizeMethod · 0.45
inputMethod · 0.45
atMethod · 0.45
paramMethod · 0.45
outputMethod · 0.45
mem_nodeMethod · 0.45
comp_nodeMethod · 0.45
nodeMethod · 0.45

Tested by

no test coverage detected