|
11 | 11 | selection and combine multiple backends optimally for target hardware.
|
12 | 12 | """
|
13 | 13 |
|
| 14 | +import sys |
14 | 15 | from typing import Dict, List
|
15 | 16 |
|
16 |
| -import coremltools as ct |
| 17 | +if sys.platform != "win32": |
| 18 | + import coremltools as ct |
| 19 | + from executorch.backends.apple.coreml.recipes import CoreMLRecipeType |
17 | 20 |
|
18 | 21 | # pyre-ignore
|
19 |
| -from executorch.backends.apple.coreml.recipes import CoreMLRecipeType |
20 | 22 | from executorch.backends.xnnpack.recipes import XNNPackRecipeType
|
21 | 23 | from executorch.export.recipe import ExportRecipe, RecipeType
|
22 | 24 |
|
23 | 25 |
|
24 | 26 | ## IOS Target configs
|
25 | 27 | # The following list of recipes are not exhaustive for CoreML; refer to CoreMLRecipeType for more detailed recipes.
|
26 |
| -IOS_CONFIGS: Dict[str, List[RecipeType]] = { |
27 |
| - # pyre-ignore |
28 |
| - "ios-arm64-coreml-fp32": [CoreMLRecipeType.FP32, XNNPackRecipeType.FP32], |
29 |
| - # pyre-ignore |
30 |
| - "ios-arm64-coreml-fp16": [CoreMLRecipeType.FP16], |
31 |
| - # pyre-ignore |
32 |
| - "ios-arm64-coreml-int8": [CoreMLRecipeType.PT2E_INT8_STATIC], |
33 |
| -} |
| 28 | +IOS_CONFIGS: Dict[str, List[RecipeType]] = ( |
| 29 | + { |
| 30 | + # pyre-ignore |
| 31 | + "ios-arm64-coreml-fp32": [CoreMLRecipeType.FP32, XNNPackRecipeType.FP32], |
| 32 | + # pyre-ignore |
| 33 | + "ios-arm64-coreml-fp16": [CoreMLRecipeType.FP16], |
| 34 | + # pyre-ignore |
| 35 | + "ios-arm64-coreml-int8": [CoreMLRecipeType.PT2E_INT8_STATIC], |
| 36 | + } |
| 37 | + if sys.platform != "win32" |
| 38 | + else {} |
| 39 | +) |
34 | 40 |
|
35 | 41 |
|
36 | 42 | def _create_target_recipe(
|
@@ -94,6 +100,9 @@ def get_ios_recipe(
|
94 | 100 | recipe = get_ios_recipe('ios-arm64-coreml-int8')
|
95 | 101 | session = export(model, recipe, example_inputs)
|
96 | 102 | """
|
| 103 | + if sys.platform == "win32": |
| 104 | + raise RuntimeError("iOS recipes are not available on Windows.") |
| 105 | + |
97 | 106 | if target_config not in IOS_CONFIGS:
|
98 | 107 | supported = list(IOS_CONFIGS.keys())
|
99 | 108 | raise ValueError(
|
|
0 commit comments