tvm icon indicating copy to clipboard operation
tvm copied to clipboard

[Bug] [ONNX][FRONTEND] - Loop and NonMaximalSupression operators missing

Open Mathevilg opened this issue 9 months ago • 1 comments

When converting ONNX models that contain dynamic control flow (e.g., the Loop operator) or post-processing operations such as NonMaxSuppression using TVM's Relax ONNX frontend, the conversion fails with the following error:

tvm.error.OpNotImplemented: The following operators are not supported for frontend ONNX: Loop, NonMaxSuppression

This issue prevents conversion of models such as YOLOv3/YOLOv5 that include these operators. It appears that the Relax ONNX frontend does not currently implement these operators.

Steps to Reproduce: Export a YOLO model (or any model containing Loop and/or NonMaxSuppression) to ONNX. Load the ONNX model using TVM's Relax ONNX frontend:

import onnx
import tvm.relax as relax

onnx_model = onnx.load("path/to/model.onnx")
shape_dict = {"input": (1, 3, 640, 640)}
mod, params = relax.frontend.from_onnx(onnx_model, shape_dict)

Expected Behavior: Either these operators should be supported by the ONNX Relax frontend, or the frontend should provide a clear message or workaround (such as lowering them to supported operators) so that users can convert their models.

Environment:

TVM Version: 19
Model: YOLO model onnx - https://github.com/onnx/models/tree/main/validated/vision/object_detection_segmentation/yolov3

Additional Info: The issue appears when converting models that rely on dynamic control flow or include post-processing operators like Loop and NonMaxSuppression.

Additional Context: This issue was encountered while attempting to convert a YOLO model to TVM Relax IR. Any guidance or workarounds on handling these operators would be greatly appreciated.

cc @KJlaccHoeUM9l

Mathevilg avatar Mar 20 '25 07:03 Mathevilg

We meet the missing op too, and we are working on to support them, have any others also is working on them? Maybe we can share the work before we can send a formal PR.

Johnson9009 avatar Apr 23 '25 08:04 Johnson9009