Skip to content

Commit 8674a3c

Browse files
committed
chore: minor fixes
1 parent ce606fe commit 8674a3c

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

py/torch_tensorrt/dynamo/_exporter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def lift(
129129

130130
# Replace get_attr nodes with placeholder nodes and copy metadata.
131131
with gm.graph.inserting_before(first_user_input):
132+
# Ensure name doesn't contain period as it is used for submodules
132133
const_placeholder_node = gm.graph.placeholder(
133134
node.target.replace(".", "_")
134135
)

tests/py/dynamo/lowering/test_aten_lowering_passes.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import torch
2-
from torch.testing._internal.common_utils import TestCase, run_tests
3-
42
import torch_tensorrt
3+
from torch.testing._internal.common_utils import TestCase, run_tests
54

6-
from ..testing_utilities import DECIMALS_OF_AGREEMENT, lower_graph_testing
5+
from ..testing_utilities import (
6+
DECIMALS_OF_AGREEMENT,
7+
DECIMALS_OF_AGREEMENT_3,
8+
lower_graph_testing,
9+
)
710

811

912
class TestInputAsOutput(TestCase):
@@ -444,10 +447,11 @@ def forward(self, input, weight, bias):
444447
max_diff = float(
445448
torch.max(torch.abs(optimized_model_results - torch_model_results))
446449
)
450+
447451
self.assertAlmostEqual(
448452
max_diff,
449453
0,
450-
DECIMALS_OF_AGREEMENT,
454+
DECIMALS_OF_AGREEMENT_3,
451455
msg=f"Linear TRT outputs don't match with the original model.",
452456
)
453457
torch._dynamo.reset()

tests/py/dynamo/models/test_models_export.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ def test_bert_base_uncased(ir):
159159
model = BertModel.from_pretrained("bert-base-uncased").cuda().eval()
160160
input = torch.randint(0, 1, (1, 14), dtype=torch.int32).to("cuda")
161161
input2 = torch.randint(0, 1, (1, 14), dtype=torch.int32).to("cuda")
162-
model = (
163-
transformers_trace(model, input_names=["input_ids", "attention_mask"])
164-
.eval()
165-
.cuda()
166-
)
162+
# model = (
163+
# transformers_trace(model, input_names=["input_ids", "attention_mask"])
164+
# .eval()
165+
# .cuda()
166+
# )
167167

168168
compile_spec = {
169169
"inputs": [
@@ -182,8 +182,8 @@ def test_bert_base_uncased(ir):
182182
"enabled_precisions": {torch.float},
183183
"truncate_long_and_double": True,
184184
"ir": ir,
185-
"min_block_size": 10,
186-
"torch_executed_ops": {"torch.ops.aten.gelu.default"},
185+
"min_block_size": 15,
186+
"debug": True,
187187
}
188188
trt_mod = torchtrt.compile(model, **compile_spec)
189189
model_outputs = model(input, input2)
@@ -192,8 +192,9 @@ def test_bert_base_uncased(ir):
192192
len(model_outputs) == len(trt_model_outputs),
193193
msg=f"Number of outputs for BERT model compilation is different with Pytorch {len(model_outputs)} and TensorRT {len(trt_model_outputs)}. Please check the compilation.",
194194
)
195-
for index, key in enumerate(model_outputs):
196-
out, trt_out = model_outputs[key], trt_model_outputs[index]
195+
196+
for key, _ in model_outputs.items():
197+
out, trt_out = model_outputs[key], trt_model_outputs[key]
197198
cos_sim = cosine_similarity(out, trt_out)
198199
assertions.assertTrue(
199200
cos_sim > COSINE_THRESHOLD,

tests/py/dynamo/testing_utilities.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
)
1515

1616
DECIMALS_OF_AGREEMENT = 4
17+
DECIMALS_OF_AGREEMENT_3 = 3
1718

1819

1920
def fx_dynamo_testing_backend(

0 commit comments

Comments
 (0)