convert¶
- class torch.ao.quantization.convert(module, mapping=None, inplace=False, remove_qconfig=True, is_reference=False, convert_custom_config_dict=None, use_precomputed_fake_quant=False)[source][source]¶
根據 mapping,通過在目標模組類別上調用 from_float 方法,將輸入模組中的子模組轉換為不同的模組。 如果 remove_qconfig 設置為 True,則在最後移除 qconfig。
- 參數
module – 準備和校準的模組
mapping – 一個字典,將源模組類型映射到目標模組類型,可以覆蓋它以允許交換用戶定義的模組
inplace – 就地執行模型轉換,原始模組會被修改
convert_custom_config_dict – convert 函數的自定義配置字典
use_precomputed_fake_quant – 一個標誌,用於啟用預先計算的偽量化 (fake quant)
# Example of convert_custom_config_dict: convert_custom_config_dict = { # user will manually define the corresponding quantized # module class which has a from_observed class method that converts # observed custom module to quantized custom module "observed_to_quantized_custom_module_class": { ObservedCustomModule: QuantizedCustomModule } }