| 1031 | CompSeqManager::~CompSeqManager() noexcept = default; |
| 1032 | |
| 1033 | void CompSeqManager::add_dest(CompSeqExtraInfo& info, TagTraitBase* dest) { |
| 1034 | if (!m_added.insert(dest).second) |
| 1035 | return; |
| 1036 | |
| 1037 | auto&& queue = m_add_dest_queue; |
| 1038 | queue.clear(); |
| 1039 | queue.push_back(dest); |
| 1040 | |
| 1041 | while (!queue.empty()) { |
| 1042 | auto qh = queue.front(); |
| 1043 | queue.pop_front(); |
| 1044 | mgb_assert(qh->tag()->owner_graph() == m_owner_graph); |
| 1045 | |
| 1046 | for (auto i : qh->deps()) { |
| 1047 | if (m_added.insert(i).second) |
| 1048 | queue.push_back(i); |
| 1049 | } |
| 1050 | |
| 1051 | switch (qh->infer_type()) { |
| 1052 | case InferType::CONST: |
| 1053 | if (!qh->is_const()) { |
| 1054 | // shape already updated for qh being const |
| 1055 | m_static_infer_const_needed.emplace_back(qh); |
| 1056 | } |
| 1057 | break; |
| 1058 | case InferType::NO_DESC: |
| 1059 | // record this as a missing input |
| 1060 | if (qh->handler_type() == TagHandlerType::SHAPE) |
| 1061 | info.missing_for_shape.insert(qh->tag()); |
| 1062 | else { |
| 1063 | mgb_assert(qh->handler_type() == TagHandlerType::VALUE); |
| 1064 | info.missing_for_value.insert(qh->tag()); |
| 1065 | } |
| 1066 | break; |
| 1067 | case InferType::RT_STATIC: |
| 1068 | if (qh->deps().empty()) { |
| 1069 | m_static_srcnode.emplace_back(qh); |
| 1070 | } else { |
| 1071 | m_static_mid.emplace_back(qh); |
| 1072 | } |
| 1073 | case InferType::MISSING_INP: |
| 1074 | // its missing inputs have been recorded, and this tag would be |
| 1075 | // inferred on demand when the operator asks for its value |
| 1076 | break; |
| 1077 | default: |
| 1078 | mgb_throw(MegBrainError, "bad infer type"); |
| 1079 | } |
| 1080 | } |
| 1081 | } |
| 1082 | |
| 1083 | void CompSeqManager::reset_dest(CompSeqExtraInfo& info) { |
| 1084 | m_static_first_run = true; |