MCPcopy Create free account
hub / github.com/OpenNMT/CTranslate2 / optimize

Method optimize

python/ctranslate2/specs/model_spec.py:262–273  ·  view source on GitHub ↗

Recursively applies some optimizations to this layer: * Alias variables with the same shape and value. * Quantize weights. Arguments: quantization: Weight quantization scheme (possible values are: int8, int8_float32, int8_float16, int8_bfloat16, int16,

(self, quantization: Optional[str] = None)

Source from the content-addressed store, hash-verified

260 self._visit(_quantize)
261
262 def optimize(self, quantization: Optional[str] = None) -> None:
263 """Recursively applies some optimizations to this layer:
264
265 * Alias variables with the same shape and value.
266 * Quantize weights.
267
268 Arguments:
269 quantization: Weight quantization scheme (possible values are: int8, int8_float32,
270 int8_float16, int8_bfloat16, int16, float16, bfloat16, float32).
271 """
272 self._alias_variables()
273 self._quantize(quantization)
274
275 def _visit(self, fn):
276 """Recursively visits this layer and its children."""

Callers 5

test_layer_spec_optimizeFunction · 0.80
test_int8_quantizationFunction · 0.80
test_fp16_weightsFunction · 0.80
test_torch_variablesFunction · 0.80
convertMethod · 0.80

Calls 2

_alias_variablesMethod · 0.95
_quantizeMethod · 0.95

Tested by 4

test_layer_spec_optimizeFunction · 0.64
test_int8_quantizationFunction · 0.64
test_fp16_weightsFunction · 0.64
test_torch_variablesFunction · 0.64