TensorRT icon indicating copy to clipboard operation
TensorRT copied to clipboard

How to set the input when compiling model for non-image input?

Open DeepDuke opened this issue 1 year ago • 1 comments

Hi, I have trained a model whose input is a set of 3D points with a shape Nx3, N is not a fixed number. In this case, how to set the input during compiling my model?

For image, the input shape is like this:

inputs = [torch.randn((1, 3, 224, 224)).to("cuda").half()]

What if for my case? Thank you!

### Tasks

DeepDuke avatar Dec 26 '23 12:12 DeepDuke

Hello - for models with tensors that have Dynamic dimensions, you can specify the minimum, optimal, and maximum shapes via the torch_tensorrt.Input API. For instance, when compiling via torch_tensorrt.compile, you could specify:

torch_tensorrt.compile(model,
                       inputs=[
                           torch_tensorrt.Input(
                               min_shape=(1, 3, 224, 224),
                               opt_shape=(3, 3, 224, 224),
                               max_shape=(10, 3, 224, 224))]
                      ...

gs-olive avatar Dec 27 '23 18:12 gs-olive