TensorRT icon indicating copy to clipboard operation
TensorRT copied to clipboard

error when value is a np.array int

Open ecilay opened this issue 2 years ago • 1 comments

https://github.com/pytorch/TensorRT/blob/5f66adefcea1302e91aa2b3b9e3120636d7027d8/py/torch_tensorrt/dynamo/conversion/converter_utils.py#L273

In this line, if the value is a np.array int, eg, a = np.array(50), then a.shape would be empty, and the ctx.net.add_constant function would throw Type error: incompatible function arguments.

ecilay avatar Jan 18 '24 00:01 ecilay

Hi - thanks for the report. Are you encountering this bug when compiling a specific model?

Fix Outline

Ensure all np.array tensors have nonzero rank before calling add_constant here: https://github.com/pytorch/TensorRT/blob/5f66adefcea1302e91aa2b3b9e3120636d7027d8/py/torch_tensorrt/dynamo/conversion/converter_utils.py#L272-L275 A regression test case to elicit this behavior might be to have a constant variable which is a dimensionless tensor, as in:

class TestModule(nn.Module):
  def __init__(...):
    self.const = torch.tensor(1)
...

gs-olive avatar Feb 16 '24 02:02 gs-olive