当前位置:网站首页>Dynamic dimensions required for input: input, but no shapes were provided. Automatically overriding

Dynamic dimensions required for input: input, but no shapes were provided. Automatically overriding

2022-07-05 08:40:00 Mr.Q

问题:pth转onnx时设置了动态维度Dynamic dimensions,如下所示

torch.onnx.export(model, input_tensor, output_onnx,
    opset_version=12,
    do_constant_folding=True,
    input_names=["input"],
    output_names=["output"],
    dynamic_axes={"input": {0: "batch", 2: "height", 3: "width"},
                  "output": {0: "batch", 2: "height", 3: "width"}},
    verbose=False)

但是,onnx转trt时,必须指定推理维度,否则会报warning:

[W] Dynamic dimensions required for input: input, but no shapes were provided. Automatically overriding shape to: 1x3x1x1

输入维度变成了1x3x1x1,显然不对。

解决办法

需指定维度:

 

trtexec.exe --onnx=E:\code\python\TensorRT-main\quickstart\SemanticSegmentation\fcn-resnet101.onnx --minShapes=input:1x3x1026x1282 --optShapes=input:1x3x1026x1282 --maxShapes=input:4x3x1026x1282 --workspace=4096 --saveEngine=E:\code\python\TensorRT-main\quickstart\SemanticSegmentation\fcn-resnet101.engine

原网站

版权声明
本文为[Mr.Q]所创,转载请带上原文链接,感谢
https://blog.csdn.net/jizhidexiaoming/article/details/125515503