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

【PIR】add gather_nd #57640

Merged
merged 4 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
'fused_softmax_mask_upper_triangle',
'slice',
'transpose',
'slice_double',
'slice_grad',
'gather_nd',
'stack',
'poisson',
'gumbel_softmax',
]
Expand Down Expand Up @@ -91,6 +93,9 @@
'fused_softmax_mask_upper_triangle',
'slice',
'transpose',
'slice_grad',
'gather_nd',
'stack',
'slice_double',
xiaoguoguo626807 marked this conversation as resolved.
Show resolved Hide resolved
'poisson',
'gumbel_softmax',
Expand Down
8 changes: 8 additions & 0 deletions paddle/fluid/primitive/codegen/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
'layer_norm_grad',
'embedding_grad',
'scale_grad',
'gather_nd_grad',
'stack_grad',
'squeeze_grad',
'unsqueeze_grad',
'poisson_grad',
'gumbel_softmax_grad',
]
Expand Down Expand Up @@ -169,6 +173,10 @@
'gumbel_softmax_grad',
'split',
'transpose',
'gather_nd_grad',
'stack_grad',
'squeeze_grad',
'unsqueeze_grad',
]


Expand Down
30 changes: 15 additions & 15 deletions test/legacy_test/test_gather_nd_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def config_dtype(self):
def test_check_output(self):
self.check_output(check_new_ir=True)

def test_check_grad(self):
self.check_grad(['X'], 'Out', check_prim=True, check_new_ir=False)
def test_x(self):
xiaoguoguo626807 marked this conversation as resolved.
Show resolved Hide resolved
self.check_grad(['X'], 'Out', check_prim=True, check_new_ir=True)


class TestGatherNdOpWithEmptyIndexFP16(TestGatherNdOpWithEmptyIndex):
Expand All @@ -80,7 +80,7 @@ def test_check_output(self):
def test_check_grad(self):
place = core.CUDAPlace(0)
self.check_grad_with_place(
place, ['X'], 'Out', check_prim=True, check_new_ir=False
place, ['X'], 'Out', check_prim=True, check_new_ir=True
)


Expand Down Expand Up @@ -117,7 +117,7 @@ def test_check_output(self):
self.check_output(check_new_ir=True)

def test_check_grad(self):
self.check_grad(['X'], 'Out', check_prim=True, check_new_ir=False)
self.check_grad(['X'], 'Out', check_prim=True, check_new_ir=True)


class TestGatherNdOpWithIndex1_ZeroDim(TestGatherNdOpWithIndex1):
Expand Down Expand Up @@ -168,7 +168,7 @@ def test_check_output(self):
def test_check_grad(self):
place = core.CUDAPlace(0)
self.check_grad_with_place(
place, ['X'], 'Out', check_prim=True, check_new_ir=False
place, ['X'], 'Out', check_prim=True, check_new_ir=True
)


Expand Down Expand Up @@ -205,7 +205,7 @@ def test_check_output(self):
self.check_output(check_new_ir=True)

def test_check_grad(self):
self.check_grad(['X'], 'Out', check_prim=True, check_new_ir=False)
self.check_grad(['X'], 'Out', check_prim=True, check_new_ir=True)


class TestGatherNdOpWithLowIndexFP16(TestGatherNdOpWithLowIndex):
Expand Down Expand Up @@ -233,7 +233,7 @@ def test_check_grad(self):
['X'],
'Out',
check_prim=True,
check_new_ir=False,
check_new_ir=True,
numeric_grad_delta=0.5,
)

Expand Down Expand Up @@ -280,7 +280,7 @@ def test_check_grad(self):
['X'],
'Out',
check_prim=True,
check_new_ir=False,
check_new_ir=True,
numeric_grad_delta=0.05,
)

Expand Down Expand Up @@ -310,7 +310,7 @@ def test_check_grad(self):
['X'],
'Out',
check_prim=True,
check_new_ir=False,
check_new_ir=True,
numeric_grad_delta=0.5,
)

Expand Down Expand Up @@ -345,7 +345,7 @@ def test_check_output(self):
self.check_output(check_new_ir=True)

def test_check_grad(self):
self.check_grad(['X'], 'Out', check_prim=True, check_new_ir=False)
self.check_grad(['X'], 'Out', check_prim=True, check_new_ir=True)


class TestGatherNdOpWithSameIndexAsXFP16(TestGatherNdOpWithSameIndexAsX):
Expand Down Expand Up @@ -373,7 +373,7 @@ def test_check_grad(self):
['X'],
'Out',
check_prim=True,
check_new_ir=False,
check_new_ir=True,
numeric_grad_delta=0.5,
)

Expand Down Expand Up @@ -410,7 +410,7 @@ def test_check_output(self):
self.check_output(check_new_ir=True)

def test_check_grad(self):
self.check_grad(['X'], 'Out', check_prim=True, check_new_ir=False)
self.check_grad(['X'], 'Out', check_prim=True, check_new_ir=True)


class TestGatherNdOpWithHighRankSameFP16(TestGatherNdOpWithHighRankSame):
Expand All @@ -434,7 +434,7 @@ def test_check_output(self):
def test_check_grad(self):
place = core.CUDAPlace(0)
self.check_grad_with_place(
place, ['X'], 'Out', check_prim=True, check_new_ir=False
place, ['X'], 'Out', check_prim=True, check_new_ir=True
)


Expand Down Expand Up @@ -471,7 +471,7 @@ def test_check_output(self):
self.check_output(check_new_ir=True)

def test_check_grad(self):
self.check_grad(['X'], 'Out', check_prim=True, check_new_ir=False)
self.check_grad(['X'], 'Out', check_prim=True, check_new_ir=True)


class TestGatherNdOpWithHighRankDiffFP16(TestGatherNdOpWithHighRankDiff):
Expand All @@ -495,7 +495,7 @@ def test_check_output(self):
def test_check_grad(self):
place = core.CUDAPlace(0)
self.check_grad_with_place(
place, ['X'], 'Out', check_prim=True, check_new_ir=False
place, ['X'], 'Out', check_prim=True, check_new_ir=True
)


Expand Down