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

Method do_make_node_prop

src/opr/impl/loop/forward.cpp:271–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269#endif
270
271cg::OperatorNodeBase::NodeProp* Loop::do_make_node_prop() const {
272 auto prop = LoopImpl::do_make_node_prop();
273
274 // check whether sub graph is impure
275 for (auto i : static_cast<FwdDesc*>(m_desc.get())->sub_graph_oprs()) {
276 constexpr auto IMPURE = NodeProp::Flag::IMPURE_FUNC;
277 if (i->node_prop().contain(IMPURE) && !i->same_type<InputMaker>()) {
278 prop->add_flag(IMPURE);
279 break;
280 }
281 }
282
283 auto cond_opr = m_desc->loop_cond_manager().var().node()->owner_opr();
284
285 // add static infer deps to opr deps
286 auto extend = [&](const cg::static_infer::DepVal& deps) {
287 using namespace cg::static_infer;
288 using NDT = NodeProp::DepType;
289
290 for (auto&& i : deps) {
291 if (i.dest == m_desc->get_counter_var().node())
292 continue;
293
294 auto dt = i.type == DepType::SHAPE ? NDT::SHAPE : NDT::HOST_VALUE;
295 auto opr = i.dest->owner_opr();
296 if (opr->same_type<InputMaker>()) {
297 prop->add_dep_type(opr->cast_final<InputMaker>().orig_var(), dt);
298 }
299 }
300 };
301
302 extend(m_desc->compile()->get_rt_static_source_deps());
303
304 auto setup_static_infer = [&]() {
305 if (cond_opr->dyn_typeinfo() != opr::Elemwise::typeinfo() ||
306 cond_opr->input().size() != 2)
307 return;
308
309 auto mode = cond_opr->cast_final<opr::Elemwise>().param().mode;
310 using Mode = opr::Elemwise::Mode;
311 if (mode != Mode::LT && mode != Mode::LEQ)
312 return;
313 {
314 // check whether is the form counter < X
315 auto inp0 = cond_opr->input(0), cnt = m_desc->get_counter_var().node();
316 if (inp0 != cnt) {
317 auto inp0_opr = inp0->owner_opr();
318 if (inp0_opr->dyn_typeinfo() != opr::TypeCvt::typeinfo())
319 return;
320 inp0 = inp0_opr->input(0);
321 if (inp0 != cnt)
322 return;
323 }
324 }
325 auto cnt_end = cond_opr->input(1);
326 if (!cg::is_static_var_value(cnt_end))
327 return;
328

Callers

nothing calls this directly

Calls 15

is_static_var_valueFunction · 0.85
maxFunction · 0.85
get_counter_varMethod · 0.80
do_make_node_propFunction · 0.70
ceilFunction · 0.50
getMethod · 0.45
containMethod · 0.45
owner_oprMethod · 0.45
nodeMethod · 0.45
varMethod · 0.45

Tested by

no test coverage detected