| 32 | #include <test.hpp> |
| 33 | |
| 34 | TEST_CASE(add_broadcast_test) |
| 35 | { |
| 36 | migraphx::program p; |
| 37 | auto* mm = p.get_main_module(); |
| 38 | migraphx::shape a_shape{migraphx::shape::float_type, {2, 2, 3}}; |
| 39 | std::vector<float> a_data{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; |
| 40 | migraphx::shape b_shape{migraphx::shape::float_type, {2, 2}}; |
| 41 | std::vector<float> b_data{0, -1, -2, -3}; |
| 42 | uint64_t axis = 0; |
| 43 | auto l1 = mm->add_literal(migraphx::literal{a_shape, a_data}); |
| 44 | auto l2 = mm->add_literal(migraphx::literal{b_shape, b_data}); |
| 45 | auto l3 = mm->add_instruction( |
| 46 | migraphx::make_op("broadcast", {{"axis", axis}, {"out_lens", l1->get_shape().lens()}}), l2); |
| 47 | mm->add_instruction(migraphx::make_op("add"), l1, l3); |
| 48 | p.compile(migraphx::make_target("ref")); |
| 49 | auto result = p.eval({}).back(); |
| 50 | EXPECT(result.get_shape().packed()); |
| 51 | std::vector<float> results_vector(12); |
| 52 | result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); |
| 53 | std::vector<float> gold = {0, 1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8}; |
| 54 | EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); |
| 55 | } |
| 56 | |
| 57 | TEST_CASE(add_multibroadcast_test) |
| 58 | { |
nothing calls this directly
no test coverage detected