dynamic shape arg#4233
Conversation
There was a problem hiding this comment.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/tests/py/dynamo/models/test_shared_dynamic_dim.py 2026-05-05 04:54:37.448873+00:00
+++ /home/runner/work/TensorRT/TensorRT/tests/py/dynamo/models/test_shared_dynamic_dim.py 2026-05-05 04:55:00.216122+00:00
@@ -14,10 +14,11 @@
caller supply a shared ``Dim`` directly to ``torch_tensorrt.compile`` --
mirroring the ``torch.export.export(dynamic_shapes=...)`` signature -- so the
shared-batch case compiles end to end without the caller having to pre-export
the module themselves.
"""
+
import unittest
import pytest
import torch
import torch.nn as nn64bcdc4 to
adffa87
Compare
There was a problem hiding this comment.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/tests/py/dynamo/models/test_shared_dynamic_dim.py 2026-06-04 17:31:18.741538+00:00
+++ /home/runner/work/TensorRT/TensorRT/tests/py/dynamo/models/test_shared_dynamic_dim.py 2026-06-04 17:31:43.478755+00:00
@@ -13,10 +13,11 @@
name; the same name across inputs is exported as a single shared ``Dim``. All
the dynamic-shape intent lives on the ``Input`` objects -- no separate
``dynamic_shapes`` argument and no ``torch.export`` knowledge required at the
call site.
"""
+
import unittest
import pytest
import torch
import torch.nn as nnadffa87 to
ae1ce2f
Compare
|
@narendasan are you suggesting something like this? B and S are the named tuples torch_tensorrt.compile( |
|
No it was more like two different ideas. Idea 1: Copy the export dynamic dimension system torch_tensorrt.compile(model,
arg_inputs=[
torch_tensorrt.Input({
"min":(1,2,3,4),
"opt":(1,4,3,4),
"max":(1,8,3,4),
}, shared_dims={1:"channel"}),
torch_tensorrt.Input({
"min":(2,2,),
"opt":(4,2,),
"max":(8,2,),
}, shared_dims={0:"channel"}),
]) Idea 2 (we can do later): Named dimensions from collections import namedtuple
input_shape1 = namedtuple('input_shape', ['n', 'c', 'h', 'w'])
input_shape2 = namedtuple('input_shape', ['c', 'seq',])
torch_tensorrt.compile(model,
arg_inputs=[
torch_tensorrt.Input({
"min":input_shape1(1,2,3,4),
"opt":input_shape1(1,4,3,4),
"max":input_shape1(1,8,3,4),
}),
torch_tensorrt.Input({
"min":input_shape2(2,2,),
"opt":input_shape2(4,2,),
"max":input_shape2(8,2,),
}),
]) |
f134c58 to
d1e4c28
Compare
narendasan
left a comment
There was a problem hiding this comment.
LGTM please add an example on how to use this feature then merge.
f907b64 to
9f9055a
Compare
Uh oh!
There was an error while loading. Please reload this page.