| 256 | } |
| 257 | |
| 258 | int main(int argc, char **argv) { |
| 259 | // usage: neural_network_xxx (device) (console on/off) (percentage |
| 260 | // training/test set) (f32|f16) |
| 261 | int device = argc > 1 ? atoi(argv[1]) : 0; |
| 262 | bool console = argc > 2 ? argv[2][0] == '-' : false; |
| 263 | int perc = argc > 3 ? atoi(argv[3]) : 60; |
| 264 | if (perc < 0 || perc > 100) { |
| 265 | std::cerr << "Bad perc arg: " << perc << std::endl; |
| 266 | return EXIT_FAILURE; |
| 267 | } |
| 268 | std::string dts = argc > 4 ? argv[4] : "f32"; |
| 269 | dtype dt = f32; |
| 270 | if (dts == "f16") |
| 271 | dt = f16; |
| 272 | else if (dts != "f32") { |
| 273 | std::cerr << "Unsupported datatype " << dts << ". Supported: f32 or f16" |
| 274 | << std::endl; |
| 275 | return EXIT_FAILURE; |
| 276 | } |
| 277 | |
| 278 | if (dts == "f16" && !af::isHalfAvailable(device)) { |
| 279 | std::cerr << "Half not available for device " << device << std::endl; |
| 280 | return EXIT_FAILURE; |
| 281 | } |
| 282 | |
| 283 | try { |
| 284 | af::setDevice(device); |
| 285 | af::info(); |
| 286 | return ann_demo(console, perc, dt); |
| 287 | } catch (af::exception &ae) { std::cerr << ae.what() << std::endl; } |
| 288 | |
| 289 | return 0; |
| 290 | } |
nothing calls this directly
no test coverage detected