快捷方式

PrepareCustomConfig

class torch.ao.quantization.fx.custom_config.PrepareCustomConfig[source][source]

prepare_fx()prepare_qat_fx() 自定义配置。

使用示例

prepare_custom_config = PrepareCustomConfig()             .set_standalone_module_name("module1", qconfig_mapping, example_inputs,                 child_prepare_custom_config, backend_config)             .set_standalone_module_class(MyStandaloneModule, qconfig_mapping, example_inputs,                 child_prepare_custom_config, backend_config)             .set_float_to_observed_mapping(FloatCustomModule, ObservedCustomModule)             .set_non_traceable_module_names(["module2", "module3"])             .set_non_traceable_module_classes([NonTraceableModule1, NonTraceableModule2])             .set_input_quantized_indexes([0])             .set_output_quantized_indexes([0])             .set_preserved_attributes(["attr1", "attr2"])
classmethod from_dict(prepare_custom_config_dict)[source][source]

从具有以下项目的字典创建 PrepareCustomConfig

“standalone_module_name”:(module_name, qconfig_mapping, example_inputs, child_prepare_custom_config, backend_config) 元组列表

“standalone_module_class”:(module_class, qconfig_mapping, example_inputs, child_prepare_custom_config, backend_config) 元组列表

“float_to_observed_custom_module_class”:从量化模式到从浮点模块类到观察模块类的内部映射的嵌套字典,例如 {“static”: {FloatCustomModule: ObservedCustomModule}}

“non_traceable_module_name”:不可符号跟踪的模块名称列表 “non_traceable_module_class”:不可符号跟踪的模块类列表 “input_quantized_idxs”:应量化的图形输入索引列表 “output_quantized_idxs”:应量化的图形输出索引列表 “preserved_attributes”:即使在 forward 中未使用也持久存在的属性列表

此函数主要用于向后兼容,将来可能会被删除。

返回类型

PrepareCustomConfig

set_float_to_observed_mapping(float_class, observed_class, quant_type=QuantType.STATIC)[source][source]

设置从自定义浮点模块类到自定义观察模块类的映射。

观察模块类必须具有 from_float 类方法,该方法将浮点模块类转换为观察模块类。目前仅静态量化支持此功能。

返回类型

PrepareCustomConfig

set_input_quantized_indexes(indexes)[source][source]

设置应量化的图形输入的索引。否则,默认情况下输入被假定为 fp32。

返回类型

PrepareCustomConfig

set_non_traceable_module_classes(module_classes)[source][source]

设置不可符号跟踪的模块,按类标识。

返回类型

PrepareCustomConfig

set_non_traceable_module_names(module_names)[source][source]

设置不可符号跟踪的模块,按名称标识。

返回类型

PrepareCustomConfig

set_output_quantized_indexes(indexes)[source][source]

设置应量化的图形输出的索引。否则,默认情况下输出被假定为 fp32。

返回类型

PrepareCustomConfig

set_preserved_attributes(attributes)[source][source]

设置即使在模型的 forward 方法中未使用也将在图形模块中持久存在的属性名称。

返回类型

PrepareCustomConfig

set_standalone_module_class(module_class, qconfig_mapping, example_inputs, prepare_custom_config, backend_config)[source][source]

设置用于运行由 module_class 标识的独立模块的配置。

如果 qconfig_mapping 为 None,则将改为使用父 qconfig_mapping。如果 prepare_custom_config 为 None,则将使用空的 PrepareCustomConfig。如果 backend_config 为 None,则将改为使用父 backend_config

返回类型

PrepareCustomConfig

set_standalone_module_name(module_name, qconfig_mapping, example_inputs, prepare_custom_config, backend_config)[source][source]

设置用于运行由 module_name 标识的独立模块的配置。

如果 qconfig_mapping 为 None,则将改为使用父 qconfig_mapping。如果 prepare_custom_config 为 None,则将使用空的 PrepareCustomConfig。如果 backend_config 为 None,则将改为使用父 backend_config

返回类型

PrepareCustomConfig

to_dict()[source][source]

将此 PrepareCustomConfig 转换为具有 from_dict() 中描述的项目的字典。

返回类型

Dict[str, Any]

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得问题解答

查看资源