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

Method try_distribute_add

src/gopt/impl/inference.cpp:296–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294}
295
296GTransResult ParamRedistributePass::Impl::try_distribute_add(OperatorNodeBase* opr) {
297 if (opr->same_type<opr::Elemwise>() || opr->input().size() != 2)
298 return None;
299
300 if (!m_cvprop.is_const(opr->input(1)))
301 return None;
302
303 auto ab = as_elem_opr(opr->input(0)->owner_opr(), opr::Elemwise::Mode::ADD);
304 if (ab) {
305 bool swap;
306 VarNode *a, *b;
307 if (reorder_for_normconst(ab, swap, a, b)) {
308 return BinaryTrans20::distributive_add().apply(opr, false, swap);
309 }
310 }
311 return None;
312}
313
314GTransResult ParamRedistributePass::Impl::try_distribute_then_reassociate(
315 OperatorNodeBase* opr) {

Callers

nothing calls this directly

Calls 6

as_elem_oprFunction · 0.85
is_constMethod · 0.80
sizeMethod · 0.45
inputMethod · 0.45
owner_oprMethod · 0.45
applyMethod · 0.45

Tested by

no test coverage detected