Allow ntuple to be used with string values

This commit is contained in:
Ross Wightman 2022-07-28 16:18:18 -07:00
parent 7430a85d07
commit 8ad4bdfa06

View File

@ -9,7 +9,7 @@ import collections.abc
# From PyTorch internals # From PyTorch internals
def _ntuple(n): def _ntuple(n):
def parse(x): def parse(x):
if isinstance(x, collections.abc.Iterable): if isinstance(x, collections.abc.Iterable) and not isinstance(x, str):
return x return x
return tuple(repeat(x, n)) return tuple(repeat(x, n))
return parse return parse