Skip to content

Commit 01b17f1

Browse files
tugsbayasgalanfacebook-github-bot
authored andcommitted
Remove redundant pt2_mode=True
Summary: Title Reviewed By: gmagogsfm Differential Revision: D48181683 fbshipit-source-id: b36b8ee863c63e87cf4ca298aed71e9424f4328d
1 parent d62a934 commit 01b17f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+195
-322
lines changed

backends/qnnpack/partition/support_patterns.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ def get_dynamic_quantized_graph(f, example_inputs, dynamic_shape=False):
4848
# Convert module
4949
converted_mod = _convert_to_reference_decomposed_fx(prepared_mod)
5050
if dynamic_shape:
51-
capture_config = CaptureConfig(pt2_mode=True, enable_dynamic_shape=True)
51+
capture_config = CaptureConfig(enable_dynamic_shape=True)
5252
else:
53-
capture_config = CaptureConfig(pt2_mode=True)
53+
capture_config = CaptureConfig()
5454
# EXIR trace
5555
gm = (
5656
exir.capture(converted_mod, example_inputs, capture_config)

backends/qnnpack/test/test_qnnpack.py

+10-16
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_qnnpack_per_channel_dynamic_mm(self):
8383
)
8484

8585
# Step 2: EXIR capturing
86-
capture_config = CaptureConfig(pt2_mode=True, enable_dynamic_shape=False)
86+
capture_config = CaptureConfig(enable_dynamic_shape=False)
8787
captured_mod = exir.capture(
8888
converted_mod, example_inputs, config=capture_config
8989
).to_edge(EDGE_COMPILE_CONFIG)
@@ -115,9 +115,7 @@ def forward(self, x):
115115

116116
composite_model(*example_inputs)
117117
program = (
118-
exir.capture(
119-
composite_model, example_inputs, exir.CaptureConfig(pt2_mode=True)
120-
)
118+
exir.capture(composite_model, example_inputs, exir.CaptureConfig())
121119
.to_edge(EDGE_COMPILE_CONFIG)
122120
.to_executorch(config=EXECUTORCH_BACKEND_CONFIG)
123121
.program
@@ -159,7 +157,7 @@ def test_qnnpack_per_channel_dynamic_qlinear(self):
159157
)
160158

161159
# Step 2: EXIR capturing
162-
capture_config = CaptureConfig(pt2_mode=True, enable_dynamic_shape=False)
160+
capture_config = CaptureConfig(enable_dynamic_shape=False)
163161
captured_mod = exir.capture(
164162
converted_mod, example_inputs, config=capture_config
165163
).to_edge(EDGE_COMPILE_CONFIG)
@@ -202,9 +200,7 @@ def forward(self, x):
202200

203201
composite_model(*example_inputs)
204202
program = (
205-
exir.capture(
206-
composite_model, example_inputs, exir.CaptureConfig(pt2_mode=True)
207-
)
203+
exir.capture(composite_model, example_inputs, exir.CaptureConfig())
208204
.to_edge(EDGE_COMPILE_CONFIG)
209205
.to_executorch(config=EXECUTORCH_BACKEND_CONFIG)
210206
.program
@@ -246,7 +242,7 @@ def test_qnnpack_per_tensor_dynamic_mm(self):
246242
)
247243

248244
# Step 2: EXIR capturing
249-
capture_config = CaptureConfig(pt2_mode=True, enable_dynamic_shape=False)
245+
capture_config = CaptureConfig(enable_dynamic_shape=False)
250246
captured_mod = exir.capture(
251247
converted_mod, example_inputs, config=capture_config
252248
).to_edge(EDGE_COMPILE_CONFIG)
@@ -321,7 +317,7 @@ def test_qnnpack_per_tensor_dynamic_qlinear(self):
321317
)
322318

323319
# Step 2: EXIR capturing
324-
capture_config = CaptureConfig(pt2_mode=True, enable_dynamic_shape=False)
320+
capture_config = CaptureConfig(enable_dynamic_shape=False)
325321
captured_mod = exir.capture(
326322
converted_mod, example_inputs, config=capture_config
327323
).to_edge(EDGE_COMPILE_CONFIG)
@@ -406,7 +402,7 @@ def test_qnnpack_per_channel_dynamic_mm_with_dynamic_shape(self):
406402
)
407403

