ai-edge-quantizer-nightly 0.0.1.dev20250228__py3-none-any.whl → 0.0.1.dev20250301__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.
@@ -22,8 +22,11 @@ from ai_edge_quantizer import default_policy
22
22
  from ai_edge_quantizer import qtyping
23
23
  from ai_edge_quantizer.algorithms.nonlinear_quantize import float_casting
24
24
  from ai_edge_quantizer.algorithms.uniform_quantize import common_quantize
25
+ from ai_edge_quantizer.algorithms.uniform_quantize import dequantized_weight_recovery
25
26
  from ai_edge_quantizer.algorithms.uniform_quantize import naive_min_max_quantize
26
27
 
28
+ # TODO: b/399775701 - Clean up this file.
29
+
27
30
  _TFLOpName = qtyping.TFLOperationName
28
31
 
29
32
  _alg_manager_instance = algorithm_manager_api.AlgorithmManagerApi()
@@ -51,7 +54,9 @@ class AlgorithmName(str, enum.Enum):
51
54
  NO_QUANTIZE = "no_quantize"
52
55
  MIN_MAX_UNIFORM_QUANT = naive_min_max_quantize.ALGORITHM_KEY
53
56
  FLOAT_CASTING = float_casting.ALGORITHM_KEY
57
+ DEQUANTIZED_WEIGHT_RECOVERY = dequantized_weight_recovery.ALGORITHM_KEY
54
58
 
59
+ ### MIN/MAX_UNIFORM_QUANT ###
55
60
 
56
61
  # Register MIN_MAX_UNIFORM_QUANT algorithm.
57
62
  register_op_quant_config_validation_func(
@@ -109,7 +114,7 @@ for op_name, materialize_func in MIN_MAX_OP_NAME_MATERIALIZE_FUNC_DICT.items():
109
114
  ),
110
115
  )
111
116
 
112
- # Register FLOAT_CASTING algorithm.
117
+ ### FLOAT_CASTING ###
113
118
  register_op_quant_config_validation_func(
114
119
  AlgorithmName.FLOAT_CASTING,
115
120
  float_casting.check_op_quantization_config,
@@ -144,3 +149,38 @@ for op_name, materialize_func in zip(
144
149
  calibration_func=float_casting.calibrate,
145
150
  materialize_func=materialize_func,
146
151
  )
152
+
153
+ ### DEQUANTIZED_WEIGHT_RECOVERY ###
154
+ register_op_quant_config_validation_func(
155
+ AlgorithmName.DEQUANTIZED_WEIGHT_RECOVERY,
156
+ common_quantize.check_op_quantization_config,
157
+ )
158
+
159
+ register_config_check_policy_func(
160
+ AlgorithmName.DEQUANTIZED_WEIGHT_RECOVERY,
161
+ default_policy.DEFAULT_CONFIG_CHECK_POLICY,
162
+ )
163
+
164
+ DEQUANTIZED_WEIGHT_RECOVERY_OP_NAME_MATERIALIZE_FUNC_DICT = {
165
+ _TFLOpName.FULLY_CONNECTED: common_quantize.materialize_fc_conv,
166
+ _TFLOpName.EMBEDDING_LOOKUP: common_quantize.materialize_embedding_lookup,
167
+ }
168
+
169
+ for (
170
+ op_name,
171
+ materialize_func,
172
+ ) in DEQUANTIZED_WEIGHT_RECOVERY_OP_NAME_MATERIALIZE_FUNC_DICT.items():
173
+ register_quantized_op(
174
+ algorithm_key=AlgorithmName.DEQUANTIZED_WEIGHT_RECOVERY,
175
+ tfl_op_name=op_name,
176
+ init_qsv_func=dequantized_weight_recovery.init_qsvs,
177
+ calibration_func=dequantized_weight_recovery.calibrate,
178
+ # Most of the materialize op functions are common for all algorithms
179
+ # except for the function to get scale and zero point, i.e.,
180
+ # get_tensor_quant_params. So we use functools.partial here to pass in the
181
+ # common utility function and the algorithm-specific function.
182
+ materialize_func=functools.partial(
183
+ materialize_func,
184
+ dequantized_weight_recovery.get_tensor_quant_params,
185
+ ),
186
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ai-edge-quantizer-nightly
3
- Version: 0.0.1.dev20250228
3
+ Version: 0.0.1.dev20250301
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
@@ -1,5 +1,5 @@
1
1
  ai_edge_quantizer/__init__.py,sha256=4pFSkukSwahYyzwqia0yPRyz8TnFQfGRthVJhYpMWas,793
2
- ai_edge_quantizer/algorithm_manager.py,sha256=dOW_ex_KShoFaib7auISgsx5wRtxpaxhWrwA2nWgito,6003
2
+ ai_edge_quantizer/algorithm_manager.py,sha256=qjpdEei5l-k5wgGDnelMGVDAYb7K7z8Nn9FIuZBWPA0,7534
3
3
  ai_edge_quantizer/algorithm_manager_api.py,sha256=u903TG0s1uIDhJqfeJne3CFl8A93phZrwgV2-hwdcXU,9247
4
4
  ai_edge_quantizer/algorithm_manager_api_test.py,sha256=tL_ozYFTsOPX8qGcti0KTz37nVsCxf0SSG5C45SyT-g,7319
5
5
  ai_edge_quantizer/calibrator.py,sha256=2J-bX0k09A7vZSRnO3eP49YO2uBMUQh6-sk3JRz9fGQ,11363
@@ -60,8 +60,8 @@ ai_edge_quantizer/utils/tfl_interpreter_utils.py,sha256=SM8H4i7Jq_nfdsJpImopHndN
60
60
  ai_edge_quantizer/utils/tfl_interpreter_utils_test.py,sha256=Op3JxtOqlrjzmYF18jnnstL1k9xiY9kKJ8S2vklKGkc,11327
61
61
  ai_edge_quantizer/utils/validation_utils.py,sha256=oYw33Sg547AqtGw-choPUJmp9SAKkV46J_ddqSsum2Q,3950
62
62
  ai_edge_quantizer/utils/validation_utils_test.py,sha256=V_qNDikPD4OPB-siOLQCWNVWTAu87h2IgNYt7teFd-o,2934
63
- ai_edge_quantizer_nightly-0.0.1.dev20250228.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
64
- ai_edge_quantizer_nightly-0.0.1.dev20250228.dist-info/METADATA,sha256=xlHVb_zTpsb3cqr55S8fCH6jp1T143R6tH6ND9j-iWk,1528
65
- ai_edge_quantizer_nightly-0.0.1.dev20250228.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
66
- ai_edge_quantizer_nightly-0.0.1.dev20250228.dist-info/top_level.txt,sha256=8QTfPnFXNVUhScFLaa-NWZMFWMn72M50DVPubpwWB1g,18
67
- ai_edge_quantizer_nightly-0.0.1.dev20250228.dist-info/RECORD,,
63
+ ai_edge_quantizer_nightly-0.0.1.dev20250301.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
64
+ ai_edge_quantizer_nightly-0.0.1.dev20250301.dist-info/METADATA,sha256=xyqDD73R7HgfjIXn-IS_FgqswM8sxMSMMbFwGSyI9sM,1528
65
+ ai_edge_quantizer_nightly-0.0.1.dev20250301.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
66
+ ai_edge_quantizer_nightly-0.0.1.dev20250301.dist-info/top_level.txt,sha256=8QTfPnFXNVUhScFLaa-NWZMFWMn72M50DVPubpwWB1g,18
67
+ ai_edge_quantizer_nightly-0.0.1.dev20250301.dist-info/RECORD,,