Function(s) expecting a tuple argument don't accept generators #69207
Labels
module: nn
Related to torch.nn
Stale
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
π Bug
From the docs for
torch.interpolate
, these arguments accept tuples:int
orTuple[int]
orTuple[int, int]
orTuple[int, int, int])
β output spatial size.float
orTuple[float]
) β multiplier for spatial size. Ifscale_factor
is a tuple, its length has to matchinput.dim()
.However, if
size
orscale_factor
are generators the function fails.I am not sure if this extends to other similar functions.
To Reproduce
Steps to reproduce the behavior:
size
argumentproduces error
scale_factor
argumentproduces error
Expected behavior
The generators would at least be attempted to be evaluated to lists/tuples. Even in the case of the
size
argument, the traceback states that it has received a list rather than a generator!In both cases, resolving the generator expressions to either tuple or a list works perfectly.
Environment
Additional context
The reason I was doing this in the first place is that I thought using parentheses would be 'tuple' comprehension rather than list comprehension. I have now learned that this is actually a generator expression.
I could easily use square brackets instead and move on - it's just I also expected this to work and the error message is a bit strange.
cc @albanD @mruberry @jbschlosser @walterddr @kshitij12345
The text was updated successfully, but these errors were encountered: