The official doc on torch.numel
notes that its input must be a torch.Tensor
. I tried torch.Size
as input and the result might be kind of unexpected.
The code snippet is shown as:
import torch
a = torch.Tensor(3, 4)
print(a.numel(), a.shape.numel())
The returned values of both a.numel()
and a.shape.numel()
are 12
.
But there is no documentation or explanation for the input type torch.Size
. Whether it is a potential bug or feature?