(
self, operation: Operation)
| 19 | self._quant_max = + 127 |
| 20 | |
| 21 | def init_quantize_config( |
| 22 | self, operation: Operation) -> OperationQuantizationConfig: |
| 23 | base_quant_config = self.create_default_quant_config( |
| 24 | policy=self.quantize_policy, rounding=self.rounding_policy, |
| 25 | op=operation, num_of_bits=self._num_of_bits, exponent_bits=0, |
| 26 | quant_max=self._quant_max, quant_min=self._quant_min, |
| 27 | observer_algorithm='percentile' |
| 28 | ) |
| 29 | |
| 30 | if operation.type == 'Conv': |
| 31 | assert operation.num_of_input > 0, 'Seems you got a Conv layer with no parameters.' |
| 32 | |
| 33 | if operation.inputs[1].is_parameter: |
| 34 | conv_weight_config = base_quant_config.input_quantization_config[1] |
| 35 | conv_weight_config.policy = QuantizationPolicy( |
| 36 | QuantizationProperty.SYMMETRICAL + |
| 37 | QuantizationProperty.LINEAR + |
| 38 | QuantizationProperty.PER_CHANNEL |
| 39 | ) |
| 40 | conv_weight_config.channel_axis = 0 |
| 41 | conv_weight_config.observer_algorithm = 'minmax' |
| 42 | |
| 43 | if operation.num_of_input > 2: |
| 44 | bias_config = base_quant_config.input_quantization_config[-1] |
| 45 | bias_config.state = QuantizationStates.FP32 |
| 46 | |
| 47 | if operation.type in PASSIVE_OPERATIONS: |
| 48 | # Those op are not active op. |
| 49 | base_quant_config.is_active_quant_op = False |
| 50 | return base_quant_config |
| 51 | |
| 52 | @ property |
| 53 | def target_platform(self) -> TargetPlatform: |
nothing calls this directly
no test coverage detected