| 163 | } |
| 164 | |
| 165 | void ProfilerPlugin::init_seq(cg::AsyncExecutable* comp_seq) { |
| 166 | mgb_assert(m_opr_dict.empty()); |
| 167 | mgb_assert(m_var_dict.empty()); |
| 168 | comp_seq->iter_opr_seq([this](cg::OperatorNodeBase* opr) { |
| 169 | auto comp_nodes = get_opr_comp_node_set(opr); |
| 170 | mgb_assert(comp_nodes.size() == 1); |
| 171 | register_opr(opr); |
| 172 | for (auto&& input : opr->input()) { |
| 173 | if (m_var_dict.count(input) == 0) { |
| 174 | register_var(input).is_const = true; |
| 175 | } else { |
| 176 | get_var_info(input).ref_cnt++; |
| 177 | } |
| 178 | } |
| 179 | for (auto&& output : opr->output()) { |
| 180 | register_var(output).is_const = false; |
| 181 | } |
| 182 | // TODO: check ref_cnt |
| 183 | return true; |
| 184 | }); |
| 185 | } |
| 186 | |
| 187 | ProfilerPlugin::OprInfo& ProfilerPlugin::register_opr(cg::OperatorNodeBase* opr) { |
| 188 | OprInfo info; |