MCPcopy Create free account
hub / github.com/alibaba/MNN / main

Function main

benchmark/benchmarkExprModels.cpp:149–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147};
148
149int main(int argc, const char* argv[]) {
150 std::cout << "MNN Expr Models benchmark" << std::endl;
151 size_t loop = 10;
152 MNNForwardType forward = MNN_FORWARD_CPU;
153 size_t numThread = 4;
154 if (argc <= 1) {
155 _printHelp();
156 return 0;
157 }
158 if (((argc > 1) && (strcmp(argv[1], "help") == 0)) || argc > 5) {
159 _printHelp();
160 return 0;
161 }
162 std::vector<std::string> models;
163 if (((argc > 1) && (strcmp(argv[1], "default") == 0)) || argc > 5) {
164 models = gDefaultModels;
165 } else {
166 models = {argv[1]};
167 }
168
169 if (argc >= 3) {
170 loop = atoi(argv[2]);
171 }
172 if (argc >= 4) {
173 forward = static_cast<MNNForwardType>(atoi(argv[3]));
174 }
175 if (argc >= 5) {
176 numThread = atoi(argv[4]);
177 }
178 std::cout << "Forward type: **" << forwardType(forward) << "** thread=" << numThread << std::endl;
179 ScheduleConfig config;
180 config.type = forward;
181 config.numThread = numThread;
182 BackendConfig bnConfig;
183 bnConfig.precision = BackendConfig::Precision_Low;
184 bnConfig.power = BackendConfig::Power_High;
185 config.backendConfig = &bnConfig;
186
187 std::vector<float> costs;
188
189 // ResNet18 benchmark
190 for (auto model : models) {
191 auto modelArgs = splitArgs(model.c_str(), "_");
192 auto modelType = modelArgs[0];
193 int numClass = atoi(modelArgs[1].c_str());
194 if (modelType == "MobileNetV1") {
195 auto mobileNetWidthType = EnumMobileNetWidthTypeByString(modelArgs[2]);
196 if (mobileNetWidthType < 0) {
197 std::cout << "Not support MobileNetWidthType " << modelArgs[2] << std::endl;
198 std::cout << "Only [1.0, 0.75, 0.5, 0.25] be support" << std::endl;
199 return 1;
200 }
201 auto mobileNetResolutionType = EnumMobileNetResolutionTypeByString(modelArgs[3]);
202 if (mobileNetResolutionType < 0) {
203 std::cout << "Not support MobileNetResolutionType " << modelArgs[3] << std::endl;
204 std::cout << "Only [224, 192, 160, 128] be support" << std::endl;
205 return 1;
206 }

Callers

nothing calls this directly

Calls 15

_printHelpFunction · 0.85
splitArgsFunction · 0.85
runNetFunction · 0.85
mobileNetV1ExprFunction · 0.85
mobileNetV2ExprFunction · 0.85
EnumResNetTypeByStringFunction · 0.85
resNetExprFunction · 0.85
googLeNetExprFunction · 0.85
squeezeNetExprFunction · 0.85
shuffleNetExprFunction · 0.85

Tested by

no test coverage detected