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 将被忽略。