check the input length into argfix (#3610)

* check the input length into argfix

it's possible to overlook setting keyword for kwargs and argfix silently truncates input

* add test
This commit is contained in:
chenyu
2024-03-04 19:50:17 -05:00
committed by GitHub
parent 7db6dd725d
commit 282bbd5acb
2 changed files with 13 additions and 4 deletions

View File

@@ -214,6 +214,13 @@ class TestTinygrad(unittest.TestCase):
self.assertEqual(Tensor.empty(1,10,20).shape, (1,10,20))
self.assertEqual(Tensor.empty((10,20,40)).shape, (10,20,40))
with self.assertRaises(ValueError):
Tensor.zeros((2, 2), 2, 2)
with self.assertRaises(ValueError):
Tensor.zeros((2, 2), (2, 2))
with self.assertRaises(ValueError):
Tensor.randn((128, 128), 0.0, 0.01)
def test_numel(self):
assert Tensor.randn(10, 10).numel() == 100
assert Tensor.randn(1,2,5).numel() == 10