You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the **Core ML** backend delegates the whole module to **Core ML**. If a specific op is not supported by the **Core ML** backend then the `to_backend` call would throw an exception. We will be adding a **Core ML Partitioner** to resolve the issue.
59
+
The module will be fully or partially delegated to **Core ML**, depending on whether all or part of ops are supported by the **Core ML** backend. User may force skip certain ops by `CoreMLPartitioner(skip_ops_for_coreml_delegation=...)`
60
+
61
+
The `to_backend` implementation is a thin wrapper over [coremltools](https://apple.github.io/coremltools/docs-guides/), `coremltools` is responsible for converting an **ExportedProgram** to a **MLModel**. The converted **MLModel** data is saved, flattened, and returned as bytes to **ExecuTorch**.
62
+
63
+
## Quantization
64
+
65
+
To quantize a Program in a Core ML favored way, the client may utilize **CoreMLQuantizer**.
66
+
67
+
```python
68
+
import torch
69
+
import executorch.exir
70
+
71
+
from torch._export import capture_pre_autograd_graph
72
+
from torch.ao.quantization.quantize_pt2e import (
73
+
convert_pt2e,
74
+
prepare_pt2e,
75
+
prepare_qat_pt2e,
76
+
)
77
+
78
+
from executorch.backends.apple.coreml.quantizer.coreml_quantizer import CoreMLQuantizer
79
+
from coremltools.optimize.torch.quantization.quantization_config import (
The `to_backend` implementation is a thin wrapper over `coremltools`, `coremltools` is responsible for converting an **ExportedProgram**to a **MLModel**. The converted **MLModel** data is saved, flattened, and returned as bytes to **ExecuTorch**.
122
+
The `converted_graph`is the quantized torch model, and can be delegated to **Core ML** similarly through **CoreMLPartitioner**
0 commit comments