使用paddle2onnx导出的segformer onnx,报Integer division by zero
Author: FreemanTangCreated Apr 2, 2026Updated Apr 2, 2026
Labelsbug
问题确认 Search before asking
- 我已经查询历史issue(包括open与closed),没有发现相似的bug。I have searched the open and closed issues and found no similar bug report.
Bug描述 Describe the Bug
@wuyefeilin @juncaipeng 大佬们,请教一下,我使用paddle2onnx导出的segformer onnx模型,在使用onnxruntime推理时报Integer division by zero,是什么原因导致的,有解决方法吗?
paddle2onnx --model_dir inference_model ^
--model_filename model.pdmodel ^
--params_filename model.pdiparams ^
--save_file model.onnx最奇怪的点是,一样是segformer导出的onnx模型,只是训练时input_shape不一样,但是input_shape:[1,3,384,192]的可以正常推理,但是input_shape:[1,3,384,96]的就报错了(Integer division by zero),并且我调试发现是session初始化时就报错了。
复现环境 Environment
- OS: Windows -
- PaddlePaddle: 2.4.2
- PaddleSeg: release/2.8
- paddle2onnx:1.3.0
- Python: 3.10.0
Bug描述确认 Bug description confirmation
- 我确认已经提供了Bug复现步骤、代码改动说明、以及环境信息,确认问题是可以复现的。I confirm that the bug replication steps, code change instructions, and environment information have been provided, and the problem can be reproduced.
是否愿意提交PR? Are you willing to submit a PR?
- 我愿意提交PR!I'd like to help by submitting a PR!
Source: PaddlePaddle/PaddleSeg