Skip to content

Commit e77e5b0

Browse files
authored
add 0d tensor support for searchsorted for npu and mlu (PaddlePaddle#233)
* add ut for searchsorted for npu and mlu * add value compare
1 parent d438673 commit e77e5b0

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

backends/mlu/tests/unittests/test_zero_dim_tensor_mlu.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,16 @@ def test_logical_not(self):
426426

427427
self.assertEqual(out.shape, [])
428428

429+
def test_searchsorted(self):
430+
x = paddle.to_tensor([1, 3, 5, 7, 9])
431+
y = paddle.rand([])
432+
433+
# only has forward kernel
434+
out = paddle.searchsorted(x, y)
435+
436+
self.assertEqual(out.shape, [])
437+
self.assertEqual(out.numpy(), 0)
438+
429439

430440
# Use to test API whose zero-dim input tensors don't have grad and not need to test backward in OpTest.
431441
class TestNoBackwardAPI(unittest.TestCase):

backends/npu/tests/unittests/test_zero_dim_tensor_npu.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,16 @@ def test_logical_not(self):
426426

427427
self.assertEqual(out.shape, [])
428428

429+
def test_searchsorted(self):
430+
x = paddle.to_tensor([1, 3, 5, 7, 9])
431+
y = paddle.rand([])
432+
433+
# only has forward kernel
434+
out = paddle.searchsorted(x, y)
435+
436+
self.assertEqual(out.shape, [])
437+
self.assertEqual(out.numpy(), 0)
438+
429439
# Use to test API whose zero-dim input tensors don't have grad and not need to test backward in OpTest.
430440
class TestNoBackwardAPI(unittest.TestCase):
431441
def setUp(self):

0 commit comments

Comments
 (0)