MCPcopy Create free account
hub / github.com/alibaba/MNN / _splitSubModuleForShapeConst

Function _splitSubModuleForShapeConst

tools/cpp/compilefornpu.cpp:597–629  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

595 return res;
596}
597static std::vector<SubModuleInfo> _splitSubModuleForShapeConst(const std::vector<SubModuleInfo>& origin, const Net* net, std::shared_ptr<Schedule::ScheduleInfo> sharedConst) {
598 std::vector<SubModuleInfo> res;
599 for (auto& m : origin) {
600 if (m.isBreak) {
601 res.emplace_back(std::move(m));
602 continue;
603 }
604 auto breakIndexes = _findBreakIndex(m, net, sharedConst);
605 if (breakIndexes.size() > 0) {
606 int current = 0;
607 for (auto breakIndex : breakIndexes) {
608 // Split
609 if (breakIndex > current) {
610 SubModuleInfo m0;
611 m0.opList.insert(m0.opList.begin(), m.opList.begin() + current, m.opList.begin() + breakIndex);
612 res.emplace_back(std::move(m0));
613 }
614 SubModuleInfo m1;
615 m1.opList = {m.opList[breakIndex]};
616 res.emplace_back(std::move(m1));
617 current = breakIndex + 1;
618 }
619 if (current < m.opList.size()) {
620 SubModuleInfo m2;
621 m2.opList.insert(m2.opList.begin(), m.opList.begin() + current, m.opList.end());
622 res.emplace_back(std::move(m2));
623 }
624 } else {
625 res.emplace_back(std::move(m));
626 }
627 }
628 return res;
629}
630
631static bool _needSplitNet(const Net* net, const std::set<int>& inputIndexes, const std::set<int>& outputIndexes) {
632 auto selectOps = _collectNeededOps(net, inputIndexes, outputIndexes);

Callers 1

_createSubModuleInfoFunction · 0.70

Calls 5

_findBreakIndexFunction · 0.70
sizeMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected