Skip to content

Commit c69861d

Browse files
shoumikhinfacebook-github-bot
authored andcommitted
Ease Core ML partitioner and quantizer imports. (#3564)
Summary: Pull Request resolved: #3564 . Reviewed By: mcr229 Differential Revision: D57172491 fbshipit-source-id: c7724130d973ca8e7df510e9d5eb95c329c4c2bd
1 parent c853b3c commit c69861d

File tree

7 files changed

+26
-14
lines changed

7 files changed

+26
-14
lines changed

backends/apple/coreml/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import torch
2828
import executorch.exir
2929

3030
from executorch.backends.apple.coreml.compiler import CoreMLBackend
31-
from executorch.backends.apple.coreml.partition.coreml_partitioner import CoreMLPartitioner
31+
from executorch.backends.apple.coreml.partition import CoreMLPartitioner
3232

3333
class Model(torch.nn.Module):
3434
def __init__(self):
@@ -72,7 +72,7 @@ from torch.ao.quantization.quantize_pt2e import (
7272
prepare_qat_pt2e,
7373
)
7474

75-
from executorch.backends.apple.coreml.quantizer.coreml_quantizer import CoreMLQuantizer
75+
from executorch.backends.apple.coreml.quantizer import CoreMLQuantizer
7676
from coremltools.optimize.torch.quantization.quantization_config import (
7777
LinearQuantizerConfig,
7878
QuantizationScheme,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright © 2023 Apple Inc. All rights reserved.
2+
#
3+
# Please refer to the license found in the LICENSE file in the root directory of the source tree.
4+
5+
from .coreml_partitioner import CoreMLPartitioner
6+
7+
__all__ = [
8+
CoreMLPartitioner,
9+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright © 2023 Apple Inc. All rights reserved.
2+
#
3+
# Please refer to the license found in the LICENSE file in the root directory of the source tree.
4+
5+
from .coreml_quantizer import CoreMLQuantizer
6+
7+
__all__ = [
8+
CoreMLQuantizer,
9+
]

backends/apple/coreml/test/test_coreml_partitioner.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
import torch
1010
import torchvision
1111

12-
from executorch.backends.apple.coreml.partition.coreml_partitioner import (
13-
CoreMLPartitioner,
14-
)
12+
from executorch.backends.apple.coreml.partition import CoreMLPartitioner
1513

1614

1715
class TestCoreMLPartitioner(unittest.TestCase):

backends/apple/coreml/test/test_coreml_quantizer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
QuantizationScheme,
1515
)
1616

17-
from executorch.backends.apple.coreml.quantizer.coreml_quantizer import CoreMLQuantizer
17+
from executorch.backends.apple.coreml.quantizer import CoreMLQuantizer
1818
from torch._export import capture_pre_autograd_graph
1919
from torch.ao.quantization.quantize_pt2e import (
2020
convert_pt2e,

examples/apple/coreml/scripts/export.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
from executorch.backends.apple.coreml.compiler import CoreMLBackend
1818

19-
from executorch.backends.apple.coreml.partition.coreml_partitioner import (
20-
CoreMLPartitioner,
21-
)
19+
from executorch.backends.apple.coreml.partition import CoreMLPartitioner
2220
from executorch.exir import to_edge
2321

2422
from executorch.exir.backend.backend_api import to_backend

examples/models/llama2/lib/partitioner_lib.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,14 @@ def get_coreml_partitioner(args):
5757
args.use_kv_cache is True
5858
), "CoreML backend currently only supports static shape and use_kv_cache=True is the only way to support it at the moment"
5959
try:
60-
# pyre-ignore: Undefined import [21]: Could not find a module corresponding to import `executorch.backends.apple.coreml.partition.coreml_partitioner`.
60+
# pyre-ignore: Undefined import [21]: Could not find a module corresponding to import `coremltools`.
6161
import coremltools as ct
6262

6363
# pyre-ignore: Undefined import [21]: Could not find a module corresponding to import `executorch.backends.apple.coreml.compiler`
6464
from executorch.backends.apple.coreml.compiler import CoreMLBackend
6565

66-
# pyre-ignore: Undefined import [21]: Could not find a module corresponding to import `executorch.backends.apple.coreml.partition.coreml_partitioner`
67-
from executorch.backends.apple.coreml.partition.coreml_partitioner import (
68-
CoreMLPartitioner,
69-
)
66+
# pyre-ignore: Undefined import [21]: Could not find a module corresponding to import `executorch.backends.apple.coreml.partition`
67+
from executorch.backends.apple.coreml.partition import CoreMLPartitioner
7068
except ImportError:
7169
raise ImportError(
7270
"Please install the CoreML backend follwing https://pytorch.org/executorch/main/build-run-coreml.html"

0 commit comments

Comments
 (0)