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

Method insert_pre

src/core/impl/graph/graph_opt.cpp:12–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10constexpr size_t MAX_CONST_FOLDING_SIZE = 1024;
11
12OperatorNodeBase* GraphOptimizer::insert_pre(OperatorNodeBase* opr) {
13 auto hash = opr->hash();
14 auto iter = m_opr_hash_list.find(hash);
15 if (iter != m_opr_hash_list.end()) {
16 for (auto i : iter->second) {
17 if (i->is_same(*opr)) {
18 if (opr->owner_graph()->options().log_level >= 2) {
19 mgb_log_debug(
20 "opr %s{%s} already exists as %s, "
21 "do not insert again",
22 opr->cname(), opr->dyn_typeinfo()->name, i->cname());
23 }
24 mgb_assert(i->output().size() == opr->output().size());
25 if (opr->usable_output().size() == 1) {
26 auto c = m_const_map.find(i->output(0));
27 if (c != m_const_map.end())
28 return c->second;
29 }
30 return i;
31 }
32 }
33 }
34 return nullptr;
35}
36
37OperatorNodeBase* GraphOptimizer::insert_post(OperatorNodeBase* opr) {
38 bool already_inserted = false;

Callers 1

cg_impl.cppFile · 0.80

Calls 9

hashMethod · 0.45
findMethod · 0.45
endMethod · 0.45
is_sameMethod · 0.45
owner_graphMethod · 0.45
cnameMethod · 0.45
sizeMethod · 0.45
outputMethod · 0.45
usable_outputMethod · 0.45

Tested by

no test coverage detected