Skip to content

🐛 [Bug] Some elementwise like floor_divide.Scalar using float as default scalar type #1447

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

Closed
Njuapp opened this issue Nov 8, 2022 · 1 comment · Fixed by #1448
Closed
Labels
bug Something isn't working

Comments

@Njuapp
Copy link
Contributor

Njuapp commented Nov 8, 2022

Bug Description

Elementwise operations like floor_divide.Scalar uses float as default scalar type, this may cause error in such a case:
The graph is partitioned into torch/tensorrt-interleaved subgraphs, and floor_divide.Scalar accepts one INT-type tensor and one INT-type scalar as input, and the output is fed into the subsequent subgraph as its INT-type input.
However, currently the floor_divide.Scalar converts the scalar into float by default, and then output a float-type tensor, which does not fullfill the requirement of subsequent graph.

To Reproduce

Traceback (most recent call last):
File "reproduce.py", line 34, in
trt_model(img_input)
File "/root/.pyenv/versions/3.7.13/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
RuntimeError: [Error thrown at core/runtime/execute_engine.cpp:91] Expected inputs[pyt_idx].dtype() == expected_type to be true but got false
Expected input tensors to have type Int, found type float

Expected behavior

Environment

Build information about Torch-TensorRT can be found by turning on debug messages

  • Torch-TensorRT Version (e.g. 1.0.0):
  • PyTorch Version (e.g. 1.0):
  • CPU Architecture:
  • OS (e.g., Linux):
  • How you installed PyTorch (conda, pip, libtorch, source):
  • Build command you used (if compiling from source):
  • Are you using local sources or building from archives:
  • Python version:
  • CUDA version:
  • GPU models and configuration:
  • Any other relevant information:

Additional context

@narendasan
Copy link
Collaborator

@Njuapp can you share a repro?

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

Successfully merging a pull request may close this issue.

4 participants