Skip to content

Commit 6839212

Browse files
committed
Add Core ML test for _clone_dim_order
1 parent 8d0cb06 commit 6839212

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

backends/apple/coreml/test/test_torch_ops.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,28 @@ def test_dequantize_codebook_embedding(self):
221221
et_prog = delegated_program.to_executorch()
222222
self._compare_outputs(et_prog, model, example_inputs)
223223

224+
def test__clone_dim_order_contiguous(self):
225+
class Model(torch.nn.Module):
226+
def forward(self, x):
227+
return torch.ops.dim_order_ops._clone_dim_order(
228+
x, dim_order=[0, 1, 2, 3]
229+
)
230+
231+
model, example_inputs = Model(), (torch.randn(1, 3, 8, 8),)
232+
ep = torch.export.export(model, example_inputs)
233+
delegated_program = executorch.exir.to_edge_transform_and_lower(
234+
ep,
235+
partitioner=[self._coreml_partitioner()],
236+
)
237+
for node in delegated_program.exported_program().graph.nodes:
238+
if node.op == "call_function":
239+
assert node.target.__name__ in [
240+
"executorch_call_delegate",
241+
"getitem",
242+
], f"Got unexpected node target after delegation: {node.target.__name__}"
243+
et_prog = delegated_program.to_executorch()
244+
self._compare_outputs(et_prog, model, example_inputs)
245+
224246

225247
if __name__ == "__main__":
226248
test_runner = TestTorchOps()
@@ -231,3 +253,4 @@ def test_dequantize_codebook_embedding(self):
231253
test_runner.test_dequantize_affine_c8w_embedding_b4w_linear()
232254
test_runner.test_dequantize_codebook_linear()
233255
test_runner.test_dequantize_codebook_embedding()
256+
test_runner.test__clone_dim_order_contiguous()

0 commit comments

Comments
 (0)