| 271 | } |
| 272 | |
| 273 | int main(int argc, char* argv[]) |
| 274 | { |
| 275 | DeviceType deviceType = DeviceType::Default; |
| 276 | PhysicalDeviceRef physicalDevice; |
| 277 | std::string run = ".*"; |
| 278 | int numThreads = -1; |
| 279 | int setAffinity = -1; |
| 280 | int verbose = -1; |
| 281 | |
| 282 | try |
| 283 | { |
| 284 | ArgParser args(argc, argv); |
| 285 | while (args.hasNext()) |
| 286 | { |
| 287 | std::string opt = args.getNextOpt(); |
| 288 | if (opt == "d" || opt == "dev" || opt == "device") |
| 289 | { |
| 290 | std::string value = args.getNext(); |
| 291 | if (isdigit(value[0])) |
| 292 | physicalDevice = fromString<int>(value); |
| 293 | else |
| 294 | deviceType = fromString<DeviceType>(value); |
| 295 | } |
| 296 | else if (opt == "r" || opt == "run") |
| 297 | run = args.getNextValue(); |
| 298 | else if (opt == "n") |
| 299 | { |
| 300 | numRuns = args.getNextValue<int>(); |
| 301 | if (numRuns <= 0) |
| 302 | throw std::runtime_error("invalid number of runs"); |
| 303 | } |
| 304 | else if (opt == "s" || opt == "size") |
| 305 | { |
| 306 | width = args.getNextValue<int>(); |
| 307 | height = args.getNextValue<int>(); |
| 308 | if (width < 1 || height < 1) |
| 309 | throw std::runtime_error("invalid image size"); |
| 310 | } |
| 311 | else if (opt == "t" || opt == "type") |
| 312 | { |
| 313 | const auto val = toLower(args.getNextValue()); |
| 314 | if (val == "f" || val == "float" || val == "fp32") |
| 315 | dataType = DataType::Float32; |
| 316 | else if (val == "h" || val == "half" || val == "fp16") |
| 317 | dataType = DataType::Float16; |
| 318 | else |
| 319 | throw std::runtime_error("invalid data type"); |
| 320 | } |
| 321 | else if (opt == "q" || opt == "quality") |
| 322 | { |
| 323 | const auto val = toLower(args.getNextValue()); |
| 324 | if (val == "default") |
| 325 | quality = Quality::Default; |
| 326 | else if (val == "h" || val == "high") |
| 327 | quality = Quality::High; |
| 328 | else if (val == "b" || val == "balanced") |
| 329 | quality = Quality::Balanced; |
| 330 | else if (val == "f" || val == "fast") |
nothing calls this directly
no test coverage detected