## PPQ 核心量化函数 根据 config 中描述的策略,这个函数将会执行线性量化,动态量化 但是结果直接出来是整数
(tensor: torch.Tensor, config: TensorQuantizationConfig)
| 45 | |
| 46 | |
| 47 | def 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', |
nothing calls this directly
no test coverage detected