Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Prim][PIR] Add the dynamic shape test case for roll_grad #68272

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions python/paddle/autograd/backward_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"pd_op.reduce_as",
"pd_op.relu",
"pd_op.reshape",
"pd_op.roll",
"pd_op.rsqrt",
"pd_op.scale",
"pd_op.scatter",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def reshape_net(x):
return paddle.reshape(x, [30, 200 * 40])


def roll_net(x):
return paddle.roll(x, shifts=[101, -1], axis=[0, -2])


def scale_net(x):
return paddle.scale(x, scale=-2.3)

Expand Down Expand Up @@ -334,6 +338,32 @@ def setUp(self):
self.tol = 1e-6


class TestPrimRollWithGrad1(TestPrimBaseWithGrad):
def setUp(self):
np.random.seed(2024)
self.op_name = "pd_op.roll_grad"
self.dtype = "float32"
self.x_shape = [100, 4, 5]
self.init_x_shape = [None, None, 5]
self.x = np.random.random(self.x_shape).astype(self.dtype)
self.net = roll_net
self.enable_cinn = False
self.tol = 1e-6


class TestPrimRollWithGrad2(TestPrimBaseWithGrad):
def setUp(self):
np.random.seed(2024)
self.op_name = "pd_op.roll_grad"
self.dtype = "float32"
self.x_shape = [100, 4, 5]
self.init_x_shape = [100, None, None]
self.x = np.random.random(self.x_shape).astype(self.dtype)
self.net = roll_net
self.enable_cinn = False
self.tol = 1e-6


class TestPrimScaleWithGrad(TestPrimBaseWithGrad):
def setUp(self):
np.random.seed(2023)
Expand Down