评价此页

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)[源代码]#

用于在 DTypeConfig 中指定给定 dtype 的额外约束的配置,例如量化值范围、比例值范围和固定量化参数。

当前支持的约束有:

  • quant_min_lower_boundquant_max_upper_bound:分别表示量化值的最小值和最大值的下限和上限。如果 QConfig 的 quant_minquant_max 超出此范围,则忽略该 QConfig。

  • scale_min_lower_boundscale_max_upper_bound:分别表示比例值的最小值和最大值的下限和上限。如果 QConfig 的最小比例值(当前公开为 eps)低于下限,则忽略该 QConfig。请注意,当前不强制执行上限。

  • scale_exact_matchzero_point_exact_match:比例值和零点的精确匹配要求,用于具有固定量化参数的算子,例如 sigmoid 和 tanh。如果 QConfig 中指定的观察者不是 FixedQParamsObserverFixedQParamsFakeQuantize,或者量化参数不匹配,则忽略该 QConfig。