MCPcopy
hub / github.com/OpenPPL/ppq / align_to_output

Method align_to_output

ppq/quantization/optim/refine.py:467–479  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

optimizeMethod · 0.95

Calls 1

has_propertyMethod · 0.80

Tested by

no test coverage detected