| 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 |
| 679 | auto net = GetNet(buffer); |
| 680 | if (nullptr == net->oplists() || nullptr == net->tensorName()) { |
| 681 | MNN_ERROR("Invalid net, for null oplist or tensorName\n"); |
| 682 | return nullptr; |
| 683 | } |
| 684 | Module::Config defaultConfig; |
| 685 | if (nullptr == config) { |
| 686 | config = &defaultConfig; |
| 687 | } |
| 688 | auto subGraphs = net->subgraphs(); |
| 689 | if (config->dynamic) { |
| 690 | // TODO: Support subgraph |
| 691 | if (nullptr == subGraphs) { |
| 692 | auto varMap = MNN::Express::Variable::loadMap(buffer, length); |
| 693 | std::vector<MNN::Express::VARP> inputsVar(inputs.size()); |
| 694 | for (int i=0; i<inputs.size(); ++i) { |
| 695 | inputsVar[i] = varMap[inputs[i]]; |
| 696 | } |
| 697 | std::vector<MNN::Express::VARP> outputsVar(outputs.size()); |
| 698 | for (int i=0; i<outputs.size(); ++i) { |
| 699 | outputsVar[i] = varMap[outputs[i]]; |
| 700 | } |
| 701 | return extract(inputsVar, outputsVar, false); |
| 702 | } else { |
| 703 | MNN_ERROR("Don't support subgraph for dynamic load, turn back to static load\n"); |
| 704 | } |
| 705 | } |
| 706 | std::map<std::string, SubGraph> subGraphMap; |
| 707 | _createSubGraph(net, rtMgr, config, subGraphMap); |
| 708 | std::shared_ptr<BufferStorage> bufferStorage(new BufferStorage); |
| 709 | bufferStorage->storage = new uint8_t[length]; |
| 710 | ::memcpy(bufferStorage->storage, buffer, length); |
| 711 | bufferStorage->offset = 0; |
| 712 | bufferStorage->allocated_size = length; |
| 713 | return load(inputs, outputs, bufferStorage, rtMgr, config, subGraphMap); |
| 714 | } |
| 715 | |
| 716 | Module* PipelineModule::load(const std::vector<std::string>& inputs, const std::vector<std::string>& outputs, std::shared_ptr<BufferStorage> bufferStorage, std::shared_ptr<MNN::Express::Executor::RuntimeManager> rtMgr, const Module::Config* config, std::map<std::string, SubGraph>& subGraphMap) { |
| 717 | MNN_ASSERT(nullptr != rtMgr); |
nothing calls this directly
no test coverage detected