Unverified Commit b1d3c954 authored by Chris Austen's avatar Chris Austen Committed by GitHub
Browse files

Rocm55 neg param fix (#1566)

test change to neg unit ops to prevent on use for param
change to insert instruction, add and modify existing tes
Equivalent to #1562
parent ec5d6835
...@@ -975,7 +975,7 @@ struct find_neg_unit_ops ...@@ -975,7 +975,7 @@ struct find_neg_unit_ops
auto ins = r.result; auto ins = r.result;
auto c_in = r.instructions["x"]; auto c_in = r.instructions["x"];
auto neg = m.add_instruction(make_op("neg"), c_in); auto neg = m.insert_instruction(ins, make_op("neg"), c_in);
m.replace_instruction(ins, neg); m.replace_instruction(ins, neg);
} }
}; };
......
...@@ -1041,16 +1041,18 @@ TEST_CASE(simplify_neg_unit_mult_const) ...@@ -1041,16 +1041,18 @@ TEST_CASE(simplify_neg_unit_mult_const)
{ {
migraphx::module m1; migraphx::module m1;
{ {
auto x = m1.add_parameter("x", {migraphx::shape::int32_type, {1}}); auto x = m1.add_parameter("x", {migraphx::shape::int32_type, {1, 6}});
auto unit = m1.add_literal(-1); auto unit = m1.add_literal(
migraphx::literal{{migraphx::shape::int32_type, {1, 6}}, std::vector<int>(6, -1)});
m1.add_instruction(migraphx::make_op("mul"), x, unit); m1.add_instruction(migraphx::make_op("mul"), x, unit);
} }
run_pass(m1); run_pass(m1);
migraphx::module m2; migraphx::module m2;
{ {
auto x = m2.add_parameter("x", {migraphx::shape::int32_type, {1}}); auto x = m2.add_parameter("x", {migraphx::shape::int32_type, {1, 6}});
m2.add_instruction(migraphx::make_op("neg"), x); auto x2 = m2.add_instruction(migraphx::make_op("neg"), x);
m2.add_instruction(migraphx::make_op("identity"), x2);
} }
EXPECT((m1 == m2)); EXPECT((m1 == m2));
...@@ -1069,7 +1071,29 @@ TEST_CASE(simplify_neg_unit_mult_const2) ...@@ -1069,7 +1071,29 @@ TEST_CASE(simplify_neg_unit_mult_const2)
migraphx::module m2; migraphx::module m2;
{ {
auto x = m2.add_parameter("x", {migraphx::shape::int32_type, {1}}); auto x = m2.add_parameter("x", {migraphx::shape::int32_type, {1}});
m2.add_instruction(migraphx::make_op("neg"), x); auto x2 = m2.add_instruction(migraphx::make_op("neg"), x);
m2.add_instruction(migraphx::make_op("identity"), x2);
}
EXPECT((m1 == m2));
}
TEST_CASE(simplify_neg_unit_mult_const_add)
{
migraphx::module m1;
{
auto unit = m1.add_literal(-1);
auto x = m1.add_parameter("x", {migraphx::shape::int32_type, {1}});
auto x2 = m1.add_instruction(migraphx::make_op("mul"), unit, x);
m1.add_instruction(migraphx::make_op("add"), x2, x2);
}
run_pass(m1);
migraphx::module m2;
{
auto x = m2.add_parameter("x", {migraphx::shape::int32_type, {1}});
auto x2 = m2.add_instruction(migraphx::make_op("neg"), x);
m2.add_instruction(migraphx::make_op("add"), x2, x2);
} }
EXPECT((m1 == m2)); EXPECT((m1 == m2));
...@@ -1092,7 +1116,8 @@ TEST_CASE(simplify_neg_unit_mul_const_vec) ...@@ -1092,7 +1116,8 @@ TEST_CASE(simplify_neg_unit_mul_const_vec)
migraphx::module m2; migraphx::module m2;
{ {
auto x = m2.add_parameter("x", x_shape); auto x = m2.add_parameter("x", x_shape);
m2.add_instruction(migraphx::make_op("neg"), x); auto x2 = m2.add_instruction(migraphx::make_op("neg"), x);
m2.add_instruction(migraphx::make_op("identity"), x2);
} }
EXPECT(m1 == m2); EXPECT(m1 == m2);
...@@ -1115,7 +1140,8 @@ TEST_CASE(simplify_neg_unit_mul_const_vec2) ...@@ -1115,7 +1140,8 @@ TEST_CASE(simplify_neg_unit_mul_const_vec2)
migraphx::module m2; migraphx::module m2;
{ {
auto x = m2.add_parameter("x", x_shape); auto x = m2.add_parameter("x", x_shape);
m2.add_instruction(migraphx::make_op("neg"), x); auto x2 = m2.add_instruction(migraphx::make_op("neg"), x);
m2.add_instruction(migraphx::make_op("identity"), x2);
} }
EXPECT(m1 == m2); EXPECT(m1 == m2);
...@@ -1134,7 +1160,8 @@ TEST_CASE(simplify_neg_unit_div_const) ...@@ -1134,7 +1160,8 @@ TEST_CASE(simplify_neg_unit_div_const)
migraphx::module m2; migraphx::module m2;
{ {
auto x = m2.add_parameter("x", {migraphx::shape::int32_type, {1}}); auto x = m2.add_parameter("x", {migraphx::shape::int32_type, {1}});
m2.add_instruction(migraphx::make_op("neg"), x); auto x2 = m2.add_instruction(migraphx::make_op("neg"), x);
m2.add_instruction(migraphx::make_op("identity"), x2);
} }
EXPECT(m1 == m2); EXPECT(m1 == m2);
...@@ -1157,7 +1184,8 @@ TEST_CASE(simplify_neg_unit_div_const_vec) ...@@ -1157,7 +1184,8 @@ TEST_CASE(simplify_neg_unit_div_const_vec)
migraphx::module m2; migraphx::module m2;
{ {
auto x = m2.add_parameter("x", x_shape); auto x = m2.add_parameter("x", x_shape);
m2.add_instruction(migraphx::make_op("neg"), x); auto x2 = m2.add_instruction(migraphx::make_op("neg"), x);
m2.add_instruction(migraphx::make_op("identity"), x2);
} }
EXPECT(m1 == m2); EXPECT(m1 == m2);
...@@ -1217,7 +1245,8 @@ TEST_CASE(simplify_sub_neg_zero_const) ...@@ -1217,7 +1245,8 @@ TEST_CASE(simplify_sub_neg_zero_const)
migraphx::module m2; migraphx::module m2;
{ {
auto x = m2.add_parameter("x", {migraphx::shape::int32_type, {1}}); auto x = m2.add_parameter("x", {migraphx::shape::int32_type, {1}});
m2.add_instruction(migraphx::make_op("neg"), x); auto x2 = m2.add_instruction(migraphx::make_op("neg"), x);
m2.add_instruction(migraphx::make_op("identity"), x2);
} }
EXPECT(m1 == m2); EXPECT(m1 == m2);
} }
...@@ -1239,7 +1268,8 @@ TEST_CASE(simplify_sub_neg_zero_const_vec) ...@@ -1239,7 +1268,8 @@ TEST_CASE(simplify_sub_neg_zero_const_vec)
migraphx::module m2; migraphx::module m2;
{ {
auto x = m2.add_parameter("x", x_shape); auto x = m2.add_parameter("x", x_shape);
m2.add_instruction(migraphx::make_op("neg"), x); auto x2 = m2.add_instruction(migraphx::make_op("neg"), x);
m2.add_instruction(migraphx::make_op("identity"), x2);
} }
EXPECT(m1 == m2); EXPECT(m1 == m2);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment