转换自定义配置¶
- 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中使用,也会保留此函数主要用于向后兼容,未来可能会被移除。
- Return type
- set_observed_to_quantized_mapping(observed_class, quantized_class, quant_type=QuantType.STATIC)[源代码]¶
设置从自定义观察模块类到自定义量化模块类的映射。
量化模块类必须有一个
from_observed类方法,用于将观察到的模块类转换为量化模块类。- Return type