apache / tvm

Open deep learning compiler stack for cpu, gpu and specialized accelerators
https://tvm.apache.org/
Apache License 2.0
11.76k stars 3.47k forks source link

[Bug] ```from_onnx``` Gather op segmentation fault #15087

Open makaveli10 opened 1 year ago

makaveli10 commented 1 year ago

Environment

Ubuntu 20.04, onnx opset version 11, tvm version 0.13.dev0

Steps to reproduce

tvmc tune --target "cuda" --output autotune.json encoder_model.onnx

For the gather op I see a segmentation fault in relay.frontend.from_onnx on line. Which calls fold_constant() on this node less(0i64 /* span=/layers.0/self_attn/Gather./layers.0/self_attn/Constant_output_0:0:0 */, 0i64):

op_name = Gather,
attrs: {'axis': 0, 'tvm_custom': {'name': '/layers.0/self_attn/Gather', 'num_outputs': 1}}
less(0i64 /* span=/layers.0/self_attn/Gather./layers.0/self_attn/Constant_output_0:0:0 */, 0i64)

there are two inputs to Gather:

0: 
    meta[relay.Constant][0] 
    type: /* span=/layers.0/self_attn/Shape:0:0 */

1:
    0i64 
    type: /* span=/layers.0/self_attn/Gather./layers.0/self_attn/Constant_output_0:0:0 */

cc @Hzfengsy @junrushao @shingjan

quic-sanirudh commented 1 year ago

I can try to fix this if you could provide a small test case to reproduce this issue locally. Perhaps a small onnx model that contains just the subgraph including the gather op?

P.S. I've found the onnx-modifier tool to be very useful to create small subgraphs for test cases in onnx. Or if you could share the whole model, that should also be fine.