check Tensor.reshape can have at most one -1 (#5026)

raise RuntimeError to match torch. on master it throws weird errors from shapetracker
This commit is contained in:
chenyu
2024-06-18 08:17:12 -04:00
committed by GitHub
parent 7bfa9101c0
commit 620fa6e5a2
2 changed files with 3 additions and 0 deletions

View File

@@ -1123,6 +1123,8 @@ class TestOps(unittest.TestCase):
helper_test_op([(1,)], lambda x: x.reshape([]))
helper_test_op([()], lambda x: x.reshape([1]))
helper_test_op([()], lambda x: x.reshape([1, 1, 1]))
self.helper_test_exception([(3, 4)], lambda x: x.reshape((-1, -1, 2)), lambda x: x.reshape((-1, -1, 2)), expected=RuntimeError)
self.helper_test_exception([(3, 4)], lambda x: x.reshape((-1, -1, -1, 2)), lambda x: x.reshape((-1, -1, -1, 2)), expected=RuntimeError)
with self.assertRaises(ValueError):
x = Tensor.ones((4,3,6,6))