| 620 | }; |
| 621 | |
| 622 | static Module* _createSubModule(std::shared_ptr<BufferStorage> bufferStorage, const SubModuleInfo& info, const std::map<std::string, SubGraph>& subs, std::shared_ptr<Schedule::ScheduleInfo> sharedConst, const Module::Config& config, const ModuleRuntimeConfig& runtimeConfig) { |
| 623 | auto net = flatbuffers::GetRoot<Net>(bufferStorage->buffer()); |
| 624 | if (1 == info.opList.size()) { |
| 625 | auto op = net->oplists()->GetAs<Op>(info.opList[0]); |
| 626 | if (OpType_If == op->type()) { |
| 627 | return IfModule::create(op, subs); |
| 628 | } |
| 629 | if (OpType_While == op->type() && op->main_type() != OpParameter_LoopParam) { |
| 630 | return WhileModule::create(op, subs); |
| 631 | } |
| 632 | if (OpType_NonMaxSuppressionV2 == op->type()) { |
| 633 | return NMSModule::create(op); |
| 634 | } |
| 635 | if (OpType_MoE == op->type()) { |
| 636 | return MoEModule::create(op, subs, runtimeConfig.rt, config); |
| 637 | } |
| 638 | // MNN_ASSERT(false); |
| 639 | } |
| 640 | Schedule::ScheduleInfo scheduleInfo; |
| 641 | scheduleInfo.externalWeightPath = runtimeConfig.externalFile; |
| 642 | scheduleInfo.defaultBackend = sharedConst->defaultBackend; |
| 643 | scheduleInfo.constReplaceBackend = sharedConst->constReplaceBackend; |
| 644 | scheduleInfo.allTensors = sharedConst->allTensors; |
| 645 | scheduleInfo.validForResize = initTensors(scheduleInfo.allTensors, net, info.opList.data(), info.opList.size()); |
| 646 | std::vector<Schedule::OpCacheInfo> oplists; |
| 647 | std::vector<const Op*> ops; |
| 648 | ops.reserve(info.opList.size()); |
| 649 | for (auto opIndex : info.opList) { |
| 650 | ops.emplace_back(net->oplists()->GetAs<Op>(opIndex)); |
| 651 | } |
| 652 | initPipelineInfosFromOps(oplists, ops, scheduleInfo.allTensors); |
| 653 | int breakIndex = GeometryComputerUtils::buildConstantTensors(oplists); |
| 654 | if (breakIndex >= 0) { |
| 655 | scheduleInfo.needInputContentForShape = true; |
| 656 | } |
| 657 | auto rt = runtimeConfig.rt; |
| 658 | auto modes = runtimeConfig.modes; |
| 659 | Schedule::BackendCache bnCache; |
| 660 | Backend::Info compute = runtimeConfig.compute; |
| 661 | if (nullptr != runtimeConfig.userConfig) { |
| 662 | bnCache.config = *runtimeConfig.userConfig; |
| 663 | compute.user = &bnCache.config; |
| 664 | } else { |
| 665 | compute.user = nullptr; |
| 666 | } |
| 667 | bnCache.info = std::move(compute); |
| 668 | bnCache.needComputeGeometry = runtimeConfig.needGeometry; |
| 669 | |
| 670 | scheduleInfo.pipelineInfo.emplace_back(std::make_pair(std::move(bnCache), std::move(oplists))); |
| 671 | |
| 672 | std::vector<std::shared_ptr<BufferStorage>> buffers = {bufferStorage}; |
| 673 | |
| 674 | return new StaticModule(info.inputs, info.outputs, std::move(buffers), std::move(scheduleInfo), sharedConst, std::move(modes), std::move(rt), config); |
| 675 | } |
| 676 | |
| 677 | Module* PipelineModule::load(const std::vector<std::string>& inputs, const std::vector<std::string>& outputs, const uint8_t* buffer, size_t length, const std::shared_ptr<MNN::Express::Executor::RuntimeManager> rtMgr, const Module::Config* config) { |
| 678 | // Create Subgraph |
no test coverage detected