ai-edge-litert-nightly 2.0.2a1.dev20250829__cp312-cp312-manylinux_2_27_x86_64.whl → 2.0.2.dev20250916__cp312-cp312-manylinux_2_27_x86_64.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.

Files changed (22) hide show
  1. ai_edge_litert/__init__.py +1 -1
  2. ai_edge_litert/aot/aot_compile.py +3 -2
  3. ai_edge_litert/aot/vendors/__init__.py +1 -0
  4. ai_edge_litert/aot/vendors/google_tensor/__init__.py +0 -0
  5. ai_edge_litert/aot/vendors/google_tensor/google_tensor_backend.py +153 -0
  6. ai_edge_litert/aot/vendors/google_tensor/target.py +83 -0
  7. ai_edge_litert/internal/__init__.py +0 -0
  8. ai_edge_litert/internal/litertlm_builder.py +573 -0
  9. ai_edge_litert/internal/litertlm_core.py +51 -0
  10. ai_edge_litert/internal/litertlm_header_schema_py_generated.py +1538 -0
  11. ai_edge_litert/internal/llm_metadata_pb2.py +45 -0
  12. ai_edge_litert/internal/sampler_params_pb2.py +39 -0
  13. ai_edge_litert/libLiteRtRuntimeCApi.so +0 -0
  14. ai_edge_litert/libpywrap_litert_common.so +0 -0
  15. ai_edge_litert/tools/apply_plugin_main +0 -0
  16. ai_edge_litert/vendors/google_tensor/compiler/libLiteRtCompilerPlugin_google_tensor.so +0 -0
  17. ai_edge_litert/vendors/mediatek/compiler/libLiteRtCompilerPlugin_MediaTek.so +0 -0
  18. ai_edge_litert/vendors/qualcomm/compiler/libLiteRtCompilerPlugin_Qualcomm.so +0 -0
  19. {ai_edge_litert_nightly-2.0.2a1.dev20250829.dist-info → ai_edge_litert_nightly-2.0.2.dev20250916.dist-info}/METADATA +2 -1
  20. {ai_edge_litert_nightly-2.0.2a1.dev20250829.dist-info → ai_edge_litert_nightly-2.0.2.dev20250916.dist-info}/RECORD +22 -11
  21. {ai_edge_litert_nightly-2.0.2a1.dev20250829.dist-info → ai_edge_litert_nightly-2.0.2.dev20250916.dist-info}/WHEEL +0 -0
  22. {ai_edge_litert_nightly-2.0.2a1.dev20250829.dist-info → ai_edge_litert_nightly-2.0.2.dev20250916.dist-info}/top_level.txt +0 -0
