Shortcuts

转换自定义配置

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

转换自定义配置

set_preserved_attributes(attributes)[源代码]

设置在图模块中将持久化的属性名称,即使它们未在模型的 forward 方法中使用。

Return type

转换自定义配置

to_dict()[源代码]

将此 ConvertCustomConfig 转换为字典,其中包含在 from_dict() 中描述的项目。

Return type

字典[字符串, 任意]

优云智算