diff --git a/src/onnx/parse_depthtospace.cpp b/src/onnx/parse_depthtospace.cpp index 610902ef4af..609eee04605 100644 --- a/src/onnx/parse_depthtospace.cpp +++ b/src/onnx/parse_depthtospace.cpp @@ -87,8 +87,7 @@ struct parse_depthtospace : op_parser auto temp1 = info.add_instruction(make_op("reshape", {{"dims", lens1}}), args[0]); auto temp2 = info.add_instruction(make_op("transpose", {{"permutation", perm}}), temp1); - return info.add_instruction(make_op("reshape", {{"dims", lens2}}), - info.make_contiguous(temp2)); + return info.add_instruction(make_op("reshape", {{"dims", lens2}}), temp2); } }; diff --git a/src/onnx/parse_reshape.cpp b/src/onnx/parse_reshape.cpp index ee5adeeb52d..a22f1389c33 100644 --- a/src/onnx/parse_reshape.cpp +++ b/src/onnx/parse_reshape.cpp @@ -53,8 +53,7 @@ struct parse_reshape : op_parser s.visit([&](auto v) { copy(v, std::back_inserter(dims)); }); } - auto cont = info.add_instruction(make_op("contiguous"), args[0]); - return info.add_instruction(make_op("reshape", {{"dims", dims}}), cont); + return info.add_instruction(make_op("reshape", {{"dims", dims}}), args[0]); } }; diff --git a/src/onnx/parse_spacetodepth.cpp b/src/onnx/parse_spacetodepth.cpp index 51ca1c0053f..69a8bf58a15 100644 --- a/src/onnx/parse_spacetodepth.cpp +++ b/src/onnx/parse_spacetodepth.cpp @@ -73,8 +73,7 @@ struct parse_spacetodepth : op_parser std::vector perm = {0, 3, 5, 1, 2, 4}; auto temp1 = info.add_instruction(make_op("reshape", {{"dims", trans_lens}}), args[0]); auto temp2 = info.add_instruction(make_op("transpose", {{"permutation", perm}}), temp1); - return info.add_instruction(make_op("reshape", {{"dims", res_lens}}), - info.make_contiguous(temp2)); + return info.add_instruction(make_op("reshape", {{"dims", res_lens}}), temp2); } }; diff --git a/src/tf/parse_reshape.cpp b/src/tf/parse_reshape.cpp index 6ab28e7c564..3cbe2d878c8 100644 --- a/src/tf/parse_reshape.cpp +++ b/src/tf/parse_reshape.cpp @@ -45,8 +45,7 @@ struct parse_reshape : op_parser auto s = args[1]->eval(); std::vector dims; s.visit([&](auto v) { copy(v, std::back_inserter(dims)); }); - return info.add_instruction(make_op("reshape", {{"dims", dims}}), - info.make_contiguous(args[0])); + return info.add_instruction(make_op("reshape", {{"dims", dims}}), args[0]); } }; diff --git a/test/onnx/onnx_test.cpp b/test/onnx/onnx_test.cpp index 54031e8d5f2..f45af14d100 100644 --- a/test/onnx/onnx_test.cpp +++ b/test/onnx/onnx_test.cpp @@ -1772,8 +1772,7 @@ TEST_CASE(depthtospace_test) mm->add_instruction(migraphx::make_op("reshape", {{"dims", {2, 2, 2, 2, 5, 5}}}), l0); auto tmp2 = mm->add_instruction( migraphx::make_op("transpose", {{"permutation", {0, 3, 4, 1, 5, 2}}}), tmp1); - auto tmp3 = mm->add_instruction(migraphx::make_op("contiguous"), tmp2); - mm->add_instruction(migraphx::make_op("reshape", {{"dims", {2, 2, 10, 10}}}), tmp3); + mm->add_instruction(migraphx::make_op("reshape", {{"dims", {2, 2, 10, 10}}}), tmp2); auto prog = optimize_onnx("depthtospace_test.onnx"); EXPECT(p == prog); } @@ -1787,8 +1786,7 @@ TEST_CASE(depthtospace_crd_test) mm->add_instruction(migraphx::make_op("reshape", {{"dims", {2, 2, 2, 2, 5, 5}}}), l0); auto tmp2 = mm->add_instruction( migraphx::make_op("transpose", {{"permutation", {0, 1, 4, 2, 5, 3}}}), tmp1); - auto tmp3 = mm->add_instruction(migraphx::make_op("contiguous"), tmp2); - mm->add_instruction(migraphx::make_op("reshape", {{"dims", {2, 2, 10, 10}}}), tmp3); + mm->add_instruction(migraphx::make_op("reshape", {{"dims", {2, 2, 10, 10}}}), tmp2); auto prog = optimize_onnx("depthtospace_crd_test.onnx"); EXPECT(p == prog); } @@ -1802,8 +1800,7 @@ TEST_CASE(depthtospace_simple_test) mm->add_instruction(migraphx::make_op("reshape", {{"dims", {1, 2, 2, 2, 2, 3}}}), l0); auto tmp2 = mm->add_instruction( migraphx::make_op("transpose", {{"permutation", {0, 3, 4, 1, 5, 2}}}), tmp1); - auto tmp3 = mm->add_instruction(migraphx::make_op("contiguous"), tmp2); - mm->add_instruction(migraphx::make_op("reshape", {{"dims", {1, 2, 4, 6}}}), tmp3); + mm->add_instruction(migraphx::make_op("reshape", {{"dims", {1, 2, 4, 6}}}), tmp2); auto prog = optimize_onnx("depthtospace_simple_test.onnx"); EXPECT(p == prog); } @@ -1817,8 +1814,7 @@ TEST_CASE(spacetodepth_test) mm->add_instruction(migraphx::make_op("reshape", {{"dims", {2, 2, 5, 2, 5, 2}}}), l0); auto tmp2 = mm->add_instruction( migraphx::make_op("transpose", {{"permutation", {0, 3, 5, 1, 2, 4}}}), tmp1); - auto tmp3 = mm->add_instruction(migraphx::make_op("contiguous"), tmp2); - mm->add_instruction(migraphx::make_op("reshape", {{"dims", {2, 8, 5, 5}}}), tmp3); + mm->add_instruction(migraphx::make_op("reshape", {{"dims", {2, 8, 5, 5}}}), tmp2); auto prog = optimize_onnx("spacetodepth_test.onnx"); EXPECT(p == prog); } @@ -1832,8 +1828,7 @@ TEST_CASE(spacetodepth_simple_test) mm->add_instruction(migraphx::make_op("reshape", {{"dims", {1, 2, 2, 2, 3, 2}}}), l0); auto tmp2 = mm->add_instruction( migraphx::make_op("transpose", {{"permutation", {0, 3, 5, 1, 2, 4}}}), tmp1); - auto tmp3 = mm->add_instruction(migraphx::make_op("contiguous"), tmp2); - mm->add_instruction(migraphx::make_op("reshape", {{"dims", {1, 8, 2, 3}}}), tmp3); + mm->add_instruction(migraphx::make_op("reshape", {{"dims", {1, 8, 2, 3}}}), tmp2); auto prog = optimize_onnx("spacetodepth_simple_test.onnx"); EXPECT(p == prog); } @@ -5491,12 +5486,9 @@ TEST_CASE(reshape_test) migraphx::literal{migraphx::shape{migraphx::shape::int64_type, {2}}, reshape_dims}); auto l0 = mm->add_parameter("0", migraphx::shape{migraphx::shape::float_type, {4, 2, 3}}); op.dims = reshape_dims; - auto c0 = mm->add_instruction(migraphx::make_op("contiguous"), l0); - mm->add_instruction(op, c0); - auto c1 = mm->add_instruction(migraphx::make_op("contiguous"), l0); - mm->add_instruction(op, c1); + mm->add_instruction(op, l0); + mm->add_instruction(op, l0); auto prog = optimize_onnx("reshape_test.onnx"); - EXPECT(p == prog); } @@ -5509,8 +5501,7 @@ TEST_CASE(reshape_non_standard_test) auto x = mm->add_parameter("x", s); auto tran_x = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {0, 2, 1}}}), x); - auto cont_x = mm->add_instruction(migraphx::make_op("contiguous"), tran_x); - mm->add_instruction(migraphx::make_op("reshape", {{"dims", {4, 3, 2}}}), cont_x); + mm->add_instruction(migraphx::make_op("reshape", {{"dims", {4, 3, 2}}}), tran_x); auto prog = optimize_onnx("reshape_non_standard_test.onnx"); EXPECT(p == prog);