You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reshape, broadcast_to, and permute_dims (I think these are all but I could have missed one), all accept a Tuple[int, ...]. The shape parameter for reshape and broadcast_to for shape, and axis for permute_dims
Every other function that accepts this kind of parameter accepts Union[int, Tuple[int, ...]].
It was pointed out in data-apis/array-api-compat#28 that NumPy currently accepts ints for all of these (and indeed, numpy.array_api accidentally does), but PyTorch does not.
The text was updated successfully, but these errors were encountered:
IIRC, the use of an integer is not the dominant use case and is more of shorthand in NumPy. In #42, we explicitly favored Torch (and somewhat TF) in restricting to a tuple for reshape.
For permute_dims, providing an integer does not make sense as a shorthand, except for the trivial case of a 1d array.
In general, I'd argue that a shape kwarg should be a tuple. If NumPy wants to support an integer shorthand, that's its prerogative, but I don't think this should be codified in the spec.
Every other function that accepts this kind of parameter accepts Union[int, Tuple[int, ...]].
The only instances of shape parameters are for creation functions (ones & co) and manipulation functions (the ones you mentioned. The former accept ints, because ones(3) is a super common shorthand. The latter all require a tuple. So I'm inclined to agree with @kgryte here and say that the current state is fine, and preferred over allowing reshape(3).
reshape
,broadcast_to
, andpermute_dims
(I think these are all but I could have missed one), all accept aTuple[int, ...]
. Theshape
parameter forreshape
andbroadcast_to
forshape
, andaxis
forpermute_dims
Every other function that accepts this kind of parameter accepts
Union[int, Tuple[int, ...]]
.It was pointed out in data-apis/array-api-compat#28 that NumPy currently accepts ints for all of these (and indeed, numpy.array_api accidentally does), but PyTorch does not.
The text was updated successfully, but these errors were encountered: