Skip to content

Commit 34e0570

Browse files
authored
executorch/exir/program/test
Differential Revision: D67383235 Pull Request resolved: #7397
1 parent c947fed commit 34e0570

File tree

72 files changed

+396
-587
lines changed

Some content is hidden

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

72 files changed

+396
-587
lines changed

backends/apple/coreml/runtime/test/export_stateful_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def main() -> None:
4747
torch.randn((1, embedding_dim)),
4848
torch.tensor([0]),
4949
)
50-
exported_model = export(model, example_inputs)
50+
exported_model = export(model, example_inputs, strict=True)
5151
edge_program_manager = exir.to_edge(exported_model)
5252
compile_specs = CoreMLBackend.generate_compile_specs(
5353
compute_precision=ct.precision.FLOAT16,

backends/apple/coreml/test/test_coreml_partitioner.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717

1818
class TestCoreMLPartitioner(unittest.TestCase):
19-
2019
# TODO(T182928844): Delegate dim order op to backend.
2120
edge_compile_config = executorch.exir.EdgeCompileConfig(_skip_dim_order=True)
2221

@@ -34,7 +33,7 @@ def forward(self, a, x, b):
3433
model.eval()
3534

3635
example_inputs = (torch.randn(2, 2), torch.randn(2, 2), torch.randn(2, 2))
37-
exir_program_aten = torch.export.export(model, example_inputs)
36+
exir_program_aten = torch.export.export(model, example_inputs, strict=True)
3837

3938
edge_program_manager = executorch.exir.to_edge(
4039
exir_program_aten, compile_config=self.edge_compile_config
@@ -61,7 +60,7 @@ def test_vit_skip_conv(self):
6160
model.eval()
6261

6362
example_inputs = (torch.randn(1, 3, 224, 224),)
64-
exir_program_aten = torch.export.export(model, example_inputs)
63+
exir_program_aten = torch.export.export(model, example_inputs, strict=True)
6564
edge_program_manager = executorch.exir.to_edge(
6665
exir_program_aten, compile_config=self.edge_compile_config
6766
)
@@ -106,7 +105,7 @@ def forward(self, q, k_val, input_pos):
106105
k_val = torch.randn((1, embedding_dim))
107106
input_pos = torch.tensor([0])
108107
example_inputs = (q, k_val, input_pos)
109-
exir_program_aten = torch.export.export(model, example_inputs)
108+
exir_program_aten = torch.export.export(model, example_inputs, strict=True)
110109

111110
compile_specs = CoreMLBackend.generate_compile_specs(
112111
minimum_deployment_target=ct.target.iOS18

backends/apple/mps/test/test_mps_utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,7 @@ def lower_module_and_test_output(
247247
)
248248

249249
executorch_program = to_edge(
250-
export(
251-
delegated_program,
252-
sample_inputs,
253-
),
250+
export(delegated_program, sample_inputs, strict=True),
254251
compile_config=exir.EdgeCompileConfig(
255252
_check_ir_validity=False,
256253
_skip_dim_order=True, # TODO(T182928844): Delegate dim order op to backend.

backends/cadence/aot/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def export_program(
176176
torch._C._set_mkldnn_enabled(False)
177177

178178
# else: capture the model and return it.
179-
expo_program = export(model, inputs)
179+
expo_program = export(model, inputs, strict=True)
180180

181181
if dump_graphs:
182182
logging.info("Exported graph:")

backends/example/test_example_delegate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def get_example_inputs():
6060

6161
quantized_gm = m
6262
exported_program = to_edge(
63-
export(quantized_gm, copy.deepcopy(example_inputs)),
63+
export(quantized_gm, copy.deepcopy(example_inputs), strict=True),
6464
compile_config=EDGE_COMPILE_CONFIG,
6565
)
6666

@@ -92,7 +92,7 @@ def test_delegate_mobilenet_v2(self):
9292

9393
quantized_gm = m
9494
exported_program = to_edge(
95-
export(quantized_gm, copy.deepcopy(example_inputs)),
95+
export(quantized_gm, copy.deepcopy(example_inputs), strict=True),
9696
compile_config=EDGE_COMPILE_CONFIG,
9797
)
9898

backends/qualcomm/tests/test_qnn_delegate.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ def test_qnn_backend_multi_contexts_composite(self):
16171617
)
16181618
sample_input = module.get_random_input()
16191619
edge_prog = to_edge(
1620-
torch.export.export(module, sample_input),
1620+
torch.export.export(module, sample_input, strict=True),
16211621
)
16221622
update_spill_fill_size(edge_prog.exported_program())
16231623
exec_prog = edge_prog.to_executorch()
@@ -1957,7 +1957,7 @@ def calibrator(gm):
19571957
self.assertEqual(len(exported_progs), 1)
19581958
# lower all graph again, the skipped operators will be left in CPU
19591959
exec_prog = to_edge(
1960-
torch.export.export(graph_module, sample_input),
1960+
torch.export.export(graph_module, sample_input, strict=True),
19611961
).to_executorch()
19621962
self.verify_output(module, sample_input, exec_prog)
19631963

@@ -2004,7 +2004,7 @@ def calibrator(gm):
20042004
self.assertEqual(len(exported_progs), 2)
20052005
# lower all graph again, the skipped operators will be left in CPU
20062006
exec_prog = exec_prog = to_edge(
2007-
torch.export.export(graph_module, sample_input),
2007+
torch.export.export(graph_module, sample_input, strict=True),
20082008
).to_executorch()
20092009
self.verify_output(module, sample_input, exec_prog)
20102010

@@ -2041,7 +2041,7 @@ def calibrator(gm):
20412041
self.assertEqual(len(exported_progs), 5)
20422042
# lower all graph again, the skipped operators will be delegated with fp16
20432043
exec_prog = to_edge(
2044-
torch.export.export(graph_module, sample_input),
2044+
torch.export.export(graph_module, sample_input, strict=True),
20452045
).to_executorch()
20462046
self.verify_output(module, sample_input, exec_prog)
20472047

@@ -2086,7 +2086,7 @@ def test_qnn_backend_multi_contexts_composite(self):
20862086
)
20872087
sample_input = module.get_random_input()
20882088
edge_prog = to_edge(
2089-
torch.export.export(module, sample_input),
2089+
torch.export.export(module, sample_input, strict=True),
20902090
)
20912091
update_spill_fill_size(edge_prog.exported_program())
20922092
exec_prog = edge_prog.to_executorch()
@@ -2721,7 +2721,6 @@ def test_ssd300_vgg16(self):
27212721

27222722

27232723
class TestExampleQaihubScript(TestQNN):
2724-
27252724
def required_envs(self, conditions=None) -> bool:
27262725
conditions = [] if conditions is None else conditions
27272726
return all(

backends/qualcomm/tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def get_qdq_module(
385385
custom_quant_annotations: Tuple[Callable] = (),
386386
quant_dtype: QuantDtype = QuantDtype.use_8a8w,
387387
) -> torch.fx.GraphModule:
388-
m = torch.export.export(module, inputs).module()
388+
m = torch.export.export(module, inputs, strict=True).module()
389389

390390
quantizer = QnnQuantizer()
391391
quantizer.add_custom_quant_annotations(custom_quant_annotations)

backends/qualcomm/utils/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def capture_program(
337337
inputs: Tuple[torch.Tensor],
338338
custom_pass_config: FrozenSet[str] = frozenset(),
339339
) -> exir.ExirExportedProgram:
340-
ep = torch.export.export(module, inputs)
340+
ep = torch.export.export(module, inputs, strict=True)
341341
decomposed_ep = ep.run_decompositions(get_decomp_table())
342342
# We choose call_operator by target in ConvertBinaryOpsWithScalar
343343
# because it is the same source_fn_stack for MultiheadAttention
@@ -551,7 +551,7 @@ def prepare_subgm(subgm, subgm_name):
551551

552552
fp_node_id_set = fp_node_id_set if fp_node_id_set is not None else set()
553553
fp_node_op_set = fp_node_op_set if fp_node_op_set is not None else set()
554-
graph_module = torch.export.export(nn_module, sample_input).module()
554+
graph_module = torch.export.export(nn_module, sample_input, strict=True).module()
555555
# define node support type
556556
capability_partitioner = CapabilityBasedPartitioner(
557557
graph_module,
@@ -664,7 +664,7 @@ def forward(self, *inputs):
664664
).default(inputs)
665665

666666
model = Model()
667-
prog = torch.export.export(model, tuple(inputs.values()))
667+
prog = torch.export.export(model, tuple(inputs.values()), strict=True)
668668
# bookkeeping for variables' life cycle
669669
return {
670670
"custom_op": custom_op,

backends/vulkan/test/test_vulkan_delegate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def run_test():
112112
model(*sample_inputs)
113113

114114
program: ExportedProgram = export(
115-
model, sample_inputs, dynamic_shapes=dynamic_shapes
115+
model, sample_inputs, dynamic_shapes=dynamic_shapes, strict=True
116116
)
117117

118118
edge_program = to_edge_transform_and_lower(

backends/xnnpack/partition/graphs/sdpa.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def forward(
7676
v,
7777
mask,
7878
),
79+
strict=True,
7980
),
8081
compile_config=get_xnnpack_edge_compile_config(),
8182
)

0 commit comments

Comments
 (0)