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

Method AddUpdate

src/opr/impl/basic_arith.cpp:851–879  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

849MGB_DYN_TYPE_OBJ_FINAL_IMPL(AddUpdate);
850
851AddUpdate::AddUpdate(
852 VarNode* dest, VarNode* delta, const Param& param,
853 const OperatorNodeConfig& config)
854 : Super{dest->owner_graph(), config, "inplace_add", {dest, delta}},
855 m_param{param} {
856 auto dest_opr = dest->owner_opr();
857 mgb_throw_if(
858 dest_opr->same_type<ImmutableTensor>(), GraphError,
859 "AddUpdate cannot be applied on ImmutableTensor; ");
860 add_input({dest, delta});
861
862 /*
863 * here we tell the system that output(0) would force-update input(0); the
864 * topo-sorting system would ensure that all the readers finish before
865 * executing this AddUpdate operation
866 */
867 add_output(None)->set_fwd_in2out_writable_force(input(0)).add_flag(
868 VarNode::Flag::NO_MEM_RECLAIM);
869
870 mgb_assert(
871 m_param.disable->dtype() == dtype::Int32{},
872 "dtype of disable flag on AddUpdate must be Int32, got %s actually.",
873 m_param.disable->dtype().name());
874
875 add_equivalence_component<ScalarHash<void*>>(m_param.alpha.get());
876 add_equivalence_component<ScalarHash<void*>>(m_param.beta.get());
877 add_equivalence_component<ScalarHash<void*>>(m_param.bias.get());
878 add_equivalence_component<ScalarHash<void*>>(m_param.disable.get());
879}
880
881SymbolVar AddUpdate::make(
882 SymbolVar dest, SymbolVar delta, const Param& param,

Callers

nothing calls this directly

Calls 5

owner_graphMethod · 0.45
owner_oprMethod · 0.45
dtypeMethod · 0.45
nameMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected