| 109 | } |
| 110 | |
| 111 | static std::vector<argument> run_target(program p, |
| 112 | const target& t, |
| 113 | const compile_options& options, |
| 114 | const verify_options& vo, |
| 115 | const parameter_map& inputs) |
| 116 | { |
| 117 | if(vo.compiled_model.empty()) |
| 118 | { |
| 119 | if(vo.quantize == precision::fp16) |
| 120 | { |
| 121 | quantize_fp16(p); |
| 122 | } |
| 123 | if(vo.quantize == precision::bf16) |
| 124 | { |
| 125 | quantize_bf16(p); |
| 126 | } |
| 127 | p.compile(t, options); |
| 128 | } |
| 129 | else |
| 130 | { |
| 131 | p = load(vo.compiled_model); |
| 132 | } |
| 133 | |
| 134 | parameter_map m; |
| 135 | for(auto&& x : p.get_parameter_shapes()) |
| 136 | { |
| 137 | auto arg = inputs.count(x.first) == 0 ? generate_argument(x.second) : inputs.at(x.first); |
| 138 | m[x.first] = options.offload_copy ? arg : t.copy_to(arg); |
| 139 | } |
| 140 | auto gpu_out = p.eval(m); |
| 141 | std::vector<argument> output(gpu_out.size()); |
| 142 | std::cout << p << std::endl; |
| 143 | std::transform(gpu_out.begin(), gpu_out.end(), output.begin(), [&](auto& argu) { |
| 144 | return options.offload_copy ? argu : t.copy_from(argu); |
| 145 | }); |
| 146 | return output; |
| 147 | } |
| 148 | |
| 149 | bool verify_program(const std::string& name, |
| 150 | const program& p, |
no test coverage detected