QConfig¶
- class torch.ao.quantization.qconfig.QConfig(activation, weight)[source][source]¶
通过分别为激活和权重提供设置(观察者类),描述如何量化层或网络的一部分。
请注意,QConfig 需要包含观察者类(如 MinMaxObserver)或返回调用时实例的可调用对象,而不是具体的观察者实例本身。量化准备函数将为每一层多次实例化观察者。
观察者类通常具有合理的默认参数,但可以使用 with_args 方法(其行为类似于 functools.partial)覆盖它们
my_qconfig = QConfig( activation=MinMaxObserver.with_args(dtype=torch.qint8), weight=default_observer.with_args(dtype=torch.qint8))