MCPcopy Index your code
hub / github.com/OpenPPL/ppq / PPQuantFunction_toInt

Function PPQuantFunction_toInt

ppq/quantization/qfunction/__init__.py:47–61  ·  view source on GitHub ↗

## PPQ 核心量化函数 根据 config 中描述的策略,这个函数将会执行线性量化,动态量化 但是结果直接出来是整数

(tensor: torch.Tensor, config: TensorQuantizationConfig)

Source from the content-addressed store, hash-verified

45
46
47def PPQuantFunction_toInt(tensor: torch.Tensor, config: TensorQuantizationConfig) -> torch.Tensor:
48 """
49 ## PPQ 核心量化函数
50
51 根据 config 中描述的策略,这个函数将会执行线性量化,动态量化
52
53 但是结果直接出来是整数
54 """
55
56 if config.policy.has_property(QuantizationProperty.LINEAR):
57 if not config.policy.has_property(QuantizationProperty.DYNAMIC):
58 return PPQLinearQuant_toInt(tensor, config)
59
60 raise ValueError('Unexpected Quantization Property Found in PPQuantFunction_toInt. '
61 'Do not konw how to quantize your config yet.')
62
63
64__all__ = ['PPQuantFunction', 'PPQuantFunction_toInt', 'PPQDyamicLinearQuantFunction',

Callers

nothing calls this directly

Calls 2

PPQLinearQuant_toIntFunction · 0.85
has_propertyMethod · 0.80

Tested by

no test coverage detected