| 31 | #include <test.hpp> |
| 32 | |
| 33 | TEST_CASE(dequantizelinear_unsigned_int8) |
| 34 | |
| 35 | { /*uint8*/ |
| 36 | migraphx::shape xs{migraphx::shape::uint8_type, {1, 3, 3}}; |
| 37 | std::vector<uint8_t> xv = {0, 1, 2, 5, 10, 50, 100, 150, 250}; |
| 38 | migraphx::shape ss{migraphx::shape::float_type, {1, 3, 3}}; |
| 39 | std::vector<float> sv = {2, 2, 2, 2, 2, 2, 2, 2, 2}; |
| 40 | migraphx::shape zs{migraphx::shape::uint8_type, {1, 3, 3}}; |
| 41 | std::vector<uint8_t> zv = {0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 42 | auto create_program = [&]() { |
| 43 | migraphx::program p; |
| 44 | auto* mm = p.get_main_module(); |
| 45 | auto x = mm->add_literal(xs, xv); |
| 46 | auto s = mm->add_literal(ss, sv); |
| 47 | auto z = mm->add_literal(zs, zv); |
| 48 | mm->add_instruction(migraphx::make_op("dequantizelinear"), x, s, z); |
| 49 | return p; |
| 50 | }; |
| 51 | |
| 52 | migraphx::program p1 = create_program(); |
| 53 | p1.compile(migraphx::make_target("ref")); |
| 54 | auto result = p1.eval({}).back(); |
| 55 | std::vector<float> results_vector(9); |
| 56 | result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); |
| 57 | std::vector<float> gold{0, 2, 4, 10, 20, 100, 200, 300, 500}; |
| 58 | EXPECT(results_vector == gold); |
| 59 | } |
| 60 | |
| 61 | TEST_CASE(dequantizelinear_signed_int8) |
| 62 | { /*int8*/ |
nothing calls this directly
no test coverage detected