Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [Bug] shape tensor is a list instead of integer #3202

Open
zewenli98 opened this issue Oct 2, 2024 · 0 comments
Open

🐛 [Bug] shape tensor is a list instead of integer #3202

zewenli98 opened this issue Oct 2, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@zewenli98
Copy link
Collaborator

zewenli98 commented Oct 2, 2024

Bug Description

def get_torch_tensor(
input: Input,
device: torch.device,
mode: str = "",
) -> Union[int, torch.Tensor]:
if input.is_shape_tensor:
# TODO: All the shape tensors we've encountered so far are plain integers.
# Validate this assumption on more models.
return input.shape["opt_shape"][0]
if len(mode) > 0:
return input.example_tensor(mode).to(device)
else:
return input.torch_tensor.to(device)

Line 141 mentioned all the shape tensors encountered so far are plain integers, but aten::full() requires a list:

@parameterized.expand(
[
((1,), (3,), (4,), [3], 11),
((3, 5), (3, 7), (3, 10), [3, 7], False),
((1, 5), (3, 7), (4, 10), [3, 7], True),
((1, 5, 3), (3, 7, 3), (4, 10, 4), [3, 7, 3], 0.11),
]
)
def test_full_dynamic(self, min_shape, opt_shape, max_shape, data, fill_value):
class full(nn.Module):
def forward(self, shape):
return torch.ops.aten.full.default(shape, fill_value)
inputs = [
torch_tensorrt.Input(
min_shape=min_shape,
opt_shape=opt_shape,
max_shape=max_shape,
dtype=torch.int64,
torch_tensor=torch.tensor(data, dtype=torch.int64).cuda(),
is_shape_tensor=True,
)
]
self.run_test_with_dynamic_shape(
full(), inputs, use_example_tensors=False, check_dtype=False
)

The current implementation caused the error:

RuntimeError: aten::full() Expected a value of type 'List[int]' for argument 'size' but instead found type 'int'.
Position: 0
Value: 3
Declaration: aten::full(SymInt[] size, Scalar fill_value, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None) -> Tensor
 Python error details: TypeError: 'int' object is not iterable
@zewenli98 zewenli98 added the bug Something isn't working label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant