Skip to content

executorch/backends/apple/coreml/test #9054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backends/apple/coreml/test/test_coreml_partitioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def forward(self, q, k, v, mask):
v = torch.randn(batch_size, n_heads, max_seq_length, embedding_dim)
mask = torch.randn(seq_len, max_seq_length)
example_inputs = (q, k, v, mask)
ep = torch.export.export(model, example_inputs)
ep = torch.export.export(model, example_inputs, strict=True)
coreml_partitioner = CoreMLPartitioner()

# Using to_edge_transform_and_lower, we expect SDPA will be preserved and show up in delegated graph
Expand Down
2 changes: 1 addition & 1 deletion backends/qualcomm/_passes/decompose_any.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def call(self, graph_module: torch.fx.GraphModule) -> PassResult:
keepdim = node.args[2] if len(node.args) > 2 else False
model = Any(dim, keepdim)
edge_mgr = to_edge(
torch.export.export(model, (node.args[0].meta["val"],))
torch.export.export(model, (node.args[0].meta["val"],), strict=True)
)
decomposed_module = edge_mgr.exported_program()

Expand Down
6 changes: 4 additions & 2 deletions backends/qualcomm/_passes/decompose_linalg_vector_norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ def call(self, graph_module: torch.fx.GraphModule) -> PassResult:
model = LinalgVectorNorm(ord, dim, keepdim)
if self.aten_dialect_capture:
decomposed_module = torch.export.export(
model, (node.args[0].meta["val"],)
model, (node.args[0].meta["val"],), strict=True
).module()
else:
edge_mgr = to_edge(
torch.export.export(model, (node.args[0].meta["val"],))
torch.export.export(
model, (node.args[0].meta["val"],), strict=True
)
)
decomposed_module = edge_mgr.exported_program()

Expand Down
4 changes: 3 additions & 1 deletion backends/qualcomm/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,9 @@ def get_qdq_module(
dynamic_shapes: Dict = None,
bypass_check: bool = False,
) -> torch.fx.GraphModule:
m = torch.export.export(module, inputs, dynamic_shapes=dynamic_shapes).module()
m = torch.export.export(
module, inputs, dynamic_shapes=dynamic_shapes, strict=True
).module()

quantizer = QnnQuantizer()
quantizer.add_custom_quant_annotations(custom_quant_annotations)
Expand Down
2 changes: 1 addition & 1 deletion backends/qualcomm/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def capture_program(
dynamic_shapes: Dict = None,
) -> exir.ExirExportedProgram:
module = _preprocess_module(module, inputs)
ep = torch.export.export(module, inputs, dynamic_shapes=dynamic_shapes)
ep = torch.export.export(module, inputs, dynamic_shapes=dynamic_shapes, strict=True)
decomposed_ep = ep.run_decompositions(get_decomp_table())
core_ep = ExirExportedProgram(decomposed_ep, False)
core_ep.transform(TensorI64toI32(edge_program=core_ep))
Expand Down
2 changes: 1 addition & 1 deletion backends/transforms/test/test_rank_0_to_rank_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def forward(self, x, y):
model.eval()

example_inputs = (torch.tensor(1.0), torch.tensor(2.0))
aten = torch.export.export(model, example_inputs)
aten = torch.export.export(model, example_inputs, strict=True)

# Check that the input rank is 0
for node in aten.graph.nodes:
Expand Down
5 changes: 1 addition & 4 deletions examples/apple/coreml/llama/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,7 @@ def main() -> None:
)
example_inputs = input_manager.get_inputs(tokens=[0])

ep = torch.export.export(
model,
example_inputs,
)
ep = torch.export.export(model, example_inputs, strict=True)
print("Exported program")
print(ep)

Expand Down
2 changes: 1 addition & 1 deletion exir/tests/test_memory_planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ def forward(self, input, label):
net = TrainingNet(Net())
inputs = (torch.randn(1, 6, 5, 5), torch.ones(1, dtype=torch.int64))

ep = export(net, inputs)
ep = export(net, inputs, strict=True)
ep = _export_forward_backward(ep)
ep = to_edge(ep)
ep = ep.to_executorch()
Expand Down
2 changes: 1 addition & 1 deletion exir/verification/test/test_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def forward(self, input, label):
net = TrainingNet(Net())
inputs = (torch.randn(1, 6, 5, 5), torch.ones(1, dtype=torch.int64))

export_model = export(net, inputs)
export_model = export(net, inputs, strict=True)
export_model = _export_forward_backward(export_model)

edge = to_edge(export_model)
Expand Down
Loading