Skip to content

Commit a990653

Browse files
committed
fix bugs in cpp runtime
1 parent 0a62149 commit a990653

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

examples/dynamo/autocast_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def forward(self, x):
6161
enable_autocast=True,
6262
autocast_low_precision_type=torch.float16,
6363
autocast_excluded_nodes={"^conv1$", "relu"},
64-
autocast_excluded_ops={torch.ops.aten.flatten.using_ints},
64+
autocast_excluded_ops={"torch.ops.aten.flatten.using_ints"},
6565
autocast_max_output_threshold=512,
6666
autocast_max_depth_of_reduction=None,
6767
autocast_calibration_dataloader=calibration_dataloader,

py/torch_tensorrt/dynamo/lowering/passes/nodeclassifier.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
from typing import Collection, Optional
77

88
import torch
9+
from torch_tensorrt.dynamo.conversion._ConverterRegistry import (
10+
ConverterRegistry,
11+
)
912

1013
logger = logging.getLogger(__name__)
1114

@@ -78,7 +81,8 @@ def __init__(self, excluded_ops):
7881
self.excluded_ops = excluded_ops
7982

8083
def _check_inner(self, node):
81-
return node.target in self.excluded_ops
84+
node_name = ConverterRegistry.qualified_name_or_str(node.target)
85+
return node_name in self.excluded_ops
8286

8387

8488
class IORangeRule(NodeRuleBase):

py/torch_tensorrt/dynamo/lowering/passes/rule_based_autocast.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def rule_based_autocast(
4141
reference_data: dict[str, torch.Tensor] = (
4242
settings.autocast_intermediate_node_outputs
4343
)
44+
del settings.autocast_intermediate_node_outputs
4445

4546
node_classifier = NodeClassifier(
4647
gm.graph.nodes,

tests/py/dynamo/models/test_autocast.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def forward(self, x):
5656
enable_autocast=True,
5757
autocast_low_precision_type=torch.float16,
5858
autocast_excluded_nodes={"^conv1$", "relu"},
59-
autocast_excluded_ops={torch.ops.aten.flatten.using_ints},
59+
autocast_excluded_ops={"torch.ops.aten.flatten.using_ints"},
6060
autocast_max_output_threshold=512,
6161
autocast_max_depth_of_reduction=None,
6262
autocast_calibration_dataloader=calibration_dataloader,
@@ -147,7 +147,7 @@ def forward(self, x):
147147
enable_autocast=True,
148148
autocast_low_precision_type=torch.bfloat16,
149149
autocast_excluded_nodes={"^conv1$", "relu"},
150-
autocast_excluded_ops={torch.ops.aten.flatten.using_ints},
150+
autocast_excluded_ops={"torch.ops.aten.flatten.using_ints"},
151151
autocast_max_output_threshold=512,
152152
autocast_max_depth_of_reduction=None,
153153
autocast_calibration_dataloader=calibration_dataloader,
@@ -220,13 +220,13 @@ def forward(self, x):
220220
ep.module(),
221221
arg_inputs=inputs,
222222
min_block_size=1,
223-
use_python_runtime=True,
223+
use_python_runtime=False,
224224
use_explicit_typing=True,
225225
# Torch-TensorRT's autocast doesn't affect layers inside Pytorch autocast
226226
enable_autocast=True,
227227
autocast_low_precision_type=torch.bfloat16,
228228
autocast_excluded_nodes={"^conv1$", "relu"},
229-
autocast_excluded_ops={torch.ops.aten.flatten.using_ints},
229+
autocast_excluded_ops={"torch.ops.aten.flatten.using_ints"},
230230
autocast_max_output_threshold=512,
231231
autocast_max_depth_of_reduction=None,
232232
autocast_calibration_dataloader=calibration_dataloader,
@@ -328,13 +328,13 @@ def forward(self, x, y):
328328
ep,
329329
arg_inputs=inputs,
330330
min_block_size=1,
331-
use_python_runtime=True,
331+
use_python_runtime=False,
332332
use_explicit_typing=True,
333333
# Torch-TensorRT's autocast doesn't affect layers inside Pytorch autocast
334334
enable_autocast=True,
335335
autocast_low_precision_type=torch.bfloat16,
336336
autocast_excluded_nodes={"^conv1$", "relu"},
337-
autocast_excluded_ops={torch.ops.aten.flatten.using_ints},
337+
autocast_excluded_ops={"torch.ops.aten.flatten.using_ints"},
338338
autocast_max_output_threshold=512,
339339
autocast_max_depth_of_reduction=None,
340340
autocast_calibration_dataloader=calibration_dataloader,

0 commit comments

Comments
 (0)