-
Notifications
You must be signed in to change notification settings - Fork 55
Closed
Labels
Description
Originally posted by @fdwr in #446 (comment)
If any value in newShape is 0, then throw a "DataError" DOMException.
Empty tensors are valid in ML. If the input tensor shape contains zeros, then it's correct for newShape to contain zeros. Indeed, if the input shape contains zeros, then newShape must have at least one zero, because otherwise that would be an error. It's only an error if the number of total input element count differs from the total output element count, and so it's good to remove this redundant clause because the element count check is both necessary and sufficient.
| oldShape | newShape | validity |
|---|---|---|
| [1,2,3] | [1,2,3] | ✅ |
| [2,3,1] | [3,2,1] | ✅ |
| [1,2,3] | [6] | ✅ |
| [0,0,0] | [0,0,0] | ✅ |
| [1,2,0] | [0,0,0] | ✅ |
| [1,2,0] | [0,2,1] | ✅ |
| [1,2,3] | [1,0,3] | ❌ |
| [1,0,3] | [1,2,3] | ❌ |