ai-edge-quantizer-nightly 0.3.0.dev20250603__py3-none-any.whl → 0.3.0.dev20250604__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.
@@ -15,6 +15,7 @@
15
15
 
16
16
  """Utility functions for graph transformations."""
17
17
 
18
+ import copy
18
19
  import dataclasses
19
20
  from typing import Optional, Union
20
21
 
@@ -105,7 +106,17 @@ def get_constant_buffer(
105
106
  Returns:
106
107
  The index of the new buffer in the model.
107
108
  """
108
- new_data = np.frombuffer(data.tobytes(), dtype=np.uint8).flatten()
109
+
110
+ if isinstance(data, np.ndarray):
111
+ # in the case where the data is passed from quantization_params.
112
+ new_data = np.frombuffer(data.tobytes(), dtype=np.uint8).flatten()
113
+ elif isinstance(data, bytes):
114
+ # in the case where the data is coming from duplicating buffers, we need to
115
+ # make a copy of the data to avoid having two buffers pointing to the same
116
+ # data.
117
+ new_data = copy.deepcopy(data)
118
+ else:
119
+ raise ValueError('data passed in must be either np.ndarray or bytes.')
109
120
  # TODO: b/417811116 - we should make this more efficient.
110
121
  if not force_duplicate_buffer:
111
122
  for index, buffer in enumerate(buffers):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ai-edge-quantizer-nightly
3
- Version: 0.3.0.dev20250603
3
+ Version: 0.3.0.dev20250604
4
4
  Summary: A quantizer for advanced developers to quantize converted AI Edge models.
5
5
  Home-page: https://github.com/google-ai-edge/ai-edge-quantizer
6
6
  Keywords: On-Device ML,AI,Google,TFLite,Quantization,LLMs,GenAI
@@ -58,7 +58,7 @@ ai_edge_quantizer/transformations/quant_insert.py,sha256=jn6HsJaV-sqBiFPY-Aqbd64
58
58
  ai_edge_quantizer/transformations/quant_insert_test.py,sha256=X9ptPDvJCFkR5tejKnD1SlHFGPazQTW-wNNMV9MEAuw,10107
59
59
  ai_edge_quantizer/transformations/quantize_tensor.py,sha256=kjaNrw9mnrn0t8u0vey9S_uPz3iVUicwy4rluxVqV3E,7617
60
60
  ai_edge_quantizer/transformations/quantize_tensor_test.py,sha256=mHLO3_MRt36A8-ZN8ADn5tBBJlqjTWa7ZUN8Mmu5Rcw,9116
61
- ai_edge_quantizer/transformations/transformation_utils.py,sha256=mYD6gHxSO6JmjC9fSWl0pLh6N_tCW70yTIxHYdmnV3A,6483
61
+ ai_edge_quantizer/transformations/transformation_utils.py,sha256=GwIaKVsePZYgVG2lSanOswcaZYMjvgyqstDVwXl9DGY,6923
62
62
  ai_edge_quantizer/transformations/transformation_utils_test.py,sha256=MWgq29t7rvxRQIfi4ny9IoODFCTcbpjnIwoCL40zDKk,8698
63
63
  ai_edge_quantizer/utils/__init__.py,sha256=lpq1g2ayg3lCPLy79t2VicYcnGKw64FfYIj1V7J-4m8,676
64
64
  ai_edge_quantizer/utils/calibration_utils.py,sha256=1Fj9MIO6aLZIRgyd4axvZN4S_O64nB_-Miu1WP664js,2536
@@ -70,8 +70,8 @@ ai_edge_quantizer/utils/tfl_interpreter_utils.py,sha256=WoewyiZpaua80oP0tpgyrw5W
70
70
  ai_edge_quantizer/utils/tfl_interpreter_utils_test.py,sha256=6fjkM-rycZ95L4yfvlr0TN6RlrhfPzxNUYrZaYO_F0A,12013
71
71
  ai_edge_quantizer/utils/validation_utils.py,sha256=oYw33Sg547AqtGw-choPUJmp9SAKkV46J_ddqSsum2Q,3950
72
72
  ai_edge_quantizer/utils/validation_utils_test.py,sha256=V_qNDikPD4OPB-siOLQCWNVWTAu87h2IgNYt7teFd-o,2934
73
- ai_edge_quantizer_nightly-0.3.0.dev20250603.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
74
- ai_edge_quantizer_nightly-0.3.0.dev20250603.dist-info/METADATA,sha256=h-79xv1FAsiMP50ipV6hhK8T0asiofo5-LJt-TlROpc,1528
75
- ai_edge_quantizer_nightly-0.3.0.dev20250603.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
76
- ai_edge_quantizer_nightly-0.3.0.dev20250603.dist-info/top_level.txt,sha256=8QTfPnFXNVUhScFLaa-NWZMFWMn72M50DVPubpwWB1g,18
77
- ai_edge_quantizer_nightly-0.3.0.dev20250603.dist-info/RECORD,,
73
+ ai_edge_quantizer_nightly-0.3.0.dev20250604.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
74
+ ai_edge_quantizer_nightly-0.3.0.dev20250604.dist-info/METADATA,sha256=iG1n9JA6Ei_m2GcCgokIMsjnjbhZIUp8wdCy88U2iQQ,1528
75
+ ai_edge_quantizer_nightly-0.3.0.dev20250604.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
76
+ ai_edge_quantizer_nightly-0.3.0.dev20250604.dist-info/top_level.txt,sha256=8QTfPnFXNVUhScFLaa-NWZMFWMn72M50DVPubpwWB1g,18
77
+ ai_edge_quantizer_nightly-0.3.0.dev20250604.dist-info/RECORD,,