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

Method init_oprs_to_dump

src/serialization/impl/serializer_oss.cpp:121–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121void GraphDumperOSS::init_oprs_to_dump(const SymbolVarArray& endpoints) {
122 m_oprs_to_dump.clear();
123 m_var2id.clear();
124
125 // iterate oprs to init m_var2id
126 size_t next_id = 0;
127 auto on_opr = [&](cg::OperatorNodeBase* opr) {
128 if (should_remove_in_dump(opr)) {
129 mgb_assert(opr->input().size() == 1);
130 // Copy input ID to output
131 auto id = m_var2id.at(opr->input(0));
132 for (auto i : opr->output())
133 m_var2id[i] = id;
134 } else {
135 auto registry = OprRegistry::find_by_type(opr->dyn_typeinfo());
136 if (!registry || !registry->dumper) {
137 mgb_throw(
138 cg::OperatorNodeExcExtraInfo::ExcMaker{opr}.make<MegBrainError>,
139 "serialization as FlatBuffers is not supported for "
140 "operator %s",
141 opr->dyn_typeinfo()->name);
142 }
143 m_oprs_to_dump.emplace_back(opr, registry);
144 for (auto i : opr->output()) {
145 if (!i->contain_flag(VarNode::Flag::VOLATILE_CONTENT)) {
146 m_var2id[i] = next_id++;
147 }
148 }
149 }
150 };
151 cg::DepOprIter dep_opr_iter{on_opr};
152 for (auto i : endpoints) {
153 dep_opr_iter.add(i.node()->owner_opr());
154 }
155}
156
157flatbuffers::Offset<fbs::Metadata> GraphDumperOSS::build_metadata(
158 const Metadata& metadata) {

Callers

nothing calls this directly

Calls 10

emplace_backMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
inputMethod · 0.45
atMethod · 0.45
outputMethod · 0.45
contain_flagMethod · 0.45
addMethod · 0.45
owner_oprMethod · 0.45
nodeMethod · 0.45

Tested by

no test coverage detected