The array API specification stipulates that the size attribute of an array should return an integer with the number of elements of the array.
In PyTorch the size attribute is a method that returns the shape when called. The number of elements is accessible through the numel() method:
import torch
t = torch.empty((2, 3, 4))
size = 2 * 3 * 4
assert t.size() == t.shape
assert t.numel() == size
cc @mruberry @rgommers @pmeier @asmeurer @leofang
The array API specification stipulates that the
sizeattribute of an array should return an integer with the number of elements of the array.In PyTorch the
sizeattribute is a method that returns theshapewhen called. The number of elements is accessible through thenumel()method: