快捷方式

convert

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

根據 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
    }
}

文件

查閱 PyTorch 全面開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深入教程

檢視教程

資源

查詢開發者資源並獲得問題解答

檢視資源