File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed
backends/apple/coreml/compiler
examples/apple/coreml/llama Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change 13
13
from coremltools .converters .mil .frontend import _utils
14
14
from coremltools .converters .mil .frontend .torch .ops import (
15
15
_get_inputs ,
16
+ _get_kwinputs ,
16
17
NUM_TO_NUMPY_DTYPE ,
17
18
NUM_TO_TORCH_DTYPE ,
18
19
split ,
20
+ to ,
19
21
transpose ,
20
22
unbind ,
21
23
)
24
26
register_torch_op ,
25
27
)
26
28
from coremltools .converters .mil .mil import types
29
+ from executorch .exir .dim_order_utils import get_memory_format
27
30
28
31
29
32
# https://github.com/apple/coremltools/pull/2556
@@ -44,6 +47,26 @@ def split_copy(context, node):
44
47
split (context , node )
45
48
46
49
50
+ @register_torch_op (
51
+ torch_alias = [
52
+ "dim_order_ops::_to_dim_order_copy" ,
53
+ "dim_order_ops._to_dim_order_copy" ,
54
+ ],
55
+ override = False ,
56
+ )
57
+ def _to_dim_order_copy (context , node ):
58
+ dim_order = _get_kwinputs (context , node , "dim_order" , default = [None ])[0 ]
59
+ node .kwinputs .pop ("dim_order" )
60
+
61
+ # In CoreML, dim_order.val will be an ndarray, so we convert it to a list
62
+ dim_order = [int (d ) for d in dim_order .val ]
63
+ memory_format = get_memory_format (dim_order )
64
+ assert (
65
+ memory_format == _torch .contiguous_format
66
+ ), "Only contiguous memory format is supported in CoreML"
67
+ to (context , node )
68
+
69
+
47
70
# https://github.com/apple/coremltools/pull/2558
48
71
@register_torch_op (
49
72
torch_alias = ["torchao::dequantize_affine" , "torchao.dequantize_affine" ],
Original file line number Diff line number Diff line change 21
21
22
22
from executorch .exir import to_edge_transform_and_lower
23
23
from executorch .exir .backend .utils import format_delegated_graph
24
- from executorch .exir .capture ._config import EdgeCompileConfig , ExecutorchBackendConfig
24
+ from executorch .exir .capture ._config import ExecutorchBackendConfig
25
25
from executorch .exir .passes import MemoryPlanningPass
26
26
from executorch .exir .passes .quant_fusion_pass import QuantFusionPass
27
27
from executorch .exir .passes .sym_shape_eval_pass import ConstraintBasedSymShapeEvalPass
@@ -203,10 +203,6 @@ def main() -> None:
203
203
edge_manager = to_edge_transform_and_lower (
204
204
ep ,
205
205
partitioner = [partitioner ],
206
- compile_config = EdgeCompileConfig (
207
- # TODO: fix lowering when dim_order is enabled
208
- _skip_dim_order = True ,
209
- ),
210
206
)
211
207
212
208
print ("Delegated program" )
You can’t perform that action at this time.
0 commit comments