问题:在做静态量化是,遇见onnx opset version版本报错
解决办法:
with tempfile.NamedTemporaryFile() as fp:
torch.onnx.export(model,
args=tuple(dummy_input.values()),
f = output_model_name,
input_names=list(dummy_input),
output_names=output_names,
dynamic_axes=dynamic_axes,
opset_version=10)
将onnx转换模型代码最后一行opset_version=10修改为要求的版本opset_version=13,即可。修改后
quantize_static(
model_input = model_path,
model_output = quant_model_path,
calibration_data_reader=data_reader, # 校准数据读取器
op_types_to_quantize=['MatMul'],
per_channel=True,
reduce_range=False,
weight_type=QuantType.QInt8,
nodes_to_exclude=nodes_to_exclude,
activation_type=QuantType.QInt8,
)
重新写静态量化,则可以正常进行。
标签:13,format,onnx,opset,version,output,input,model From: https://blog.51cto.com/u_12727662/7434900