swin_transformer in pytorch fails to run after converting to onnx #19280
Labels
platform:windows
issues related to the Windows platform
stale
issues that have not been addressed in a while; categorized by a bot
Describe the issue
After converting the swin_transformer model under the pytorch framework into an onnx model and enabling dynamic input, the following error occurs:
onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Non-zero status code returned while running Reshape node. Name:'Reshape_2' Status Message: /onnxruntime_src/onnxruntime/core/providers/cpu/tensor/reshape_helper.h:42 onnxruntime::ReshapeHelper::ReshapeHelper(const onnxruntime::TensorShape&, std::vector&) gsl::narrow_cast<int64_t>(input_shape.Size()) == size was false. The input tensor cannot be reshaped to the requested shape. Input shape:{4,96,64,64}, requested shape:{1,96,4096}
Locate the error statement as x = x.view (-1, H * W, C),Using visual tools to view this layer is as follows:
The reshape parameter of this layer is recorded as a fixed value. How can I modify it to solve this problem
To reproduce
The conversion code is as follows:
torch.onnx.export(model, (input0, input1), "./best.onnx", verbose=True, input_names=['input0', 'input1'], output_names=['output'], dynamic_axes={'input0':{0:'batch', 2:'height',3:'width'}, 'input1':{0:'batch'}, 'output':{0:'batch'}}, opset_version=11)
Urgency
No response
Platform
Windows
OS Version
ubuntu18.04
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
1.7.0
ONNX Runtime API
Python
Architecture
X64
Execution Provider
Default CPU
Execution Provider Library Version
No response
The text was updated successfully, but these errors were encountered: