Skip to content

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

Closed
@Njuapp

Description

@Njuapp

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions