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

Method call_with_opr

src/gopt/impl/framework.cpp:426–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424}
425
426void OptState::call_with_opr(
427 OperatorNodeBase* opr, thin_function<void(void)> func,
428 OprPropertyFlag opr_property_flag) {
429 auto src_opr = cg::get_opr_root_source_opr(opr);
430 auto opr_priority = opr->node_prop().attribute().priority;
431 auto stream_prop_type = m_comp_node_opt.stream_prop_type(opr->output(0));
432 ThinHashMap<OperatorNodeBase*, OprPropertyFlag> oprs_inserted;
433
434 auto swap_properties =
435 [&, need_src_opr = opr_property_flag & OprPropertyFlag::SOURCE_OPR,
436 need_priority = opr_property_flag & OprPropertyFlag::PRIORITY] {
437 if (need_src_opr) {
438 std::swap(m_cur_iter_src_opr, src_opr);
439 }
440 if (need_priority) {
441 std::swap(m_cur_iter_opr_priority, opr_priority);
442 }
443 std::swap(m_cur_iter_opr_stream_prop_type, stream_prop_type);
444 std::swap(m_opr_property_flag, opr_property_flag);
445 std::swap(m_oprs_inserted, oprs_inserted);
446 };
447 MGB_TRY {
448 swap_properties();
449 func();
450 }
451 MGB_FINALLY({ swap_properties(); });
452}
453

Callers 7

update_graphMethod · 0.80
inference.cppFile · 0.80
applyMethod · 0.80
applyMethod · 0.80
on_oprMethod · 0.80
on_opr_visit_finishedMethod · 0.80
update_graphMethod · 0.80

Calls 5

swapFunction · 0.85
funcFunction · 0.50
attributeMethod · 0.45
stream_prop_typeMethod · 0.45
outputMethod · 0.45

Tested by

no test coverage detected