    def test_identity_reshape(self):
        """
        Given reshape(reshape(x, shape0), shape1), where shape1 is identical to
        x's original shape, we can eliminate both reshape ops.
        """
        dtype = "float"
        x0_shape = [2, 4, 8]
        y_shape = [2, 8]

        x0 = Tensor(
            shape=x0_shape,
            dtype=dtype,
            name="x0",
            is_input=True,
        )
        x1 = ops.reshape()(x0, [8, 8])
        x2 = ops.reshape()(x1, x0_shape)

        y = ops.reduce_sum(dim=1)(x2)
        y._attrs["name"] = "y"
        y._attrs["is_output"] = True

        x0_pt = get_random_torch_tensor(x0_shape, dtype)
        y_pt = get_torch_empty_tensor(y_shape, dtype)

        target = detect_target()
        module = compile_model(
            y,
            target,
            "./tmp",
            "test_identity_reshape",
        )
        result_graph = module.debug_sorted_graph
        module.run_with_tensors({"x0": x0_pt}, {"y": y_pt})

        self.assertEqual(len(result_graph), 2)
        self.assertFalse(graph_has_op(result_graph, "reshape"))
        expected = torch.sum(x0_pt, 1)
        torch.testing.assert_close(expected, y_pt, atol=5e-2, rtol=5e-2)
Given reshape(reshape(x, shape0), shape1), where shape1 is identical to
x's original shape, we can eliminate both reshape ops.
tests/unittest/compiler/test_merge_view_ops.py