Align quant scale and offset to output config. All input configs would share a same scale and offset with output config. (as a slave to output config) Any change to slave config will be rejected since then.
(self, op: QuantableOperation)
| 465 | return master_config |
| 466 | |
| 467 | def align_to_output(self, op: QuantableOperation) -> TensorQuantizationConfig: |
| 468 | """Align quant scale and offset to output config. All input configs |
| 469 | would share a same scale and offset with output config. (as a slave to |
| 470 | output config) |
| 471 | |
| 472 | Any change to slave config will be rejected since then. |
| 473 | """ |
| 474 | master_config = op.config.output_quantization_config[0] |
| 475 | for slave_config in op.config.input_quantization_config: |
| 476 | if slave_config.policy.has_property(QuantizationProperty.FLOATING): continue |
| 477 | if slave_config.state not in {QuantizationStates.FP32, QuantizationStates.SOI}: |
| 478 | slave_config.master_by = master_config |
| 479 | return master_config |
| 480 | |
| 481 | def optimize(self, graph: BaseGraph, **kwargs) -> None: |
| 482 |