This test ensures that the codegen path doesn't round up literals, otherwise there are accuracy differences compared to ref. The values being passed in are 0.5 * (1/0.00787402), and after rounding must equal 63, not 64.
| 55 | // The values being passed in are 0.5 * (1/0.00787402), |
| 56 | // and after rounding must equal 63, not 64. |
| 57 | TEST_CASE(mul_literal_round_test) |
| 58 | { |
| 59 | |
| 60 | migraphx::program p; |
| 61 | auto* mm = p.get_main_module(); |
| 62 | migraphx::shape s0{migraphx::shape::float_type, {1}}; |
| 63 | auto l0 = mm->add_parameter("a", s0); |
| 64 | auto l1 = mm->add_literal(1 / 0.00787402f); |
| 65 | |
| 66 | auto mul = mm->add_instruction(migraphx::make_op("mul"), l0, l1); |
| 67 | auto round = mm->add_instruction(migraphx::make_op("nearbyint"), mul); |
| 68 | |
| 69 | mm->add_return({round}); |
| 70 | |
| 71 | migraphx::parameter_map m; |
| 72 | std::vector<float> a = {0.5f}; |
| 73 | |
| 74 | m["a"] = migraphx::argument{s0, a.data()}; |
| 75 | std::vector<float> ref_result; |
| 76 | migraphx::target ref_t = migraphx::make_target("ref"); |
| 77 | run_prog(p, ref_t, m, ref_result); |
| 78 | |
| 79 | std::vector<float> gpu_result; |
| 80 | migraphx::target gpu_t = migraphx::make_target("gpu"); |
| 81 | run_prog(p, gpu_t, m, gpu_result); |
| 82 | |
| 83 | EXPECT(migraphx::verify::verify_rms_range(gpu_result, ref_result)); |
| 84 | } |
| 85 | |
| 86 | int main(int argc, const char* argv[]) { test::run(argc, argv); } |
nothing calls this directly
no test coverage detected