def test_dygraph_api(self):
    self.input_data()
    with fluid.dygraph.guard():
        x = fluid.dygraph.to_variable(self.data_x)
        z = paddle.roll(x, shifts=1)
        np_z = z.numpy()
    expect_out = np.array([[9.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]])
    self.assertTrue(np.allclose(expect_out, np_z))
    with fluid.dygraph.guard():
        x = fluid.dygraph.to_variable(self.data_x)
        z = paddle.roll(x, shifts=1, dims=0)
        np_z = z.numpy()
    expect_out = np.array([[7.0, 8.0, 9.0], [1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
    self.assertTrue(np.allclose(expect_out, np_z))
def test_dygraph_api(self):
    self.input_data()
    with fluid.dygraph.guard():
        x = fluid.dygraph.to_variable(self.data_x)
        z = paddle.roll(x, shifts=1)
        np_z = z.numpy()
    expect_out = np.array([[9.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]])
    self.assertTrue(np.allclose(expect_out, np_z))
    with fluid.dygraph.guard():
        x = fluid.dygraph.to_variable(self.data_x)
        z = paddle.roll(x, shifts=1, dims=0)
        np_z = z.numpy()
    expect_out = np.array([[7.0, 8.0, 9.0], [1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
    self.assertTrue(np.allclose(expect_out, np_z))