Skip to content

Commit 9507c6d

Browse files
jerryzh168Wei Wei
authored and
Wei Wei
committed
[quant] Rename _convert_do_not_use.py to convert.py (#74322)
Summary: X-link: pytorch/pytorch#74322 att, also change all references to _convert_do_not_use Reviewed By: andrewor14 Differential Revision: D34936430 fbshipit-source-id: c96fb887847383bf47f0ec4219127e96e2b63b2d
1 parent c41a6db commit 9507c6d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

test/quant/test_quant_trt.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
from fx2trt_oss.fx.utils import LowerPrecision
2020
from fx2trt_oss.tracer.acc_tracer import acc_ops
2121
from torch.ao.quantization import default_qconfig
22-
from torch.ao.quantization._quantize_fx_do_not_use import (
23-
_convert_fx_do_not_use,
22+
from torch.ao.quantization.quantize_fx import (
23+
convert_fx,
2424
)
2525
from torch.ao.quantization.fx.backend_config.observation_type import ObservationType
2626
from torch.ao.quantization.fx.match_utils import (
@@ -95,7 +95,7 @@ def forward(self, x):
9595
prepare_custom_config_dict=prepare_custom_config_dict)
9696
self.checkGraphModuleNodes(mp, expected_node_occurrence=prepare_count_check)
9797
mp(torch.randn(1, 1, 4, 4))
98-
mq = _convert_fx_do_not_use(
98+
mq = convert_fx(
9999
mp, is_reference=True, backend_config_dict=self.trt_backend_config_dict)
100100
self.checkGraphModuleNodes(mq, expected_node_occurrence=convert_count_check)
101101

@@ -229,15 +229,15 @@ def forward(self, x):
229229
self.checkGraphModuleNodes(m.standalone, expected_node_occurrence=standalone_prepare_count_check)
230230

231231
# check converted/quantized model
232-
m = _convert_fx_do_not_use(m, is_reference=True, backend_config_dict=backend_config_dict)
232+
m = convert_fx(m, is_reference=True, backend_config_dict=backend_config_dict)
233233
self.checkGraphModuleNodes(m, expected_node_occurrence=convert_count_check)
234234
self.checkGraphModuleNodes(m.standalone, expected_node_occurrence=standalone_convert_count_check)
235235
res = m(data)
236236

237237
# quantize the reference model
238238
ref_m = prepare_fx(original_ref_m_copy, qconfig_dict, backend_config_dict=backend_config_dict)
239239
ref_m(data)
240-
ref_m = _convert_fx_do_not_use(ref_m, is_reference=True, backend_config_dict=backend_config_dict)
240+
ref_m = convert_fx(ref_m, is_reference=True, backend_config_dict=backend_config_dict)
241241
ref_res = ref_m(data)
242242
self.assertEqual(res, ref_res)
243243

@@ -395,7 +395,7 @@ def _test_module(
395395
self.checkGraphModuleNodes(prepared, expected_node_occurrence=no_prepare)
396396
# calibration
397397
prepared(*inputs)
398-
quantized = _convert_fx_do_not_use(
398+
quantized = convert_fx(
399399
prepared, is_reference=True, backend_config_dict=self.trt_backend_config_dict)
400400
self.checkGraphModuleNodes(quantized, expected_node_occurrence=no_convert)
401401
# lower to trt
@@ -500,7 +500,7 @@ def forward(self, x):
500500

501501
m = M().eval()
502502
m = prepare_fx(m, {"": default_qconfig})
503-
m = _convert_fx_do_not_use(
503+
m = convert_fx(
504504
m, is_reference=True, backend_config_dict=self.trt_backend_config_dict)
505505
expected_occurrence = {
506506
ns.call_function(torch.quantize_per_tensor): 5,
@@ -530,7 +530,7 @@ def forward(self, x):
530530
prepared = prepare_fx(m, {"": trt_unsupported_qconfig}, backend_config_dict=self.trt_backend_config_dict)
531531
# calibration
532532
prepared(linear_module_input)
533-
quantized = _convert_fx_do_not_use(
533+
quantized = convert_fx(
534534
prepared, is_reference=True, backend_config_dict=self.trt_backend_config_dict)
535535
node_occurrence = {
536536
ns.call_function(torch.quantize_per_tensor): 0,
@@ -553,7 +553,7 @@ def forward(self, x):
553553
prepared = prepare_fx(
554554
m, {"": self.qconfig}, backend_config_dict=self.trt_backend_config_dict)
555555
self.assertTrue(len(dict(prepared.named_children())) == 1)
556-
quantized = _convert_fx_do_not_use(
556+
quantized = convert_fx(
557557
prepared, is_reference=True, backend_config_dict=self.trt_backend_config_dict)
558558
node_occurrence = {
559559
ns.call_function(torch.quantize_per_tensor): 2,
@@ -582,7 +582,7 @@ def forward(self, x):
582582
ns.call_module(torch.ao.quantization.HistogramObserver): 2,
583583
}
584584
self.checkGraphModuleNodes(prepared, expected_node_occurrence=node_occurrence)
585-
quantized = _convert_fx_do_not_use(
585+
quantized = convert_fx(
586586
prepared, is_reference=True, backend_config_dict=self.trt_backend_config_dict)
587587
node_occurrence = {
588588
# input activation, output activation and weight
@@ -630,7 +630,7 @@ def forward(self, x, y):
630630
ns.call_module(torch.ao.quantization.HistogramObserver): 3,
631631
}
632632
self.checkGraphModuleNodes(m, expected_node_occurrence=node_occurrence)
633-
m = _convert_fx_do_not_use(m, is_reference=True, backend_config_dict=modified_backend_config_dict)
633+
m = convert_fx(m, is_reference=True, backend_config_dict=modified_backend_config_dict)
634634
node_occurrence = {
635635
ns.call_function(torch.quantize_per_tensor): 3,
636636
ns.call_method("dequantize"): 3,
@@ -725,7 +725,7 @@ def forward(self, x, y):
725725
ns.call_module(torch.ao.quantization.HistogramObserver): 1,
726726
}
727727
self.checkGraphModuleNodes(m.standalone, expected_node_occurrence=standalone_node_occurrence)
728-
m = _convert_fx_do_not_use(m, is_reference=True, backend_config_dict=backend_config_dict)
728+
m = convert_fx(m, is_reference=True, backend_config_dict=backend_config_dict)
729729
node_occurrence = {
730730
# two inputs for standalone module
731731
ns.call_function(torch.quantize_per_tensor): 2,
@@ -757,7 +757,7 @@ def forward(self, x):
757757
inputs = torch.rand(8, 5)
758758

759759
prepared = prepare_fx(model, {"": self.qconfig}, backend_config_dict=self.trt_backend_config_dict)
760-
quantized = _convert_fx_do_not_use(
760+
quantized = convert_fx(
761761
prepared, is_reference=True, backend_config_dict=self.trt_backend_config_dict)
762762

763763
model = acc_tracer.trace(quantized, inputs)

0 commit comments

Comments
 (0)