Skip to content

Commit 82a6514

Browse files
committed
fix: remove legacy conv converter
1 parent 25075e2 commit 82a6514

File tree

3 files changed

+100
-54
lines changed

3 files changed

+100
-54
lines changed

py/torch_tensorrt/dynamo/conversion/aten_ops_converters.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,6 +2454,8 @@ def aten_ops_le(
24542454
def conv_param_validator(
24552455
conv_node: Node, settings: Optional[CompilationSettings] = None
24562456
) -> bool:
2457+
2458+
# return True
24572459
return conv_node.args[7] in ([0], [0, 0], [0, 0, 0])
24582460

24592461

@@ -2505,6 +2507,7 @@ def aten_ops_convolution(
25052507
stride=args[3],
25062508
padding=args[4],
25072509
dilation=args[5],
2510+
# output_padding=args[7],
25082511
groups=args[8],
25092512
)
25102513

py/torch_tensorrt/fx/converters/aten_ops_converters.py

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -103,60 +103,60 @@ def aten_ops_batch_norm(
103103
)
104104

105105

106-
@tensorrt_converter(torch.ops.aten.convolution.default)
107-
def aten_ops_convolution(
108-
network: TRTNetwork,
109-
target: Target,
110-
args: Tuple[Argument, ...],
111-
kwargs: Dict[str, Argument],
112-
name: str,
113-
) -> Union[TRTTensor, Sequence[TRTTensor]]:
114-
kwargs_new = {
115-
"input": args[0],
116-
"weight": args[1],
117-
"bias": args[2],
118-
"stride": args[3],
119-
"padding": args[4],
120-
"dilation": args[5],
121-
"groups": args[8],
122-
}
123-
# we do not handle transposed.
124-
if args[6] is True:
125-
raise RuntimeError(f"Target {target} does not support `transposed=True` ")
126-
# we do not handle output_padding.
127-
if args[7] not in ([0], [0, 0], [0, 0, 0]):
128-
raise RuntimeError(f"Target {target} has non-0 output_padding")
129-
130-
if len(kwargs_new["stride"]) == 1:
131-
return convolution.convNd(
132-
network,
133-
target,
134-
source_ir=SourceIR.ATEN,
135-
name=name,
136-
is_conv1d=True,
137-
input_val=kwargs_new["input"],
138-
weight=kwargs_new["weight"],
139-
bias=kwargs_new["bias"],
140-
stride=kwargs_new["stride"],
141-
padding=kwargs_new["padding"],
142-
dilation=kwargs_new["dilation"],
143-
groups=kwargs_new["groups"],
144-
)
145-
else:
146-
return convolution.convNd(
147-
network,
148-
target,
149-
source_ir=SourceIR.ATEN,
150-
name=name,
151-
is_conv1d=False,
152-
input_val=kwargs_new["input"],
153-
weight=kwargs_new["weight"],
154-
bias=kwargs_new["bias"],
155-
stride=kwargs_new["stride"],
156-
padding=kwargs_new["padding"],
157-
dilation=kwargs_new["dilation"],
158-
groups=kwargs_new["groups"],
159-
)
106+
# @tensorrt_converter(torch.ops.aten.convolution.default)
107+
# def aten_ops_convolution(
108+
# network: TRTNetwork,
109+
# target: Target,
110+
# args: Tuple[Argument, ...],
111+
# kwargs: Dict[str, Argument],
112+
# name: str,
113+
# ) -> Union[TRTTensor, Sequence[TRTTensor]]:
114+
# kwargs_new = {
115+
# "input": args[0],
116+
# "weight": args[1],
117+
# "bias": args[2],
118+
# "stride": args[3],
119+
# "padding": args[4],
120+
# "dilation": args[5],
121+
# "groups": args[8],
122+
# }
123+
# # we do not handle transposed.
124+
# if args[6] is True:
125+
# raise RuntimeError(f"Target {target} does not support `transposed=True` ")
126+
# # we do not handle output_padding.
127+
# if args[7] not in ([0], [0, 0], [0, 0, 0]):
128+
# raise RuntimeError(f"Target {target} has non-0 output_padding")
129+
130+
# if len(kwargs_new["stride"]) == 1:
131+
# return convolution.convNd(
132+
# network,
133+
# target,
134+
# source_ir=SourceIR.ATEN,
135+
# name=name,
136+
# is_conv1d=True,
137+
# input_val=kwargs_new["input"],
138+
# weight=kwargs_new["weight"],
139+
# bias=kwargs_new["bias"],
140+
# stride=kwargs_new["stride"],
141+
# padding=kwargs_new["padding"],
142+
# dilation=kwargs_new["dilation"],
143+
# groups=kwargs_new["groups"],
144+
# )
145+
# else:
146+
# return convolution.convNd(
147+
# network,
148+
# target,
149+
# source_ir=SourceIR.ATEN,
150+
# name=name,
151+
# is_conv1d=False,
152+
# input_val=kwargs_new["input"],
153+
# weight=kwargs_new["weight"],
154+
# bias=kwargs_new["bias"],
155+
# stride=kwargs_new["stride"],
156+
# padding=kwargs_new["padding"],
157+
# dilation=kwargs_new["dilation"],
158+
# groups=kwargs_new["groups"],
159+
# )
160160

161161

162162
@tensorrt_converter(torch.ops.aten.div.default)

run_aot_moria_2dunet.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from monai.networks.nets import UNet
2+
import torch
3+
import torch_tensorrt
4+
5+
device = "cuda:0"
6+
7+
# Define the 2D U-Net model
8+
model = UNet(
9+
spatial_dims=2,
10+
in_channels=3,
11+
out_channels=2,
12+
channels=(16, 32, 64, 128),
13+
strides=(2, 2, 2),
14+
num_res_units=2,
15+
act="relu",
16+
norm="batch",
17+
dropout=0.1,
18+
).to(device).half().eval()
19+
20+
# (batch size, channels, height, width)
21+
input_tensor = torch.randn(1, 3, 256, 256, device=device).half()
22+
23+
backend = "torch_tensorrt"
24+
25+
# Compile the model with Torch-TensorRT backend
26+
model = torch.compile(
27+
model,
28+
backend=backend,
29+
options={
30+
"use_python_runtime": False,
31+
"enabled_precisions": {torch.float16},
32+
"truncate_double": True,
33+
"debug": True,
34+
"min_block_size": 1,
35+
},
36+
dynamic=False,
37+
)
38+
39+
# Perform inference with the compiled model
40+
with torch.no_grad():
41+
output = model(input_tensor)
42+
43+
print(output)

0 commit comments

Comments
 (0)