ai-edge-torch-nightly 0.6.0.dev20250606__py3-none-any.whl → 0.6.0.dev20250608__py3-none-any.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.
@@ -17,7 +17,7 @@
17
17
  from collections.abc import Callable
18
18
  import functools
19
19
  import numbers
20
- from typing import Any, Optional, Union
20
+ from typing import Any, Optional, Sequence, Union
21
21
  from ai_edge_torch.odml_torch import export_utils
22
22
  from jax._src.lib.mlir import ir
23
23
  from jax._src.lib.mlir.dialects import hlo as stablehlo
@@ -281,3 +281,33 @@ def convert_to_ir_value(
281
281
  if isinstance(value, ir.Value):
282
282
  return value
283
283
  raise TypeError(f"Unsupported type for conversion to ir.Value: {type(value)}")
284
+
285
+
286
+ def convert_shape_to_ir_value(
287
+ shape: Sequence[int],
288
+ ) -> ir.Value:
289
+ # Check if all elements in the shape sequence are integers.
290
+ if not shape or all(isinstance(dim, int) for dim in shape):
291
+ # If all are integers, create a constant numpy array.
292
+ # Assuming int32 is the required type for TFLite shape tensors.
293
+ shape_ir_value = numpy_array_constant(np.array(shape, dtype=np.int32))
294
+ else:
295
+ # Handle mixed int and ir.Value shape sequence
296
+ processed_dims = []
297
+ for dim in shape:
298
+ if isinstance(dim, int):
299
+ # Convert int to a constant 1D tensor
300
+ shape_ir_value = numpy_array_constant(np.array([dim], dtype=np.int32))
301
+ processed_dims.append(shape_ir_value)
302
+ else:
303
+ assert isinstance(dim, ir.Value)
304
+ # Convert ir.Value to a constant 1D tensor
305
+ new_type = ir.RankedTensorType.get([1], dim.type.element_type)
306
+ reshape_dim = stablehlo.reshape(new_type, dim)
307
+ processed_dims.append(reshape_dim)
308
+
309
+ shape_ir_value = stablehlo.concatenate(
310
+ processed_dims,
311
+ dimension=0,
312
+ )
313
+ return shape_ir_value
ai_edge_torch/version.py CHANGED
@@ -15,4 +15,4 @@
15
15
 
16
16
  # The next version of ai-edge-torch.
17
17
  # The minor version code should be bumped after every release.
18
- __version__ = "0.6.0.dev20250606"
18
+ __version__ = "0.6.0.dev20250608"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ai-edge-torch-nightly
3
- Version: 0.6.0.dev20250606
3
+ Version: 0.6.0.dev20250608
4
4
  Summary: Supporting PyTorch models with the Google AI Edge TFLite runtime.
5
5
  Home-page: https://github.com/google-ai-edge/ai-edge-torch
6
6
  Keywords: On-Device ML,AI,Google,TFLite,PyTorch,LLMs,GenAI
@@ -2,7 +2,7 @@ ai_edge_torch/__init__.py,sha256=lemyLCNoGYRnJsmDuGZu7qOqLbLqG6CGDFtu3ue1syU,129
2
2
  ai_edge_torch/_config.py,sha256=AiqhbcheF7j_ozIGDLC89k1we95aVgFDa-tR6h7UI0s,2529
3
3
  ai_edge_torch/conftest.py,sha256=r0GTrhMRhlmOGrrkvumHN8hkmyug6WvF60vWq8wRIBI,758
4
4
  ai_edge_torch/model.py,sha256=A7loFu8jE9CsXsfMmHYZ-KDFJiaD8Kkqwm_9d3IVzk0,5638
5
- ai_edge_torch/version.py,sha256=w38CdzAqRuFGjEjznLvOmY9z1dEKo3ySTSdgY6aBdSU,806
5
+ ai_edge_torch/version.py,sha256=BXtcfzSJXS87SYAsACZbMKtP4z7lF-KawEz0OLQFMSk,806
6
6
  ai_edge_torch/_convert/__init__.py,sha256=hHLluseD2R0Hh4W6XZRIXY_dRQeYudjsrKGf6LZz65g,671
7
7
  ai_edge_torch/_convert/conversion.py,sha256=iQk3R-pLq4c1nfLqPB4xTRj78gghxPGzJCJtILLdg5o,6123
8
8
  ai_edge_torch/_convert/conversion_utils.py,sha256=Sr8qXVcTwc-ZnZmK7yxVrIOOp1S_vNrwzC0zUvLTI2o,2160
@@ -258,7 +258,7 @@ ai_edge_torch/odml_torch/lowerings/_quantized_decomposed.py,sha256=XDZ0zLej_XaQD
258
258
  ai_edge_torch/odml_torch/lowerings/_rand.py,sha256=g6SuqDkuC6hD35lyP1-5H7ASDIzPSmKukeNT5naZSv8,4133
259
259
  ai_edge_torch/odml_torch/lowerings/context.py,sha256=jslcCv7r_HtImSRTxJwHAUV_QCu9Jub51lovmoBkmFA,1295
260
260
  ai_edge_torch/odml_torch/lowerings/registry.py,sha256=Tp2h11l5uTifO0aIkuUOWAF_ibEjmd65Xx99w3EXuGE,1924
261
- ai_edge_torch/odml_torch/lowerings/utils.py,sha256=wHIhaKGWxf_x4W750_nzKoYMBDlq2Fd6b05-XOEVyVQ,9465
261
+ ai_edge_torch/odml_torch/lowerings/utils.py,sha256=YagY2IDqtJTpPxjPz2dhb3eyCFTpTSu3ptEPSvEuDtk,10574
262
262
  ai_edge_torch/odml_torch/passes/__init__.py,sha256=AVwIwUTMx7rXacKjGy4kwrtMd3XB2v_ncdc40KOjUqQ,1245
263
263
  ai_edge_torch/quantize/__init__.py,sha256=aB5dXot04bqyUhpsDFvxt9CIi15QAC4euvqOndJ0XLU,714
264
264
  ai_edge_torch/quantize/pt2e_quantizer.py,sha256=CKIEhs9jCcna64qj1jFH9zEbMbRdyeGV_TmSqEBPjes,15741
@@ -268,8 +268,8 @@ ai_edge_torch/testing/__init__.py,sha256=_yGgvnBZWb7T3IN3mc4x1sS4vM96HZwM8pwIcPG
268
268
  ai_edge_torch/testing/export.py,sha256=k5mGDGzwc23Z4zaIVDs8CNh-oOt64gsf9MS9NjhbPy4,3293
269
269
  ai_edge_torch/testing/model_coverage/__init__.py,sha256=5P8J6Zk5YYtDvTBucFvB9NGSRI7Gw_24WnrbhXgycEE,765
270
270
  ai_edge_torch/testing/model_coverage/model_coverage.py,sha256=UPB448aMDUyC0HNYVqio2rcJPnDN0tBQMP08J6vPYew,4718
271
- ai_edge_torch_nightly-0.6.0.dev20250606.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
272
- ai_edge_torch_nightly-0.6.0.dev20250606.dist-info/METADATA,sha256=dlZhk9uhgYBPi7Z3Mywcu34k4qnslMz6QHqqaaVA9_M,2074
273
- ai_edge_torch_nightly-0.6.0.dev20250606.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
274
- ai_edge_torch_nightly-0.6.0.dev20250606.dist-info/top_level.txt,sha256=5KXRaF2hwkApYxf7Y8y_tVb9aulGTlbOoNdbx1aKRkE,14
275
- ai_edge_torch_nightly-0.6.0.dev20250606.dist-info/RECORD,,
271
+ ai_edge_torch_nightly-0.6.0.dev20250608.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
272
+ ai_edge_torch_nightly-0.6.0.dev20250608.dist-info/METADATA,sha256=2N-NXQ9DxVdBXhhR1Emb84854aBitqs6rTGp4DTlE-o,2074
273
+ ai_edge_torch_nightly-0.6.0.dev20250608.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
274
+ ai_edge_torch_nightly-0.6.0.dev20250608.dist-info/top_level.txt,sha256=5KXRaF2hwkApYxf7Y8y_tVb9aulGTlbOoNdbx1aKRkE,14
275
+ ai_edge_torch_nightly-0.6.0.dev20250608.dist-info/RECORD,,