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

Function _findBreakIndex

express/module/PipelineModule.cpp:407–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

405}
406
407static std::vector<int> _findBreakIndex(const SubModuleInfo& info, const Net* net, std::shared_ptr<Schedule::ScheduleInfo> sharedConst) {
408 // 0: not used, 1: const, 2: output
409 std::vector<uint8_t> constMask(sharedConst->allTensors.size(), 0);
410 for (int i=0; i<sharedConst->allTensors.size(); ++i) {
411 if(sharedConst->allTensors[i].get() != nullptr) {
412 constMask[i] = 1;
413 }
414 }
415 for (int v = 0; v < info.opList.size(); ++v) {
416 auto op = net->oplists()->GetAs<Op>(info.opList[v]);
417 if (nullptr == op->outputIndexes()) {
418 continue;
419 }
420 bool isConst = true;
421 if (nullptr != op->inputIndexes()) {
422 for (int i=0; i<op->inputIndexes()->size(); ++i) {
423 auto index = op->inputIndexes()->data()[i];
424 if (constMask[index]) {
425 continue;
426 }
427 if (OpCommonUtils::opNeedContent(op, i)) {
428 isConst = false;
429 break;
430 }
431 }
432 }
433 if (isConst) {
434 for (int i=0; i<op->outputIndexes()->size(); ++i) {
435 auto index = op->outputIndexes()->data()[i];
436 constMask[index] = 1;
437 }
438 }
439 }
440 std::vector<int> res;
441 // Check Break Index
442 for (int v = 0; v < info.opList.size(); ++v) {
443 auto op = net->oplists()->GetAs<Op>(info.opList[v]);
444 if (nullptr == op->outputIndexes() || nullptr == op->inputIndexes()) {
445 continue;
446 }
447 int inputNum = op->inputIndexes()->size();
448 auto dims = SizeComputer::needInputContent(op, inputNum);
449 for (auto index : dims) {
450 if (index < inputNum) {
451 if (constMask[op->inputIndexes()->data()[index]] != 1) {
452 res.emplace_back(v);
453 break;
454 }
455 }
456 }
457 }
458 return res;
459}
460static std::vector<SubModuleInfo> _splitSubModuleForShapeConst(const std::vector<SubModuleInfo>& origin, const Net* net, std::shared_ptr<Schedule::ScheduleInfo> sharedConst) {
461 std::vector<SubModuleInfo> res;
462 for (auto& m : origin) {

Callers 1

Calls 3

sizeMethod · 0.45
getMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected