Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a bug cause: onnxruntime.capi.onnxruntime_pybind11_state.Fail #1028

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bilibili12433014
Copy link

fix a bug which may cause err: onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Load model from *.onnx failed:Type Error: Type parameter (T) of Optype (Where) bound to different types (tensor(int64) and tensor(float) in node (/end2end/Where_1).
修复了一个会导致onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Load model from *.onnx failed:Type Error: Type parameter (T) of Optype (Where) bound to different types (tensor(int64) and tensor(float) in node (/end2end/Where_1).的bug。

原因是在导出到onnx时,batched_labels.new_ones应该创建一个与自身相同类型的tensor(在python中运行时确实如此),然而实际导出后创建的tensor类型(float)与batched_labels(int)不一致,造成了运行时err。

在旧版本中并没有出现这个问题(暂时不清楚是由于旧版pytorch没有这个导出bug还是onnx的where能够跨类型使用)
出现这个bug的版本是:
pytorch 2.1.0a0+41361538.nv23.6+onnxruntime-gpu 1.17.0

修改前:
图片

修改后:
图片

注意:在下面2个issue中,都有类似的err,其中一条是由于seg不支持end2end导出,另一条是由于此bug而产生,虽然issue已经被关闭,然而问题的根源并没有被解决。
#1021
#1013 (comment)

fix a bug which may cause err: onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Load model from *.onnx failed:Type Error: Type parameter (T) of Optype (Where) bound to different types (tensor(int64) and tensor(float) in node (/end2end/Where_1).
FutureWarning: torch.cuda.amp.autocast(args...) is deprecated. Use torch.amp.autocast('cuda', args...) instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant