Skip to content

Commit

Permalink
【Hackathon 5th No.13】【关联 PR】Added int16 support for less_than
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyaoao committed Oct 26, 2023
1 parent 6f7cd08 commit e9c8823
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions python/paddle/tensor/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ def less_than(x, y, name=None):
"float16",
"float32",
"float64",
"int16",
"int32",
"int64",
"uint16",
Expand All @@ -921,6 +922,7 @@ def less_than(x, y, name=None):
"float16",
"float32",
"float64",
"int16",
"int32",
"int64",
"uint16",
Expand Down
15 changes: 15 additions & 0 deletions test/legacy_test/test_compare_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,21 @@ def test_place_2(self):
self.assertEqual((result.numpy() == np.array([False])).all(), True)


class TestLessThanInt16(unittest.TestCase):
def test_less_than_int16(self):
# Create a tensor of type int8
x = paddle.to_tensor([1, 2, 3], dtype='int16')
y = paddle.to_tensor([1, 3, 2], dtype='int16')

result = paddle.less_than(x, y)

# desired output
expected = np.array([False, True, False])

# Verify output
self.assertTrue((result.numpy() == expected).all())


if __name__ == '__main__':
paddle.enable_static()
unittest.main()

0 comments on commit e9c8823

Please sign in to comment.