| 99 | } |
| 100 | |
| 101 | TEST_CASE(dot_reshapes_add) |
| 102 | { |
| 103 | migraphx::shape s{migraphx::shape::float_type, {1, 3, 3}}; |
| 104 | migraphx::program p1; |
| 105 | { |
| 106 | auto* mm = p1.get_main_module(); |
| 107 | auto a = mm->add_parameter("a", s); |
| 108 | auto b = mm->add_parameter("b", s); |
| 109 | auto x = mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {3, 3}}); |
| 110 | auto dot = mm->add_instruction(migraphx::make_op("dot"), a, b); |
| 111 | auto dot_trans = |
| 112 | mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {0, 2, 1}}}), dot); |
| 113 | auto dot_sq = mm->add_instruction(migraphx::make_op("squeeze"), dot_trans); |
| 114 | auto add = add_pointwise(p1, "main:pointwise0", {dot_sq, x}, single_pointwise("add")); |
| 115 | mm->add_return({add}); |
| 116 | } |
| 117 | run_pass(p1); |
| 118 | migraphx::program p2; |
| 119 | { |
| 120 | auto* mm = p2.get_main_module(); |
| 121 | auto a = mm->add_parameter("a", s); |
| 122 | auto b = mm->add_parameter("b", s); |
| 123 | auto x = mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {3, 3}}); |
| 124 | auto fused = |
| 125 | add_mlir(p2, "mlir_main:pointwise0", {a, b, x}, [=](auto* pm, const auto& inputs) { |
| 126 | auto dot = pm->add_instruction(migraphx::make_op("dot"), inputs[0], inputs[1]); |
| 127 | auto dot_trans = pm->add_instruction( |
| 128 | migraphx::make_op("transpose", {{"permutation", {0, 2, 1}}}), dot); |
| 129 | auto dot_rsp = pm->add_instruction(migraphx::make_op("squeeze"), dot_trans); |
| 130 | auto add = pm->add_instruction(migraphx::make_op("add"), dot_rsp, inputs[2]); |
| 131 | return std::make_tuple(dot->get_operator(), add); |
| 132 | }); |
| 133 | mm->add_return({fused}); |
| 134 | } |
| 135 | EXPECT(p1.sort() == p2.sort()); |
| 136 | } |
| 137 | |
| 138 | TEST_CASE(dot_add) |
| 139 | { |
nothing calls this directly
no test coverage detected