| 34 | void read_nth_digit(const int, std::vector<float>&); |
| 35 | |
| 36 | int main(int argc, char** argv) |
| 37 | { |
| 38 | if(argc == 1) |
| 39 | { |
| 40 | std::cout << "Usage: " << argv[0] << " [options]" << std::endl |
| 41 | << "options:" << std::endl |
| 42 | << "\t -c, --cpu Compile for CPU" << std::endl |
| 43 | << "\t -g, --gpu Compile for GPU" << std::endl |
| 44 | << "\t -f, --fp16 FP16 Quantization" << std::endl |
| 45 | << "\t -i, --int8 Int8 Quantization" << std::endl |
| 46 | << "\t --cal Int8 Calibration ON" << std::endl |
| 47 | << "\t -p, --print Print Graph at Each Stage" << std::endl |
| 48 | << std::endl |
| 49 | << std::endl; |
| 50 | } |
| 51 | |
| 52 | char** begin = argv + 1; |
| 53 | char** end = argv + argc; |
| 54 | const bool CPU = (std::find(begin, end, std::string("-c")) != end) or |
| 55 | std::find(begin, end, std::string("--cpu")) != end; |
| 56 | const bool GPU = std::find(begin, end, std::string("-g")) != end or |
| 57 | std::find(begin, end, std::string("--gpu")) != end; |
| 58 | const bool FP16 = std::find(begin, end, std::string("-f")) != end or |
| 59 | std::find(begin, end, std::string("--fp16")) != end; |
| 60 | const bool INT8 = std::find(begin, end, std::string("-i")) != end or |
| 61 | std::find(begin, end, std::string("--int8")) != end; |
| 62 | const bool CALIB = std::find(begin, end, std::string("--cal")) != end; |
| 63 | const bool PRINT = std::find(begin, end, std::string("-p")) != end or |
| 64 | std::find(begin, end, std::string("--print")) != end; |
| 65 | |
| 66 | migraphx::program prog; |
| 67 | migraphx::onnx_options onnx_opts; |
| 68 | prog = parse_onnx("../mnist-8.onnx", onnx_opts); |
| 69 | |
| 70 | std::cout << "Parsing ONNX model..." << std::endl; |
| 71 | if(PRINT) |
| 72 | prog.print(); |
| 73 | std::cout << std::endl; |
| 74 | |
| 75 | std::string target_str; |
| 76 | if(CPU) |
| 77 | target_str = "cpu"; |
| 78 | else if(GPU) |
| 79 | target_str = "gpu"; |
| 80 | else |
| 81 | target_str = "ref"; |
| 82 | migraphx::target targ = migraphx::target(target_str.c_str()); |
| 83 | |
| 84 | if(FP16) |
| 85 | { |
| 86 | migraphx::quantize_fp16(prog); |
| 87 | |
| 88 | std::cout << "Quantizing program for FP16..." << std::endl; |
| 89 | if(PRINT) |
| 90 | prog.print(); |
| 91 | std::cout << std::endl; |
| 92 | } |
| 93 | else if(INT8) |
nothing calls this directly
no test coverage detected