ConvertCustomConfig#
- class torch.ao.quantization.fx.custom_config.ConvertCustomConfig[source]#
for
convert_fx()的自定義配置。使用示例
convert_custom_config = ConvertCustomConfig() .set_observed_to_quantized_mapping(ObservedCustomModule, QuantizedCustomModule) .set_preserved_attributes(["attr1", "attr2"])
- classmethod from_dict(convert_custom_config_dict)[source]#
從具有以下專案的字典建立
ConvertCustomConfig“observed_to_quantized_custom_module_class”: 一個巢狀字典,從量化模式對映到內部字典,該內部字典從已觀察的模組類對映到已量化的模組類,例如::: { “static”: {FloatCustomModule: ObservedCustomModule}, “dynamic”: {FloatCustomModule: ObservedCustomModule}, “weight_only”: {FloatCustomModule: ObservedCustomModule} } “preserved_attributes”: 一個屬性列表,即使它們未在
forward中使用,它們也會保留此函式主要用於向後相容,將來可能會被刪除。
- 返回型別
- set_observed_to_quantized_mapping(observed_class, quantized_class, quant_type=QuantType.STATIC)[source]#
設定從自定義已觀察模組類到自定義已量化模組類的對映。
已量化模組類必須有一個
from_observed類方法,該方法將已觀察模組類轉換為已量化模組類。- 返回型別