|
33 | 33 | logger.setLevel(get_coreml_log_level(default_level=logging.INFO)) |
34 | 34 |
|
35 | 35 |
|
| 36 | +# Ops that the CoreML partitioner must always reject regardless of their |
| 37 | +# arguments. Each entry is annotated with the upstream issue that motivates |
| 38 | +# it so future readers can tell when an entry is safe to drop. |
| 39 | +_UNSUPPORTED_OP_TARGETS = frozenset( |
| 40 | + [ |
| 41 | + # https://github.com/apple/coremltools/issues/2565 — diagonal has a |
| 42 | + # CoreML correctness bug. |
| 43 | + torch.ops.aten.diagonal.default, |
| 44 | + torch.ops.aten.diagonal_copy.default, |
| 45 | + exir_ops.edge.aten.diagonal.default, |
| 46 | + exir_ops.edge.aten.diagonal_copy.default, |
| 47 | + # https://github.com/apple/coremltools/issues/2569 — acosh / asinh |
| 48 | + # are not implemented in coremltools. |
| 49 | + torch.ops.aten.acosh.default, |
| 50 | + exir_ops.edge.aten.acosh.default, |
| 51 | + torch.ops.aten.asinh.default, |
| 52 | + exir_ops.edge.aten.asinh.default, |
| 53 | + # https://github.com/pytorch/executorch/issues/11722 — only |
| 54 | + # ``aten.rand.default`` actually reaches an unimplemented branch in |
| 55 | + # coremltools 9.0 ("not enough values to unpack (expected 5, got 1)" |
| 56 | + # raised from the rand handler). ``randn`` / ``rand_like`` / |
| 57 | + # ``randn_like`` / ``randint`` lower cleanly today, so we leave them |
| 58 | + # delegated. Verified locally against coremltools 9.0 / Python 3.10 |
| 59 | + # by lowering each op in isolation. |
| 60 | + torch.ops.aten.rand.default, |
| 61 | + exir_ops.edge.aten.rand.default, |
| 62 | + ] |
| 63 | +) |
| 64 | + |
| 65 | + |
36 | 66 | def _is_view_op(op: torch._ops.OpOverload) -> bool: |
37 | 67 | schema = op._schema |
38 | 68 | if len(schema.arguments) == 0: |
@@ -92,27 +122,13 @@ def should_override_support(self, node) -> bool: |
92 | 122 | ) |
93 | 123 | return True |
94 | 124 |
|
95 | | - # https://github.com/apple/coremltools/issues/2565 |
96 | | - if node.target in [ |
97 | | - torch.ops.aten.diagonal.default, |
98 | | - torch.ops.aten.diagonal_copy.default, |
99 | | - exir_ops.edge.aten.diagonal.default, |
100 | | - exir_ops.edge.aten.diagonal_copy.default, |
101 | | - ]: |
102 | | - self.log_once( |
103 | | - "torch.ops.aten.diagonal.default has a bug in CoreML. Overriding op support." |
104 | | - ) |
105 | | - return True |
106 | | - |
107 | | - # https://github.com/apple/coremltools/issues/2569 |
108 | | - if node.target in [ |
109 | | - torch.ops.aten.acosh.default, |
110 | | - exir_ops.edge.aten.acosh.default, |
111 | | - torch.ops.aten.asinh.default, |
112 | | - exir_ops.edge.aten.asinh.default, |
113 | | - ]: |
| 125 | + # Ops that are unsupported by CoreML purely on the basis of their |
| 126 | + # target — no per-arg conditions to check. Grouped by upstream issue |
| 127 | + # so the comment trail still points at the underlying coremltools / |
| 128 | + # executorch bug for each entry. |
| 129 | + if node.target in _UNSUPPORTED_OP_TARGETS: |
114 | 130 | self.log_once( |
115 | | - "torch.ops.aten.{acosh, asinh}.default is not supported by CoreML. Overriding op support." |
| 131 | + f"{node.target} is not supported by CoreML. Overriding op support." |
116 | 132 | ) |
117 | 133 | return True |
118 | 134 |
|
|
0 commit comments