| 119 | } |
| 120 | |
| 121 | void 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 | |
| 157 | flatbuffers::Offset<fbs::Metadata> GraphDumperOSS::build_metadata( |
| 158 | const Metadata& metadata) { |
nothing calls this directly
no test coverage detected