MCPcopy Create free account
hub / github.com/XiaoMi/mace / quantize_with_scale_and_zero

Function quantize_with_scale_and_zero

tools/python/quantize/quantize_util.py:174–181  ·  view source on GitHub ↗
(data, scale, zero)

Source from the content-addressed store, hash-verified

172
173
174def quantize_with_scale_and_zero(data, scale, zero):
175 np_data = np.array(data).astype(float)
176 output = np.round(zero + np_data / scale).astype(np.int32)
177 quantized_data = QuantizedData()
178 quantized_data.data = output
179 quantized_data.scale = scale
180 quantized_data.zero = zero
181 return quantized_data
182
183
184def quantize_int8(data):

Callers

nothing calls this directly

Calls 2

QuantizedDataClass · 0.85
roundMethod · 0.80

Tested by

no test coverage detected