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

support fp16 index sample #47897

Merged
merged 8 commits into from
Dec 14, 2022
22 changes: 22 additions & 0 deletions python/paddle/fluid/tests/unittests/test_index_sample_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,28 @@ def config(self):
self.index_type = "int64"


class TestCase5(TestIndexSampleOp):
def config(self):
"""
For float16 x type
"""
self.x_shape = (10, 128)
self.x_type = "float16"
self.index_shape = (10, 64)
self.index_type = "int32"


class TestCase6(TestIndexSampleOp):
def config(self):
"""
For float16 x type
"""
self.x_shape = (10, 128)
self.x_type = "float16"
self.index_shape = (10, 64)
self.index_type = "int64"


class TestIndexSampleShape(unittest.TestCase):
def test_shape(self):
paddle.enable_static()
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/tensor/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ def index_sample(x, index):
check_variable_and_dtype(
x,
'x',
['float32', 'float64', 'int32', 'int64'],
['float16', 'float32', 'float64', 'int32', 'int64'],
'paddle.tensor.search.index_sample',
)
check_variable_and_dtype(
Expand Down