ConvertCustomConfig¶
- class torch.ao.quantization.fx.custom_config.ConvertCustomConfig[原始碼][原始碼]¶
用於
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)[原始碼][原始碼]¶
從一個包含以下項目的字典建立一個
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)[原始碼][原始碼]¶
設定從自定義觀察到的模組類別到自定義量化的模組類別的映射。
量化的模組類別必須有一個
from_observed
類別方法,該方法將觀察到的模組類別轉換為量化的模組類別。- 回傳類型