| 90 | |
| 91 | using namespace MNN::Express; |
| 92 | int main(int argc, const char* argv[]) { |
| 93 | if (argc < 4) { |
| 94 | MNN_PRINT("Usage: ./testModel_expr.out model.mnn input.mnn output.mnn [type] [tolerance] [precision]\n"); |
| 95 | return 0; |
| 96 | } |
| 97 | MNN::ScheduleConfig sdConfig; |
| 98 | auto rtMgr = std::shared_ptr<MNN::Express::Executor::RuntimeManager>(MNN::Express::Executor::RuntimeManager::createRuntimeManager(sdConfig), MNN::Express::Executor::RuntimeManager::destroy); |
| 99 | //#define TEST_DEBUG |
| 100 | #ifdef TEST_DEBUG |
| 101 | _initTensorStatic(); |
| 102 | //_initDebug(); |
| 103 | rtMgr->setMode(MNN::Interpreter::Session_Debug); |
| 104 | #endif |
| 105 | // check given & expect |
| 106 | const char* modelPath = argv[1]; |
| 107 | const char* inputName = argv[2]; |
| 108 | const char* outputName = argv[3]; |
| 109 | MNN_PRINT("Testing model %s, input: %s, output: %s\n", modelPath, inputName, outputName); |
| 110 | |
| 111 | // create net |
| 112 | auto type = MNN_FORWARD_CPU; |
| 113 | if (argc > 4) { |
| 114 | type = (MNNForwardType)stringConvert<int>(argv[4]); |
| 115 | } |
| 116 | auto tolerance = 0.1f; |
| 117 | if (argc > 5) { |
| 118 | tolerance = stringConvert<float>(argv[5]); |
| 119 | } |
| 120 | MNN::BackendConfig::PrecisionMode precision = MNN::BackendConfig::Precision_High; |
| 121 | if (argc > 6) { |
| 122 | precision = (MNN::BackendConfig::PrecisionMode)stringConvert<int>(argv[6]); |
| 123 | } |
| 124 | auto inputVars = Variable::load(inputName); |
| 125 | auto outputVars = Variable::load(outputName); |
| 126 | std::vector<std::string> inputNames; |
| 127 | std::vector<std::string> outputNames; |
| 128 | for (auto v : inputVars) { |
| 129 | inputNames.emplace_back(v->name()); |
| 130 | } |
| 131 | for (auto v : outputVars) { |
| 132 | outputNames.emplace_back(v->name()); |
| 133 | } |
| 134 | if (inputVars.empty()) { |
| 135 | MNN_ERROR("Input is Error\n"); |
| 136 | return 0; |
| 137 | } |
| 138 | if (outputVars.empty()) { |
| 139 | MNN_ERROR("Output is Error\n"); |
| 140 | return 0; |
| 141 | } |
| 142 | Module::Config config; |
| 143 | config.rearrange = true; |
| 144 | rtMgr->setHint(MNN::Interpreter::INIT_THREAD_NUMBER, 4); |
| 145 | std::shared_ptr<Module> m(Module::load(inputNames, outputNames, modelPath, rtMgr, &config), [](void* net) { |
| 146 | MNN::Express::Module::destroy((MNN::Express::Module*)net); |
| 147 | }); |
| 148 | if (nullptr == m) { |
| 149 | MNN_ERROR("Model is Error\n"); |
nothing calls this directly
no test coverage detected