ai-edge-litert-nightly 1.4.0.dev20250813__cp312-cp312-manylinux_2_27_aarch64.whl → 1.4.0.dev20250815__cp312-cp312-manylinux_2_27_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ai-edge-litert-nightly might be problematic. Click here for more details.
- ai_edge_litert/__init__.py +1 -1
- ai_edge_litert/libpywrap_litert_common.so +0 -0
- {ai_edge_litert_nightly-1.4.0.dev20250813.dist-info → ai_edge_litert_nightly-1.4.0.dev20250815.dist-info}/METADATA +1 -1
- {ai_edge_litert_nightly-1.4.0.dev20250813.dist-info → ai_edge_litert_nightly-1.4.0.dev20250815.dist-info}/RECORD +6 -31
- ai_edge_litert/aot/__init__.py +0 -0
- ai_edge_litert/aot/ai_pack/__init__.py +0 -0
- ai_edge_litert/aot/ai_pack/export_lib.py +0 -281
- ai_edge_litert/aot/aot_compile.py +0 -152
- ai_edge_litert/aot/core/__init__.py +0 -0
- ai_edge_litert/aot/core/apply_plugin.py +0 -146
- ai_edge_litert/aot/core/common.py +0 -95
- ai_edge_litert/aot/core/components.py +0 -93
- ai_edge_litert/aot/core/mlir_transforms.py +0 -36
- ai_edge_litert/aot/core/tflxx_util.py +0 -30
- ai_edge_litert/aot/core/types.py +0 -374
- ai_edge_litert/aot/prepare_for_npu.py +0 -152
- ai_edge_litert/aot/vendors/__init__.py +0 -18
- ai_edge_litert/aot/vendors/example/__init__.py +0 -0
- ai_edge_litert/aot/vendors/example/example_backend.py +0 -157
- ai_edge_litert/aot/vendors/fallback_backend.py +0 -128
- ai_edge_litert/aot/vendors/import_vendor.py +0 -132
- ai_edge_litert/aot/vendors/mediatek/__init__.py +0 -0
- ai_edge_litert/aot/vendors/mediatek/mediatek_backend.py +0 -196
- ai_edge_litert/aot/vendors/mediatek/target.py +0 -91
- ai_edge_litert/aot/vendors/qualcomm/__init__.py +0 -0
- ai_edge_litert/aot/vendors/qualcomm/qualcomm_backend.py +0 -161
- ai_edge_litert/aot/vendors/qualcomm/target.py +0 -74
- ai_edge_litert/libLiteRtRuntimeCApi.so +0 -0
- ai_edge_litert/tools/apply_plugin_main +0 -0
- {ai_edge_litert_nightly-1.4.0.dev20250813.dist-info → ai_edge_litert_nightly-1.4.0.dev20250815.dist-info}/WHEEL +0 -0
- {ai_edge_litert_nightly-1.4.0.dev20250813.dist-info → ai_edge_litert_nightly-1.4.0.dev20250815.dist-info}/top_level.txt +0 -0
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
# Copyright 2024 The TensorFlow Authors. All Rights Reserved.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
# ==============================================================================
|
|
15
|
-
|
|
16
|
-
"""Backend implementation for the example compiler plugin.."""
|
|
17
|
-
|
|
18
|
-
import copy
|
|
19
|
-
import functools
|
|
20
|
-
import itertools
|
|
21
|
-
import os
|
|
22
|
-
import pathlib
|
|
23
|
-
from typing import Iterable
|
|
24
|
-
|
|
25
|
-
from ai_edge_litert.aot.core import common
|
|
26
|
-
from ai_edge_litert.aot.core import components
|
|
27
|
-
from ai_edge_litert.aot.core import types
|
|
28
|
-
from ai_edge_litert.aot.vendors import import_vendor
|
|
29
|
-
from ai_edge_litert.aot.vendors.mediatek import target as target_lib
|
|
30
|
-
|
|
31
|
-
COMPILER_PLUGIN_LIB_PATH = pathlib.Path(
|
|
32
|
-
"vendors/mediatek/compiler/libLiteRtCompilerPlugin_MediaTek.so"
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
@import_vendor.register_backend
|
|
37
|
-
class MediaTekBackend(types.Backend):
|
|
38
|
-
"""Backend implementation for the example compiler plugin."""
|
|
39
|
-
|
|
40
|
-
def __init__(self, config: types.Config):
|
|
41
|
-
super().__init__(config)
|
|
42
|
-
self._compilation_config = config.get("compilation_config", None)
|
|
43
|
-
|
|
44
|
-
@property
|
|
45
|
-
def soc_manufacturer(self) -> target_lib.SocManufacturer:
|
|
46
|
-
return target_lib.SocManufacturer.MEDIATEK
|
|
47
|
-
|
|
48
|
-
@property
|
|
49
|
-
def soc_model(self) -> target_lib.SocModel:
|
|
50
|
-
return target_lib.SocModel(self.config.get("soc_model", "ALL"))
|
|
51
|
-
|
|
52
|
-
@property
|
|
53
|
-
def android_os_version(self) -> target_lib.AndroidOsVersion:
|
|
54
|
-
return target_lib.AndroidOsVersion(
|
|
55
|
-
self.config.get("android_os_version", "ALL")
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
@property
|
|
59
|
-
def target(self) -> target_lib.Target:
|
|
60
|
-
return target_lib.Target(
|
|
61
|
-
self.soc_model, self.soc_manufacturer, self.android_os_version
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
@property
|
|
65
|
-
def target_id(self) -> str:
|
|
66
|
-
return repr(self.target)
|
|
67
|
-
|
|
68
|
-
def specialize(self) -> Iterable["MediaTekBackend"]:
|
|
69
|
-
if (
|
|
70
|
-
self.soc_model != target_lib.SocModel.ALL
|
|
71
|
-
and self.android_os_version != target_lib.AndroidOsVersion.ALL
|
|
72
|
-
):
|
|
73
|
-
yield self
|
|
74
|
-
else:
|
|
75
|
-
if self.soc_model == target_lib.SocModel.ALL:
|
|
76
|
-
soc_models = filter(
|
|
77
|
-
lambda x: x != target_lib.SocModel.ALL, target_lib.SocModel
|
|
78
|
-
)
|
|
79
|
-
else:
|
|
80
|
-
soc_models = [self.soc_model]
|
|
81
|
-
if self.android_os_version == target_lib.AndroidOsVersion.ALL:
|
|
82
|
-
android_os_versions = [
|
|
83
|
-
x
|
|
84
|
-
for x in target_lib.AndroidOsVersion
|
|
85
|
-
if x != target_lib.AndroidOsVersion.ALL
|
|
86
|
-
]
|
|
87
|
-
else:
|
|
88
|
-
android_os_versions = [self.android_os_version]
|
|
89
|
-
for soc_model, android_os_version in itertools.product(
|
|
90
|
-
soc_models, android_os_versions
|
|
91
|
-
):
|
|
92
|
-
new_config = copy.deepcopy(self.config)
|
|
93
|
-
new_config["soc_model"] = soc_model.value
|
|
94
|
-
new_config["android_os_version"] = android_os_version.value
|
|
95
|
-
yield self.create(new_config)
|
|
96
|
-
|
|
97
|
-
@classmethod
|
|
98
|
-
def id(cls) -> str:
|
|
99
|
-
return target_lib._MEDIATEK_BACKEND_ID # pylint: disable=protected-access
|
|
100
|
-
|
|
101
|
-
@classmethod
|
|
102
|
-
def create(cls, config: types.Config) -> "MediaTekBackend":
|
|
103
|
-
if config.get("backend_id", "") != cls.id():
|
|
104
|
-
raise ValueError("Invalid backend id")
|
|
105
|
-
return cls(config)
|
|
106
|
-
|
|
107
|
-
@property
|
|
108
|
-
def quantize_recipe(self) -> str | None:
|
|
109
|
-
return self.config.get("quantize_recipe", None)
|
|
110
|
-
|
|
111
|
-
def call_component(
|
|
112
|
-
self,
|
|
113
|
-
input_model: types.Model,
|
|
114
|
-
output_model: types.Model,
|
|
115
|
-
component: types.Component,
|
|
116
|
-
):
|
|
117
|
-
return _call_component(component, self, input_model, output_model)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
@functools.singledispatch
|
|
121
|
-
def _call_component(
|
|
122
|
-
component: types.Component,
|
|
123
|
-
backend: MediaTekBackend,
|
|
124
|
-
unused_input_model: types.Model,
|
|
125
|
-
unused_output_model: types.Model,
|
|
126
|
-
):
|
|
127
|
-
raise NotImplementedError(
|
|
128
|
-
f"{backend.id()} backend does not support"
|
|
129
|
-
f" {component.component_name} component."
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
# TODO(toribiosteven): Translate SOC | OS version to the corresponding
|
|
134
|
-
# MediaTek SDK version and pass to the plugin.
|
|
135
|
-
@_call_component.register
|
|
136
|
-
def _apply_plugin(
|
|
137
|
-
component: components.ApplyPluginT,
|
|
138
|
-
backend: MediaTekBackend,
|
|
139
|
-
input_model: types.Model,
|
|
140
|
-
output_model: types.Model,
|
|
141
|
-
):
|
|
142
|
-
"""Calls the apply plugin component."""
|
|
143
|
-
try:
|
|
144
|
-
# If the plugin is not built from source (i.e. using ai_edge_litert wheel),
|
|
145
|
-
# we find the plugin library directory from the package path.
|
|
146
|
-
# Otherwise we use the default library path.
|
|
147
|
-
plugin_path = common.get_resource(COMPILER_PLUGIN_LIB_PATH)
|
|
148
|
-
lib_dir = os.path.dirname(plugin_path)
|
|
149
|
-
|
|
150
|
-
try:
|
|
151
|
-
# pytype: disable=import-error
|
|
152
|
-
import ai_edge_litert_sdk_mediatek # pylint: disable=g-import-not-at-top
|
|
153
|
-
# pytype: enable=import-error
|
|
154
|
-
|
|
155
|
-
# TODO(weiyiw): Translate SOC | OS version to the corresponding
|
|
156
|
-
# MediaTek SDK version and pass to the plugin.
|
|
157
|
-
sdk_version = "v8"
|
|
158
|
-
sdk_libs_path = str(
|
|
159
|
-
ai_edge_litert_sdk_mediatek.path_to_sdk_libs(sdk_version)
|
|
160
|
-
)
|
|
161
|
-
except ImportError:
|
|
162
|
-
sdk_libs_path = None
|
|
163
|
-
extra_kwargs = {"libs": lib_dir, "sdk_libs_path": sdk_libs_path}
|
|
164
|
-
except FileNotFoundError:
|
|
165
|
-
extra_kwargs = {}
|
|
166
|
-
return component(
|
|
167
|
-
input_model,
|
|
168
|
-
output_model,
|
|
169
|
-
backend.soc_manufacturer,
|
|
170
|
-
backend.soc_model.lower(),
|
|
171
|
-
**extra_kwargs,
|
|
172
|
-
)
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
@_call_component.register
|
|
176
|
-
def _aie_quantizer(
|
|
177
|
-
component: components.AieQuantizerT,
|
|
178
|
-
backend: MediaTekBackend,
|
|
179
|
-
input_model: types.Model,
|
|
180
|
-
output_model: types.Model,
|
|
181
|
-
):
|
|
182
|
-
return component(
|
|
183
|
-
input_model,
|
|
184
|
-
output_model,
|
|
185
|
-
quantization_recipe=backend.quantize_recipe,
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
@_call_component.register
|
|
190
|
-
def _mlir_transforms(
|
|
191
|
-
component: components.MlirTransformsT,
|
|
192
|
-
unused_backend: MediaTekBackend,
|
|
193
|
-
input_model: types.Model,
|
|
194
|
-
output_model: types.Model,
|
|
195
|
-
):
|
|
196
|
-
return component(input_model, output_model, [])
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"""Compilation target for MediaTek SOCs."""
|
|
2
|
-
|
|
3
|
-
import dataclasses
|
|
4
|
-
import sys
|
|
5
|
-
from typing import Any
|
|
6
|
-
|
|
7
|
-
from ai_edge_litert.aot.core import types
|
|
8
|
-
|
|
9
|
-
# pylint: disable=g-importing-member
|
|
10
|
-
# pylint: disable=g-import-not-at-top
|
|
11
|
-
# pylint: disable=g-bad-import-order
|
|
12
|
-
if sys.version_info >= (3, 11):
|
|
13
|
-
from enum import StrEnum # pylint: disable=g-importing-member
|
|
14
|
-
else:
|
|
15
|
-
from backports.strenum import StrEnum # pylint: disable=g-importing-member
|
|
16
|
-
# pylint: enable=g-bad-import-order
|
|
17
|
-
# pylint: enable=g-import-not-at-top
|
|
18
|
-
# pylint: enable=g-importing-member
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
_MEDIATEK_BACKEND_ID = "mediatek"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class SocModel(StrEnum):
|
|
25
|
-
"""MediaTek SOC model."""
|
|
26
|
-
|
|
27
|
-
ALL = "ALL"
|
|
28
|
-
|
|
29
|
-
MT6853 = "MT6853"
|
|
30
|
-
MT6877 = "MT6877"
|
|
31
|
-
MT6878 = "MT6878"
|
|
32
|
-
MT6879 = "MT6879"
|
|
33
|
-
MT6886 = "MT6886"
|
|
34
|
-
MT6893 = "MT6893"
|
|
35
|
-
MT6895 = "MT6895"
|
|
36
|
-
MT6897 = "MT6897"
|
|
37
|
-
MT6983 = "MT6983"
|
|
38
|
-
MT6985 = "MT6985"
|
|
39
|
-
MT6989 = "MT6989"
|
|
40
|
-
MT6991 = "MT6991"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class SocManufacturer(StrEnum):
|
|
44
|
-
"""MediaTek SOC manufacturer."""
|
|
45
|
-
|
|
46
|
-
MEDIATEK = "MediaTek"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
class AndroidOsVersion(StrEnum):
|
|
50
|
-
"""Android OS version."""
|
|
51
|
-
|
|
52
|
-
ALL = "ALL"
|
|
53
|
-
|
|
54
|
-
ANDROID_15 = "ANDROID_15"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
@dataclasses.dataclass
|
|
58
|
-
class Target(types.Target):
|
|
59
|
-
"""Compilation target for MediaTek SOCs."""
|
|
60
|
-
|
|
61
|
-
soc_model: SocModel
|
|
62
|
-
soc_manufacturer: SocManufacturer = SocManufacturer.MEDIATEK
|
|
63
|
-
android_os_version: AndroidOsVersion = AndroidOsVersion.ANDROID_15
|
|
64
|
-
|
|
65
|
-
@classmethod
|
|
66
|
-
def backend_id(cls) -> str:
|
|
67
|
-
return _MEDIATEK_BACKEND_ID
|
|
68
|
-
|
|
69
|
-
def __hash__(self) -> int:
|
|
70
|
-
return hash(
|
|
71
|
-
(self.soc_manufacturer, self.soc_model, self.android_os_version)
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
def __eq__(self, other: "Target") -> bool:
|
|
75
|
-
return (
|
|
76
|
-
self.soc_manufacturer == other.soc_manufacturer
|
|
77
|
-
and self.soc_model == other.soc_model
|
|
78
|
-
and self.android_os_version == other.android_os_version
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
def __repr__(self) -> str:
|
|
82
|
-
return f"{self.soc_manufacturer.value}_{self.soc_model.value}_{self.android_os_version.value}"
|
|
83
|
-
|
|
84
|
-
def flatten(self) -> dict[str, Any]:
|
|
85
|
-
flattend_target = super().flatten()
|
|
86
|
-
flattend_target.update({
|
|
87
|
-
"soc_manufacturer": self.soc_manufacturer.value,
|
|
88
|
-
"soc_model": self.soc_model.value,
|
|
89
|
-
"android_os_version": self.android_os_version.value,
|
|
90
|
-
})
|
|
91
|
-
return flattend_target
|
|
File without changes
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
# Copyright 2024 The TensorFlow Authors. All Rights Reserved.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
# ==============================================================================
|
|
15
|
-
|
|
16
|
-
"""Backend implementation for the example compiler plugin.."""
|
|
17
|
-
|
|
18
|
-
import copy
|
|
19
|
-
import functools
|
|
20
|
-
import os
|
|
21
|
-
import pathlib
|
|
22
|
-
from typing import Iterable
|
|
23
|
-
|
|
24
|
-
from ai_edge_litert.aot.core import common
|
|
25
|
-
from ai_edge_litert.aot.core import components
|
|
26
|
-
from ai_edge_litert.aot.core import types
|
|
27
|
-
from ai_edge_litert.aot.vendors import import_vendor
|
|
28
|
-
from ai_edge_litert.aot.vendors.qualcomm import target as target_lib
|
|
29
|
-
|
|
30
|
-
COMPILER_PLUGIN_LIB_PATH = pathlib.Path(
|
|
31
|
-
"vendors/qualcomm/compiler/libLiteRtCompilerPlugin_Qualcomm.so"
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@import_vendor.register_backend
|
|
36
|
-
class QualcommBackend(types.Backend):
|
|
37
|
-
"""Backend implementation for the example compiler plugin."""
|
|
38
|
-
|
|
39
|
-
def __init__(self, config: types.Config):
|
|
40
|
-
super().__init__(config)
|
|
41
|
-
self._compilation_config = config.get("compilation_config", None)
|
|
42
|
-
|
|
43
|
-
@property
|
|
44
|
-
def soc_manufacturer(self) -> target_lib.SocManufacturer:
|
|
45
|
-
return target_lib.SocManufacturer.QUALCOMM
|
|
46
|
-
|
|
47
|
-
@property
|
|
48
|
-
def soc_model(self) -> target_lib.SocModel:
|
|
49
|
-
return target_lib.SocModel(self.config.get("soc_model", "ALL"))
|
|
50
|
-
|
|
51
|
-
@property
|
|
52
|
-
def target(self) -> target_lib.Target:
|
|
53
|
-
return target_lib.Target(self.soc_model, self.soc_manufacturer)
|
|
54
|
-
|
|
55
|
-
@property
|
|
56
|
-
def target_id(self) -> str:
|
|
57
|
-
return repr(self.target)
|
|
58
|
-
|
|
59
|
-
def specialize(self) -> Iterable["QualcommBackend"]:
|
|
60
|
-
if self.soc_model != target_lib.SocModel.ALL:
|
|
61
|
-
yield self
|
|
62
|
-
else:
|
|
63
|
-
for soc_model in target_lib.SocModel:
|
|
64
|
-
if soc_model != target_lib.SocModel.ALL:
|
|
65
|
-
new_config = copy.deepcopy(self.config)
|
|
66
|
-
new_config["soc_model"] = soc_model.value
|
|
67
|
-
yield self.create(new_config)
|
|
68
|
-
|
|
69
|
-
@classmethod
|
|
70
|
-
def id(cls) -> str:
|
|
71
|
-
return target_lib._QUALCOMM_BACKEND_ID # pylint: disable=protected-access
|
|
72
|
-
|
|
73
|
-
@classmethod
|
|
74
|
-
def create(cls, config: types.Config) -> "QualcommBackend":
|
|
75
|
-
if config.get("backend_id", "") != cls.id():
|
|
76
|
-
raise ValueError("Invalid backend id")
|
|
77
|
-
return cls(config)
|
|
78
|
-
|
|
79
|
-
@property
|
|
80
|
-
def quantize_recipe(self) -> str | None:
|
|
81
|
-
return self.config.get("quantize_recipe", None)
|
|
82
|
-
|
|
83
|
-
def call_component(
|
|
84
|
-
self,
|
|
85
|
-
input_model: types.Model,
|
|
86
|
-
output_model: types.Model,
|
|
87
|
-
component: types.Component,
|
|
88
|
-
):
|
|
89
|
-
return _call_component(component, self, input_model, output_model)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
@functools.singledispatch
|
|
93
|
-
def _call_component(
|
|
94
|
-
component: types.Component,
|
|
95
|
-
backend: QualcommBackend,
|
|
96
|
-
unused_input_model: types.Model,
|
|
97
|
-
unused_output_model: types.Model,
|
|
98
|
-
):
|
|
99
|
-
raise NotImplementedError(
|
|
100
|
-
f"{backend.id()} backend does not support"
|
|
101
|
-
f" {component.component_name} component."
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
@_call_component.register
|
|
106
|
-
def _apply_plugin(
|
|
107
|
-
component: components.ApplyPluginT,
|
|
108
|
-
backend: QualcommBackend,
|
|
109
|
-
input_model: types.Model,
|
|
110
|
-
output_model: types.Model,
|
|
111
|
-
):
|
|
112
|
-
"""Calls the apply plugin component."""
|
|
113
|
-
try:
|
|
114
|
-
# If the plugin is not built from source (i.e. using ai_edge_litert wheel),
|
|
115
|
-
# we find the plugin library directory from the package path.
|
|
116
|
-
# Otherwise we use the default library path.
|
|
117
|
-
plugin_path = common.get_resource(COMPILER_PLUGIN_LIB_PATH)
|
|
118
|
-
lib_dir = os.path.dirname(plugin_path)
|
|
119
|
-
|
|
120
|
-
try:
|
|
121
|
-
# pytype: disable=import-error
|
|
122
|
-
import ai_edge_litert_sdk_qualcomm # pylint: disable=g-import-not-at-top
|
|
123
|
-
# pytype: enable=import-error
|
|
124
|
-
|
|
125
|
-
sdk_libs_path = str(ai_edge_litert_sdk_qualcomm.path_to_sdk_libs())
|
|
126
|
-
except ImportError:
|
|
127
|
-
sdk_libs_path = None
|
|
128
|
-
extra_kwargs = {"libs": lib_dir, "sdk_libs_path": sdk_libs_path}
|
|
129
|
-
except FileNotFoundError:
|
|
130
|
-
extra_kwargs = {}
|
|
131
|
-
return component(
|
|
132
|
-
input_model,
|
|
133
|
-
output_model,
|
|
134
|
-
backend.soc_manufacturer,
|
|
135
|
-
backend.soc_model,
|
|
136
|
-
**extra_kwargs,
|
|
137
|
-
)
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
@_call_component.register
|
|
141
|
-
def _aie_quantizer(
|
|
142
|
-
component: components.AieQuantizerT,
|
|
143
|
-
backend: QualcommBackend,
|
|
144
|
-
input_model: types.Model,
|
|
145
|
-
output_model: types.Model,
|
|
146
|
-
):
|
|
147
|
-
return component(
|
|
148
|
-
input_model,
|
|
149
|
-
output_model,
|
|
150
|
-
quantization_recipe=backend.quantize_recipe,
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
@_call_component.register
|
|
155
|
-
def _mlir_transforms(
|
|
156
|
-
component: components.MlirTransformsT,
|
|
157
|
-
unused_backend: QualcommBackend,
|
|
158
|
-
input_model: types.Model,
|
|
159
|
-
output_model: types.Model,
|
|
160
|
-
):
|
|
161
|
-
return component(input_model, output_model, [])
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"""Compilation target for Qualcomm SOCs."""
|
|
2
|
-
|
|
3
|
-
import dataclasses
|
|
4
|
-
import sys
|
|
5
|
-
from typing import Any
|
|
6
|
-
|
|
7
|
-
from ai_edge_litert.aot.core import types
|
|
8
|
-
|
|
9
|
-
# pylint: disable=g-importing-member
|
|
10
|
-
# pylint: disable=g-import-not-at-top
|
|
11
|
-
# pylint: disable=g-bad-import-order
|
|
12
|
-
if sys.version_info >= (3, 11):
|
|
13
|
-
from enum import StrEnum # pylint: disable=g-importing-member
|
|
14
|
-
else:
|
|
15
|
-
from backports.strenum import StrEnum # pylint: disable=g-importing-member
|
|
16
|
-
# pylint: enable=g-bad-import-order
|
|
17
|
-
# pylint: enable=g-import-not-at-top
|
|
18
|
-
# pylint: enable=g-importing-member
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
_QUALCOMM_BACKEND_ID = "qualcomm"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# TODO(weiyiw): Generate this from supported_soc.csv.
|
|
25
|
-
class SocModel(StrEnum):
|
|
26
|
-
"""Qualcomm SOC model."""
|
|
27
|
-
|
|
28
|
-
ALL = "ALL"
|
|
29
|
-
|
|
30
|
-
SA8255 = "SA8255"
|
|
31
|
-
SA8295 = "SA8295"
|
|
32
|
-
SM8350 = "SM8350"
|
|
33
|
-
SM8450 = "SM8450"
|
|
34
|
-
SM8550 = "SM8550"
|
|
35
|
-
SM8650 = "SM8650"
|
|
36
|
-
SM8750 = "SM8750"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class SocManufacturer(StrEnum):
|
|
40
|
-
"""Qualcomm SOC manufacturer."""
|
|
41
|
-
|
|
42
|
-
QUALCOMM = "Qualcomm"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
@dataclasses.dataclass
|
|
46
|
-
class Target(types.Target):
|
|
47
|
-
"""Compilation target for Qualcomm SOCs."""
|
|
48
|
-
|
|
49
|
-
soc_model: SocModel
|
|
50
|
-
soc_manufacturer: SocManufacturer = SocManufacturer.QUALCOMM
|
|
51
|
-
|
|
52
|
-
@classmethod
|
|
53
|
-
def backend_id(cls) -> str:
|
|
54
|
-
return _QUALCOMM_BACKEND_ID
|
|
55
|
-
|
|
56
|
-
def __hash__(self) -> int:
|
|
57
|
-
return hash((self.soc_manufacturer, self.soc_model))
|
|
58
|
-
|
|
59
|
-
def __eq__(self, other: "Target") -> bool:
|
|
60
|
-
return (
|
|
61
|
-
self.soc_manufacturer == other.soc_manufacturer
|
|
62
|
-
and self.soc_model == other.soc_model
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
def __repr__(self) -> str:
|
|
66
|
-
return f"{self.soc_manufacturer.value}_{self.soc_model.value}"
|
|
67
|
-
|
|
68
|
-
def flatten(self) -> dict[str, Any]:
|
|
69
|
-
flattend_target = super().flatten()
|
|
70
|
-
flattend_target.update({
|
|
71
|
-
"soc_manufacturer": self.soc_manufacturer.value,
|
|
72
|
-
"soc_model": self.soc_model.value,
|
|
73
|
-
})
|
|
74
|
-
return flattend_target
|
|
Binary file
|
|
Binary file
|
|
File without changes
|