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

Method add_dest

src/core/impl/graph/static_infer_impl.cpp:1033–1081  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1031CompSeqManager::~CompSeqManager() noexcept = default;
1032
1033void 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
1083void CompSeqManager::reset_dest(CompSeqExtraInfo& info) {
1084 m_static_first_run = true;

Callers 4

initializeMethod · 0.80
TESTFunction · 0.80
test_merge_oprFunction · 0.80
TESTFunction · 0.80

Calls 10

frontMethod · 0.80
infer_typeMethod · 0.80
is_constMethod · 0.80
emplace_backMethod · 0.80
insertMethod · 0.45
clearMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45
owner_graphMethod · 0.45
tagMethod · 0.45

Tested by 3

TESTFunction · 0.64
test_merge_oprFunction · 0.64
TESTFunction · 0.64