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类方法,该方法负责将观察模块类转换为量化模块类。- 返回类型: