ATen
ATen copied to clipboard
[Scalars] [maybe] accept any dimension for an operation on a scalar
Numpy allows dimensional operations on scalars, but requires that the dimension passed in is None, 0 (or -1, which is equivalent with wrap_dim):
>>> np.array(5).sum(None)
5
>>> np.array(5).sum(0)
5
>>> np.array(5).sum(-1)
5
anything else passed in as the dimension fails:
>>> np.array(5).sum(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/data/users/gchanan/anaconda3/envs/py36/lib/python3.6/site-packages/numpy/core/_methods.py", line 32, in _sum
return umr_sum(a, axis, dtype, out, keepdims)
numpy.core._internal.AxisError: axis 1 is out of bounds for array of dimension 0
>>> np.array(5).sum(-2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/data/users/gchanan/anaconda3/envs/py36/lib/python3.6/site-packages/numpy/core/_methods.py", line 32, in _sum
return umr_sum(a, axis, dtype, out, keepdims)
numpy.core._internal.AxisError: axis -2 is out of bounds for array of dimension 0
0, -1 being the only non-None values allowed doesn't make much sense; for the ATen equivalent it seems clearer if only None is allowed, or the value passed in is just ignored.
We currently don't have a None-equivalent for this case, so maybe we should just ignore the value.