| 30 | static std::string gCacheDir = "res"; |
| 31 | static MNNForwardType gNPUType = MNN_FORWARD_NN; |
| 32 | static bool initConstTensorsNoAlloc(std::vector<std::shared_ptr<Tensor>>& tensors, const Net* net) { |
| 33 | bool valid = true; |
| 34 | tensors.resize(net->tensorName()->size()); |
| 35 | // Set up const |
| 36 | for (int opIndex = 0; opIndex < net->oplists()->size(); ++opIndex) { |
| 37 | auto op = net->oplists()->GetAs<Op>(opIndex); |
| 38 | if (OpType_Const == op->type() || OpType_TrainableParam == op->type()) { |
| 39 | MNN_ASSERT(nullptr != op->outputIndexes()); |
| 40 | auto index = op->outputIndexes()->data()[0]; |
| 41 | tensors[index].reset(new Tensor); |
| 42 | TensorUtils::getDescribe(tensors[index].get())->index = index; |
| 43 | auto output = tensors[index].get(); |
| 44 | if (op->type() == OpType_TrainableParam) { |
| 45 | TensorUtils::getDescribe(output)->usage = Tensor::InsideDescribe::TRAINABLE; |
| 46 | } |
| 47 | TensorUtils::getDescribe(output)->usage = Tensor::InsideDescribe::CONSTANT; |
| 48 | TensorUtils::getDescribe(output)->isMutable = false; |
| 49 | } |
| 50 | } |
| 51 | return true; |
| 52 | } |
| 53 | struct SubModuleInfo { |
| 54 | std::vector<int> opList; |
| 55 | std::vector<int> inputs;; |