[Bug] [Relax][ONNX] NonMaxSuppression silently replaces a runtime output limit with zero
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 67/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
Start in python/tvm/relax/frontend/onnx/onnx_frontend.py at the converter lines linked in the report, and trace how a runtime max_output_boxes_per_class Var is handled when it is absent from the initializer table. Compare the dynamic-input and initializer cases using the reproduction with scalar inputs and an explicit IoU threshold. Done means the runtime limit selects the same two rows as the constant limit, with relevant tests passing.
由索引模型根据 Issue 内容生成。
描述
Expected behavior
A runtime max_output_boxes_per_class=2 should select the same two disjoint boxes as an initializer containing the identical value.
Actual behavior
The constant-limit control matches ORT. Making only the limit a graph input silently changes the result from two rows to no selections:
constant limit (2, 3) [[0, 0, 0], [0, 0, 1]]
runtime limit (0, 3) []
The converter substitutes zero when a limit Var is absent from the initializer table. This case uses zero-dimensional scalars and an explicit IoU threshold, unlike #19693 and #20506.
Environment
TVM 0.28.dev0, LLVM 18.1.3, Linux x86_64; Python 3.12.3, NumPy 2.5.4, ONNX 1.22.0, ORT 1.29.0. The installed binary build revision is unknown; current main was inspected statically, not rebuilt.
Steps to reproduce
Run with an LLVM-enabled TVM installation:
import numpy as np
import onnx
import onnxruntime as ort
import tvm
from onnx import TensorProto as T, helper as h, numpy_helper as nh
from tvm import relax
from tvm.relax.frontend.onnx import from_onnx
boxes = np.array([[[0, 0, 1, 1], [2, 2, 3, 3]]], dtype="float32")
scores = np.array([[[0.9, 0.8]]], dtype="float32")
limit = np.array(2, dtype="int64")
expected = np.array([[0, 0, 0], [0, 0, 1]], dtype="int64")
for dynamic in (False, True):
inputs = [h.make_tensor_value_info("boxes", T.FLOAT, [1, 2, 4]),
h.make_tensor_value_info("scores", T.FLOAT, [1, 1, 2])]
constants = [nh.from_array(np.array(0.5, dtype="float32"), "iou")]
feeds = {"boxes": boxes, "scores": scores}
if dynamic:
inputs.append(h.make_tensor_value_info("limit", T.INT64, []))
feeds["limit"] = limit
else:
constants.append(nh.from_array(limit, "limit"))
model = h.make_model(h.make_graph([
h.make_node("NonMaxSuppression", ["boxes", "scores", "limit", "iou"], ["y"])],
"nms", inputs, [h.make_tensor_value_info("y", T.INT64, [None, 3])], constants),
opset_imports=[h.make_opsetid("", 11)], ir_version=10)
onnx.checker.check_model(model, full_check=True)
options = ort.SessionOptions()
options.intra_op_num_threads = options.inter_op_num_threads = 1
options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_DISABLE_ALL
source = ort.InferenceSession(model.SerializeToString(), options,
providers=["CPUExecutionProvider"]).run(None, feeds)[0]
np.testing.assert_array_equal(source, expected)
mod = from_onnx(model, keep_params_in_input=False)
vm = relax.VirtualMachine(relax.build(mod, target="llvm"), tvm.cpu())
actual = vm["main"](*[tvm.runtime.tensor(v) for v in feeds.values()]).numpy()
print("runtime limit" if dynamic else "constant limit", actual.shape, actual.tolist())
if not dynamic:
np.testing.assert_array_equal(actual, expected)
Triage
- needs-triage
- 主要语言
- Python
- 星标
- 13.9k
- 派生
- 4k
- 平均合并
- 8 小时 5 分钟
- 30 天内合并 PR
- 170
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/tvm 的其他 Issue
-
needs-triage type: bug
难度 2/5 1-3 小时 新手友好度 80/100
维护者通常 1 天内回复
-
[Bug] [Relax][ONNX] OneHot does not convert floating-point depth to int64可能已有人在做 @tandede 于 2 天前认领。 未关闭needs-triage type: bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
needs-triage type: bug
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
needs-triage type: bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
[Bug][Relax] ReorderTakeAfterMatmul fails on vector dot products可能已有人在做 @hiyufan 于 12 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 88/100
aws-samples/sample-per-model-bedrock#782 ·
维护者通常 1 天内回复
-
Google text documents are base64-encoded twice可能已有人在做 @feiiiiii5 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
coveragepy/coveragepy#2364 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100