| 94 | } |
| 95 | |
| 96 | int main(int argc, char *argv[]) { |
| 97 | if (argc < 5) { |
| 98 | MNN_ERROR("Usage: ./SequenceModuleTest.out ${test.mnn} [forwardType] [shapeMutable] ${testTime} ${Dir} ${Dir1} ......\n"); |
| 99 | return 0; |
| 100 | } |
| 101 | #ifdef OPEN_TRACE |
| 102 | _initTensorStatic(); |
| 103 | #endif |
| 104 | |
| 105 | std::string modelName = argv[1]; |
| 106 | auto type = (MNNForwardType)atoi(argv[2]); |
| 107 | int numberThread = atoi(argv[3]); |
| 108 | int testTime = atoi(argv[4]); |
| 109 | int offset = 5; |
| 110 | MNN_PRINT("Test %s, type = %d\n", modelName.c_str(), type); |
| 111 | // create session |
| 112 | MNN::ScheduleConfig config; |
| 113 | config.type = type; |
| 114 | /*modeNum means gpuMode for GPU usage, Or means numThread for CPU usage.*/ |
| 115 | // If type not fount, let it failed |
| 116 | config.backupType = type; |
| 117 | config.numThread = numberThread; |
| 118 | BackendConfig backendConfig; |
| 119 | #ifdef OPEN_TRACE |
| 120 | backendConfig.precision = MNN::BackendConfig::Precision_High; |
| 121 | #endif |
| 122 | config.backendConfig = &backendConfig; |
| 123 | |
| 124 | MNN::Express::Module::Config mConfig; |
| 125 | mConfig.shapeMutable = true; |
| 126 | mConfig.rearrange = true; |
| 127 | std::shared_ptr<Executor::RuntimeManager> rtmgr(Executor::RuntimeManager::createRuntimeManager(config)); |
| 128 | #ifdef OPEN_TRACE |
| 129 | rtmgr->setMode(MNN::Interpreter::Session_Debug); |
| 130 | #endif |
| 131 | std::shared_ptr<Module> net; |
| 132 | for (int index = offset; index < argc; ++index) { |
| 133 | std::string directName = argv[index]; |
| 134 | rapidjson::Document document; |
| 135 | std::map<std::string, float> inputInfo; |
| 136 | std::map<std::string, std::vector<int>> inputShape; |
| 137 | std::vector<std::string> inputNames; |
| 138 | std::vector<std::string> outputNames; |
| 139 | std::ostringstream jsonNameOs; |
| 140 | jsonNameOs << argv[index] << "/input.json"; |
| 141 | std::ifstream fileNames(jsonNameOs.str().c_str()); |
| 142 | std::ostringstream output; |
| 143 | output << fileNames.rdbuf(); |
| 144 | auto outputStr = output.str(); |
| 145 | document.Parse(outputStr.c_str()); |
| 146 | if (document.HasParseError()) { |
| 147 | MNN_ERROR("Invalid json\n"); |
| 148 | continue; |
| 149 | } |
| 150 | if (document.HasMember("inputs")) { |
| 151 | auto inputsInfo = document["inputs"].GetArray(); |
| 152 | for (auto iter = inputsInfo.begin(); iter !=inputsInfo.end(); iter++) { |
| 153 | auto obj = iter->GetObject(); |
nothing calls this directly
no test coverage detected