文档
注册

create_quant_retrain_model

功能说明

量化感知训练接口,将输入的待量化的图结构按照给定的量化配置文件进行量化处理,在传入的图结构中插入量化相关的算子(数据和权重的量化感知训练层以及找N的层),生成量化因子记录文件record_file,返回修改后可用于量化感知训练的torch.nn.module模型。

函数原型

quant_retrain_model = create_quant_retrain_model (config_file, model, record_file, input_data)

参数说明

参数名

输入/返回值

含义

使用限制

config_file

输入

用户生成的量化感知训练配置文件,用于指定模型network中量化层的配置情况。

数据类型:string

model

输入

待进行量化感知训练的模型,已加载权重。

数据类型:torch.nn.module

record_file

输入

量化因子记录文件路径及名称。

数据类型:string

input_data

输入

模型的输入数据。一个torch.tensor会被等价为tuple(torch.tensor)。

数据类型:tuple

quant_retrain_model

返回值

修改后可用于量化感知训练的torch.nn.module模型。

默认值:None

数据类型:torch.nn.module

返回值说明

量化感知训练的模型。

函数输出

无。

调用示例

import amct_pytorch as amct
# 建立待进行量化感知训练的网络图结构
model = build_model()
model.load_state_dict(torch.load(state_dict_path))
input_data = tuple([torch.randn(input_shape)])
 
scale_offset_record_file = os.path.join(TMP, 'scale_offset_record.txt')
# 插入量化API
quant_retrain_model = amct.create_quant_retrain_model(
               config_json_file,
               model,
               scale_offset_record_file,
               input_data)
搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词