| 68 | } |
| 69 | |
| 70 | TEST_CASE(quantizelinear) |
| 71 | { |
| 72 | |
| 73 | migraphx::shape xs{migraphx::shape::float_type, {1, 3, 3}}; |
| 74 | std::vector<float> xv = {-300, 200, 129, 1, 2, 3, 500, 1000, 50}; |
| 75 | migraphx::shape ss{migraphx::shape::float_type, {1, 3, 3}}; |
| 76 | std::vector<float> sv = {2, 2, 2, 2, 2, 2, 2, 2, 2}; |
| 77 | auto create_program = [&]() { |
| 78 | migraphx::program p; |
| 79 | auto* mm = p.get_main_module(); |
| 80 | auto x = mm->add_literal(xs, xv); |
| 81 | auto s = mm->add_literal(ss, sv); |
| 82 | mm->add_instruction(migraphx::make_op("quantizelinear"), x, s); |
| 83 | return p; |
| 84 | }; |
| 85 | |
| 86 | migraphx::program p1 = create_program(); |
| 87 | migraphx::program p2 = create_program(); |
| 88 | |
| 89 | run_pass(*p2.get_main_module()); |
| 90 | EXPECT(eval(p1) == eval(p2)); |
| 91 | EXPECT(any_of(*p1.get_main_module(), &is_quantizelinear)); |
| 92 | EXPECT(none_of(*p2.get_main_module(), &is_quantizelinear)); |
| 93 | // ensure clip literals created in quantized program are scalar |
| 94 | // unless CK workarounds are enabled |
| 95 | if(migraphx::enabled(MIGRAPHX_ENABLE_CK_WORKAROUNDS{})) |
| 96 | EXPECT(none_of(*p2.get_main_module(), &is_clip_scalar)); |
| 97 | else |
| 98 | EXPECT(any_of(*p2.get_main_module(), &is_clip_scalar)); |
| 99 | } |
| 100 | |
| 101 | TEST_CASE(dequantizelinear) |
| 102 | { |
nothing calls this directly
no test coverage detected