@@ -1 +1 @@
1
- __version__ = "2.0.2a1.dev20250829"
1
+ __version__ = "2.0.2.dev20250916"
@@ -50,8 +50,8 @@ def aot_compile(
50
50
  registered targets.
51
51
  config: The compilation config(s). Cannot be specified with target.
52
52
  quantizer: The quantizer to use for quantization.
53
- keep_going: Whether to keep going if some backends fail. If False, fail
54
- fast on the first error and raise an exception.
53
+ keep_going: Whether to keep going if some backends fail. If False, fail fast
54
+ on the first error and raise an exception.
55
55
  subgraphs_to_compile: The subgraph index list to compile to NPU. If None,
56
56
  compile all subgraphs.
57
57
  **kwargs: Additional arguments to pass to the backend.
@@ -92,6 +92,7 @@ def aot_compile(
92
92
  output_dir.mkdir(parents=True, exist_ok=True)
93
93
  output_dir = str(output_dir)
94
94
  output_dir_path = pathlib.Path(output_dir)
95
+ output_dir_path.mkdir(parents=True, exist_ok=True)
95
96
 
96
97
  if isinstance(config, types.CompilationConfig) or not config:
97
98
  if config:
@@ -14,5 +14,6 @@
14
14
  # ==============================================================================
15
15
  """Vendor backends for LiteRt."""
16
16
 
17
+ from ai_edge_litert.aot.vendors.google_tensor import google_tensor_backend as _
17
18
  from ai_edge_litert.aot.vendors.mediatek import mediatek_backend as _
18
19
  from ai_edge_litert.aot.vendors.qualcomm import qualcomm_backend as _
File without changes
@@ -0,0 +1,153 @@
1
+ # Copyright 2025 Google LLC.
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
+ """Backend implementation for the Google Tensor compiler plugin.."""
16
+
17
+ import copy
18
+ import functools
19
+ import os
20
+ import pathlib
21
+ from typing import Iterable
22
+
23
+ from ai_edge_litert.aot.core import common
24
+ from ai_edge_litert.aot.core import components
25
+ from ai_edge_litert.aot.core import types
26
+ from ai_edge_litert.aot.vendors import import_vendor
27
+ from ai_edge_litert.aot.vendors.google_tensor import target as target_lib
28
+
29
+ COMPILER_PLUGIN_LIB_PATH = pathlib.Path(
30
+ "vendors/google_tensor/compiler/libLiteRtCompilerPlugin_google_tensor.so"
31
+ )
32
+
33
+
34
+ @import_vendor.register_backend
35
+ class GoogleTensorBackend(types.Backend):
36
+ """Backend implementation for the Google Tensor compiler plugin."""
37
+
38
+ def __init__(self, config: types.Config):
39
+ super().__init__(config)
40
+ self._compilation_config = config.get("compilation_config", None)
41
+
42
+ @property
43
+ def soc_manufacturer(self) -> target_lib.SocManufacturer:
44
+ return target_lib.SocManufacturer.GOOGLE_TENSOR
45
+
46
+ @property
47
+ def soc_model(self) -> target_lib.SocModel:
48
+ return target_lib.SocModel(self.config.get("soc_model", "ALL"))
49
+
50
+ @property
51
+ def target(self) -> target_lib.Target:
52
+ return target_lib.Target(self.soc_model, self.soc_manufacturer)
53
+
54
+ @property
55
+ def target_id(self) -> str:
56
+ return repr(self.target)
57
+
58
+ def specialize(self) -> Iterable["GoogleTensorBackend"]:
59
+ if self.soc_model != target_lib.SocModel.ALL:
60
+ yield self
61
+ else:
62
+ for soc_model in target_lib.SocModel:
63
+ if soc_model != target_lib.SocModel.ALL:
64
+ new_config = copy.deepcopy(self.config)
65
+ new_config["soc_model"] = soc_model.value
66
+ yield self.create(new_config)
67
+
68
+ @classmethod
69
+ def id(cls) -> str:
70
+ return target_lib._GOOGLE_TENSOR_BACKEND_ID # pylint: disable=protected-access
71
+
72
+ @classmethod
73
+ def create(cls, config: types.Config) -> "GoogleTensorBackend":
74
+ if config.get("backend_id", "") != cls.id():
75
+ raise ValueError("Invalid backend id")
76
+ return cls(config)
77
+
78
+ @property
79
+ def quantize_recipe(self) -> str | None:
80
+ return self.config.get("quantize_recipe", None)
81
+
82
+ def call_component(
83
+ self,
84
+ input_model: types.Model,
85
+ output_model: types.Model,
86
+ component: types.Component,
87
+ ):
88
+ return _call_component(component, self, input_model, output_model)
89
+
90
+
91
+ @functools.singledispatch
92
+ def _call_component(
93
+ component: types.Component,
94
+ backend: GoogleTensorBackend,
95
+ unused_input_model: types.Model,
96
+ unused_output_model: types.Model,
97
+ ):
98
+ raise NotImplementedError(
99
+ f"{backend.id()} backend does not support"
100
+ f" {component.component_name} component."
101
+ )
102
+
103
+
104
+ @_call_component.register
105
+ def _apply_plugin(
106
+ component: components.ApplyPluginT,
107
+ backend: GoogleTensorBackend,
108
+ input_model: types.Model,
109
+ output_model: types.Model,
110
+ ):
111
+ """Calls the apply plugin component."""
112
+ try:
113
+ # If the plugin is not built from source (i.e. using ai_edge_litert wheel),
114
+ # we find the plugin library directory from the package path.
115
+ # Otherwise we use the default library path.
116
+ plugin_path = common.get_resource(COMPILER_PLUGIN_LIB_PATH)
117
+ lib_dir = os.path.dirname(plugin_path)
118
+ sdk_libs_dir = os.environ.get("LITERT_GOOGLE_TENSOR_SDK", None)
119
+
120
+ extra_kwargs = {"libs": lib_dir, "sdk_libs_path": sdk_libs_dir}
121
+ except FileNotFoundError:
122
+ extra_kwargs = {}
123
+ return component(
124
+ input_model,
125
+ output_model,
126
+ backend.soc_manufacturer,
127
+ backend.soc_model,
128
+ **extra_kwargs,
129
+ )
130
+
131
+
132
+ @_call_component.register
133
+ def _aie_quantizer(
134
+ component: components.AieQuantizerT,
135
+ backend: GoogleTensorBackend,
136
+ input_model: types.Model,
137
+ output_model: types.Model,
138
+ ):
139
+ return component(
140
+ input_model,
141
+ output_model,
142
+ quantization_recipe=backend.quantize_recipe,
143
+ )
144
+
145
+
146
+ @_call_component.register
147
+ def _mlir_transforms(
148
+ component: components.MlirTransformsT,
149
+ unused_backend: GoogleTensorBackend,
150
+ input_model: types.Model,
151
+ output_model: types.Model,
152
+ ):
153
+ return component(input_model, output_model, [])
@@ -0,0 +1,83 @@
1
+ # Copyright 2025 Google LLC.
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
+ """Compilation target for Google Tensor SOCs."""
16
+
17
+ import dataclasses
18
+ import sys
19
+ from typing import Any
20
+
21
+ from ai_edge_litert.aot.core import types
22
+
23
+ # pylint: disable=g-importing-member
24
+ # pylint: disable=g-import-not-at-top
25
+ # pylint: disable=g-bad-import-order
26
+ if sys.version_info >= (3, 11):
27
+ from enum import StrEnum # pylint: disable=g-importing-member
28
+ else:
29
+ from backports.strenum import StrEnum # pylint: disable=g-importing-member
30
+ # pylint: enable=g-bad-import-order
31
+ # pylint: enable=g-import-not-at-top
32
+ # pylint: enable=g-importing-member
33
+
34
+
35
+ _GOOGLE_TENSOR_BACKEND_ID = "google_tensor"
36
+
37
+
38
+ class SocModel(StrEnum):
39
+ """Google Tensor SOC model."""
40
+
41
+ ALL = "ALL"
42
+
43
+ G3 = "g3"
44
+ G4 = "g4"
45
+ G5 = "g5"
46
+
47
+
48
+ class SocManufacturer(StrEnum):
49
+ """Google Tensor SOC manufacturer."""
50
+
51
+ GOOGLE_TENSOR = "GoogleTensor"
52
+
53
+
54
+ @dataclasses.dataclass
55
+ class Target(types.Target):
56
+ """Compilation target for Google Tensor SOCs."""
57
+
58
+ soc_model: SocModel
59
+ soc_manufacturer: SocManufacturer = SocManufacturer.GOOGLE_TENSOR
60
+
61
+ @classmethod
62
+ def backend_id(cls) -> str:
63
+ return _GOOGLE_TENSOR_BACKEND_ID
64
+
65
+ def __hash__(self) -> int:
66
+ return hash((self.soc_manufacturer, self.soc_model))
67
+
68
+ def __eq__(self, other: "Target") -> bool:
69
+ return (
70
+ self.soc_manufacturer == other.soc_manufacturer
71
+ and self.soc_model == other.soc_model
72
+ )
73
+
74
+ def __repr__(self) -> str:
75
+ return f"{self.soc_manufacturer.value}_{self.soc_model.value}"
76
+
77
+ def flatten(self) -> dict[str, Any]:
78
+ flattend_target = super().flatten()
79
+ flattend_target.update({
80
+ "soc_manufacturer": self.soc_manufacturer.value,
81
+ "soc_model": self.soc_model.value,
82
+ })
83
+ return flattend_target
File without changes