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

Method try_reassociate

src/gopt/impl/inference.cpp:278–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276}
277
278GTransResult ParamRedistributePass::Impl::try_reassociate(OperatorNodeBase* opr) {
279 // apply BinaryAssociative0 if opr is the form f(g(a, b), c) and b and c are
280 // const
281
282 bool swap_fop_inp = false, swap_gop_inp = false;
283 VarNode *a, *b, *c, *ab;
284 if (!reorder_for_normconst(opr, swap_fop_inp, ab, c))
285 return None;
286
287 if (!m_uniq_reader_check(ab))
288 return None;
289
290 if (!reorder_for_normconst(ab->owner_opr(), swap_gop_inp, a, b))
291 return None;
292
293 return BinaryTrans20::associtive().apply(opr, swap_fop_inp, swap_gop_inp);
294}
295
296GTransResult ParamRedistributePass::Impl::try_distribute_add(OperatorNodeBase* opr) {
297 if (opr->same_type<opr::Elemwise>() || opr->input().size() != 2)

Callers

nothing calls this directly

Calls 2

owner_oprMethod · 0.45
applyMethod · 0.45

Tested by

no test coverage detected