DTypeWithConstraints¶
- class torch.ao.quantization.backend_config.DTypeWithConstraints(dtype=None, quant_min_lower_bound=None, quant_max_upper_bound=None, scale_min_lower_bound=None, scale_max_upper_bound=None, scale_exact_match=None, zero_point_exact_match=None)[source][source]¶
用於指定給定 dtype 的額外約束的配置,例如量化值範圍、比例值範圍和固定量化引數,供
DTypeConfig使用。當前支援的約束包括
quant_min_lower_bound 和 quant_max_upper_bound:分別是最小和最大量化值的下限和上限。如果 QConfig 的 quant_min 和 quant_max 落在此範圍之外,則該 QConfig 將被忽略。
scale_min_lower_bound 和 scale_max_upper_bound:分別是最小和最大比例值的下限和上限。如果 QConfig 的最小比例值(當前公開為 eps)低於下限,則該 QConfig 將被忽略。請注意,目前不強制執行上限。
scale_exact_match 和 zero_point_exact_match:用於比例和零點的精確匹配要求,適用於 sigmoid 和 tanh 等具有固定量化引數的運算元。如果 QConfig 中指定的 observer 既不是 FixedQParamsObserver 也不是 FixedQParamsFakeQuantize,或者量化引數不匹配,則該 QConfig 將被忽略。