fix: add test_sum_int and remove outdated TODO in test_custom_kernel (#13560)

This commit is contained in:
ayanhan
2025-12-04 11:51:58 +09:00
committed by GitHub
parent 0a54434b15
commit 92b40290c7

View File

@@ -155,12 +155,17 @@ class TestCustomKernel(unittest.TestCase):
self.assertTrue((b_p1 == 3).all().item())
def test_sum(self):
# TODO: this only works for float, and silently fails with int
a = Tensor([1.0, 2, 3, 4, 5])
tst = Tensor.empty(1)
b = Tensor.custom_kernel(tst, a, fxn=custom_sum)[0]
self.assertEqual(b.item(), 15)
def test_sum_int(self):
a = Tensor([1, 2, 3, 4, 5])
tst = Tensor.empty(1, dtype=a.dtype)
b = Tensor.custom_kernel(tst, a, fxn=custom_sum)[0]
self.assertEqual(b.item(), 15)
def test_slice_sum(self):
A = Tensor.randn(16, 16).contiguous()
B = Tensor.empty(16)