onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Load model from /data_dir/project/e2eonnx/onnx/five_actions/tad.onnx failed:Type Error: Type parameter (T) of Optype (Concat) bound to different types (tensor(int64) and tensor(float) in node (Concat_5090).
解决思路:
首先使用了工具:Netron
发现输出当中,混了一个int64
然后再看日志
roi确实是int64啊
然后在代码中打印
但是打印出来的是float啊,怎么会突然变成了Long(int64)???
为了进一步验证,我单独输出roi,发现roi还是自动变成了int64
所以我猜测是这个里面的某个操作,变成了long,导致roi也变成了long
排bug的方式是逐行return
最后定位到最后面那个cat有错误
但是呢,在正常的训练或测试中,rois_abs是float类型,但是到了onnx中就是long类型
因为batch_ind是long类型。在正常训练测试中,rois_abs会自动转型,但是onnx不行。
所以要将batch_ind变成float类型。
bug解决
体会:一定要定位出哪里问题才能解决bug
最后来对比一下,上面是训练代码,下面则是能转onnx的代码,能训练未必能转onnx