408404
# Step 2: EXIR capturing
409-
capture_config = CaptureConfig(pt2_mode=True, enable_dynamic_shape=True)
405+
capture_config = CaptureConfig(enable_dynamic_shape=True)
410406
captured_mod = exir.capture(
411407
converted_mod, example_inputs, config=capture_config
412408
).to_edge(EDGE_COMPILE_CONFIG)
@@ -438,9 +434,7 @@ def forward(self, x):
438434

439435
composite_model(*example_inputs)
440436
program = (
441-
exir.capture(
442-
composite_model, example_inputs, exir.CaptureConfig(pt2_mode=True)
443-
)
437+
exir.capture(composite_model, example_inputs, exir.CaptureConfig())
444438
.to_edge(EDGE_COMPILE_CONFIG)
445439
.to_executorch(config=EXECUTORCH_BACKEND_CONFIG)
446440
.program
@@ -483,7 +477,7 @@ def test_qnnpack_per_channel_dynamic_qlinear_via_partitioner(self):
483477
)
484478

485479
# Step 2: EXIR capturing
486-
capture_config = CaptureConfig(pt2_mode=True, enable_dynamic_shape=False)
480+
capture_config = CaptureConfig(enable_dynamic_shape=False)
487481
captured_mod = exir.capture(
488482
converted_mod, example_inputs, config=capture_config
489483
).to_edge(EDGE_COMPILE_CONFIG)
@@ -538,7 +532,7 @@ def test_qnnpack_per_channel_dynamic_qlinear_via_partitioner(self):
538532
# composite_model(*example_inputs)
539533
# program = (
540534
# exir.capture(
541-
# composite_model, example_inputs, exir.CaptureConfig(pt2_mode=True)
535+
# composite_model, example_inputs, exir.CaptureConfig()
542536
# )
543537
# .to_edge(EDGE_COMPILE_CONFIG)
544538
# .to_executorch()

backends/qnnpack/test/test_qnnpack_partitioner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def get_actual_dyanmic_quantized_graph(
5454
converted_mod = _convert_to_reference_decomposed_fx(prepared_mod)
5555

5656
# Step 2: EXIR capturing
57-
capture_config = CaptureConfig(pt2_mode=True, enable_dynamic_shape=dynamic_shape)
57+
capture_config = CaptureConfig(enable_dynamic_shape=dynamic_shape)
5858
dynamic_quantized_exir_graph = (
5959
exir.capture(converted_mod, example_inputs, config=capture_config)
6060
.to_edge(exir.EdgeCompileConfig(_check_ir_validity=False))

backends/vulkan/test/test_vulkan_delegate.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ def lower_module_and_test_output(
6161
the given sample inputs. It then runs the lowered module and compares its
6262
outputs with the outputs of the eager module.
6363
"""
64-
edgeir_m = exir.capture(
65-
module, sample_inputs, exir.CaptureConfig(pt2_mode=True)
66-
).to_edge()
64+
edgeir_m = exir.capture(module, sample_inputs, exir.CaptureConfig()).to_edge()
6765
lowered_module = to_backend("VulkanBackend", edgeir_m.exported_program, [])
6866

6967
class WrappedModule(torch.nn.Module):
@@ -75,9 +73,7 @@ def forward(self, *args):
7573
return self.one_module(*args)
7674

7775
program = (
78-
exir.capture(
79-
WrappedModule(), sample_inputs, exir.CaptureConfig(pt2_mode=True)
80-
)
76+
exir.capture(WrappedModule(), sample_inputs, exir.CaptureConfig())
8177
.to_edge()
8278
.to_executorch()
8379
.program

backends/xnnpack/partition/support_patterns.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
exir.capture(
4242
add,
4343
model_inputs,
44-
config=CaptureConfig(pt2_mode=True, enable_dynamic_shape=True),
44+
config=CaptureConfig(enable_dynamic_shape=True),
4545
)
4646
.to_edge().module
4747
.graph
@@ -68,7 +68,7 @@
6868

6969

7070
def _capture(module, example_inputs, pt_mode=True) -> torch.fx.GraphModule:
71-
capture_config = CaptureConfig(pt2_mode=pt_mode, enable_dynamic_shape=False)
71+
capture_config = CaptureConfig(enable_dynamic_shape=False)
7272
edge_config = exir.EdgeCompileConfig(
7373
_check_ir_validity=False,
7474
passes=[DuplicateDequantNodePass()],

backends/xnnpack/test/test_xnnpack.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def test_xnnpack_backend_conv2d_dw(self):
236236
conv.eval()
237237
self.lower_and_test_with_partitioner(conv, example_inputs)
238238

239-
@torch.inference_mode() # TODO Use pt2_mode=True for capturing.
239+
@torch.inference_mode() # TODO Use for capturing.
240240
def test_xnnpack_backend_mm(self):
241241
in_sizes = [1, 4, 4]
242242
input_sizes = [4, 37, 17]
@@ -329,7 +329,7 @@ def forward(self, x, y):
329329
)
330330
self.lower_and_test_with_partitioner(module, model_inputs)
331331

332-
@torch.inference_mode() # TODO Use pt2_mode=True for capturing.
332+
@torch.inference_mode() # TODO Use for capturing.
333333
def test_xnnpack_backend_linear(self):
334334
in_size = 2
335335
input_size = 3

backends/xnnpack/utils/configs.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ def get_xnnpack_executorch_backend_config(
3434

3535
def get_xnnpack_capture_config(dynamic_shape=False, enable_aot: Optional[bool] = None):
3636
if enable_aot is None:
37-
return CaptureConfig(pt2_mode=True, enable_dynamic_shape=dynamic_shape)
37+
return CaptureConfig(enable_dynamic_shape=dynamic_shape)
3838
else:
39-
return CaptureConfig(
40-
pt2_mode=True, enable_dynamic_shape=dynamic_shape, enable_aot=enable_aot
41-
)
39+
return CaptureConfig(enable_dynamic_shape=dynamic_shape, enable_aot=enable_aot)

bundled_program/tests/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def get_common_program() -> Tuple[Program, BundledConfig]:
229229
DEFAULT_INT_INPUT,
230230
)
231231
program = (
232-
exir.capture(eager_model, capture_input, CaptureConfig(pt2_mode=True))
232+
exir.capture(eager_model, capture_input, CaptureConfig())
233233
.to_edge()
234234
.to_executorch()
235235
.program

exir/backend/test/demos/rpc/test_rpc.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def test_delegate_whole_program(self):
103103
simple_net = self.get_a_simple_net()
104104
simple_net_input = simple_net.get_example_inputs()
105105
exported_program = exir.capture(
106-
simple_net, simple_net_input, exir.CaptureConfig(pt2_mode=True)
106+
simple_net, simple_net_input, exir.CaptureConfig()
107107
).to_edge(
108108
exir.EdgeCompileConfig(
109109
_check_ir_validity=False,
@@ -125,9 +125,7 @@ def forward(self, *args):
125125
composite_model = CompositeModule()
126126

127127
exec_prog = (
128-
exir.capture(
129-
composite_model, simple_net_input, exir.CaptureConfig(pt2_mode=True)
130-
)
128+
exir.capture(composite_model, simple_net_input, exir.CaptureConfig())
131129
.to_edge()
132130
.to_executorch()
133131
)
@@ -165,9 +163,7 @@ def forward(self, a, x, b):
165163
model = Model()
166164
inputs = (torch.ones(2, 2), torch.ones(2, 2), torch.ones(2, 2))
167165

168-
exported_program = exir.capture(
169-
model, inputs, exir.CaptureConfig(pt2_mode=True)
170-
).to_edge()
166+
exported_program = exir.capture(model, inputs, exir.CaptureConfig()).to_edge()
171167

172168
# First lower to demo backend
173169
demo_backend_lowered = exported_program

exir/backend/test/demos/test_delegate_aten_mode.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def forward(self, a, x, b):
3737
add_mul_module = AddMulModule()
3838
model_inputs = (torch.ones(2, 2), 2 * torch.ones(2, 2), 3 * torch.ones(2, 2))
3939
edge_graph_module = exir.capture(
40-
add_mul_module, model_inputs, exir.CaptureConfig(pt2_mode=True)
40+
add_mul_module, model_inputs, exir.CaptureConfig()
4141
).to_edge()
4242
max_value = model_inputs[0].shape[0]
4343
compile_specs = [CompileSpec("max_value", bytes([max_value]))]
@@ -60,9 +60,7 @@ def forward(self, a, x, b):
6060
composite_model(*model_inputs)
6161

6262
exec_prog = (
63-
exir.capture(
64-
composite_model, model_inputs, exir.CaptureConfig(pt2_mode=True)
65-
)
63+
exir.capture(composite_model, model_inputs, exir.CaptureConfig())
6664
.to_edge()
6765
.to_executorch()
6866
)

exir/backend/test/demos/test_xnnpack_qnnpack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def forward(self, x, y):
8181
)
8282

8383
# Step 2: EXIR capturing
84-
capture_config = CaptureConfig(pt2_mode=True, enable_dynamic_shape=False)
84+
capture_config = CaptureConfig(enable_dynamic_shape=False)
8585
captured_mod = exir.capture(
8686
converted_mod, example_inputs, config=capture_config
8787
).to_edge(

exir/backend/test/hta_partitioner_demo.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def forward(self, x_raw, h, c):
6262
exir.capture(
6363
LSTMConvPattern(),
6464
(input_x, input_h, input_c),
65-
exir.CaptureConfig(pt2_mode=True, enable_aot=True),
65+
exir.CaptureConfig(enable_aot=True),
6666
)
6767
.to_edge(
6868
# torch._export.verifier.SpecViolationError: Operator torch._ops.aten.mkldnn_rnn_layer.default is not Aten Canonical.
@@ -74,7 +74,7 @@ def forward(self, x_raw, h, c):
7474
exir.capture(
7575
LSTMConvPattern(),
7676
(input_x, input_h, input_c),
77-
exir.CaptureConfig(pt2_mode=True),
77+
exir.CaptureConfig(),
7878
)
7979
.to_edge(
8080
# torch._export.verifier.SpecViolationError: Operator torch._ops.aten.mkldnn_rnn_layer.default is not Aten Canonical.
@@ -90,7 +90,7 @@ def sub(x, y):
9090
exir.capture(
9191
sub,
9292
(input_x, input_h),
93-
exir.CaptureConfig(pt2_mode=True, enable_aot=True, _unlift=False),
93+
exir.CaptureConfig(enable_aot=True, _unlift=False),
9494
)
9595
.to_edge(exir.EdgeCompileConfig(_use_edge_ops=True))
9696
.exported_program.graph_module
@@ -99,7 +99,7 @@ def sub(x, y):
9999
exir.capture(
100100
sub,
101101
(input_x, input_h),
102-
exir.CaptureConfig(pt2_mode=True),
102+
exir.CaptureConfig(),
103103
)
104104
.to_edge()
105105
.exported_program.graph_module
@@ -236,7 +236,7 @@ def forward(self, x_raw, h, c):
236236
exir.capture(
237237
LSTMConvPattern(),
238238
(input_x, input_h, input_c),
239-
exir.CaptureConfig(pt2_mode=True, enable_aot=True),
239+
exir.CaptureConfig(enable_aot=True),
240240
)
241241
.to_edge(
242242
# torch._export.verifier.SpecViolationError: Operator torch._ops.aten.mkldnn_rnn_layer.default is not Aten Canonical.
@@ -248,7 +248,7 @@ def forward(self, x_raw, h, c):
248248
exir.capture(
249249
LSTMConvPattern(),
250250
(input_x, input_h, input_c),
251-
exir.CaptureConfig(pt2_mode=True),
251+
exir.CaptureConfig(),
252252
)
253253
.to_edge(
254254
# torch._export.verifier.SpecViolationError: Operator torch._ops.aten.mkldnn_rnn_layer.default is not Aten Canonical.

0 commit comments

Comments
 (0)