[Bug] [Relax][ONNX] Elu, Selu and LRN construct FLOAT scalars for FLOAT16 inputs
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- machine-learning
Research direction
The three converters are the Elu, Selu and LRN handlers in the Relax ONNX frontend, which is where the FLOAT scalar constants are built; Elu and Selu create default FLOAT constants for subtraction, and LRN creates FLOAT constants for multiplication. Start by running the repro script from the issue and compare the FLOAT and FLOAT16 paths. Done means all three ops import for FLOAT16 with scalar constants matching the input dtype, and the FLOAT case still passes.
Written by the indexing model from the issue text.
Description
Expected behavior
The ONNX Elu, Selu and LRN converters should accept FLOAT16 inputs, as allowed by their schemas, and create scalar constants with a compatible dtype.
Actual behavior
All three FLOAT controls import. The otherwise identical FLOAT16 models pass full ONNX checking but fail with:
TypeError: Binary operators must have the same datatype for both operands.
Elu/Selu construct default FLOAT constants for subtraction; LRN explicitly creates FLOAT constants for multiplication. This is in the Relax ONNX converters, separate from the earlier TOPI LRN result-dtype fix in #11032.
Environment
TVM 0.28.dev0 (local build; build commit unavailable), Python 3.12.3, Linux x86_64; ONNX 1.22.0, NumPy 2.5.4.
Steps to reproduce
Run with python repro.py:
import onnx
from onnx import TensorProto as T, helper as h
from tvm.relax.frontend.onnx import from_onnx
for op in ["Elu", "Selu", "LRN"]:
for dtype in [T.FLOAT, T.FLOAT16]:
attrs = {"size": 3} if op == "LRN" else {}
node = h.make_node(op, ["x"], ["y"], **attrs)
model = h.make_model(h.make_graph([node], op,
[h.make_tensor_value_info("x", dtype, [1, 3, 2, 2])],
[h.make_tensor_value_info("y", dtype, [1, 3, 2, 2])]),
opset_imports=[h.make_opsetid("", 18)], ir_version=10)
onnx.checker.check_model(model, full_check=True)
try:
from_onnx(model, keep_params_in_input=False)
print(op, T.DataType.Name(dtype), "imported")
except Exception as error:
print(op, T.DataType.Name(dtype), type(error).__name__, str(error).splitlines()[-1])
Triage
- needs-triage
- Dominant language
- Python
- Stars
- 13.9k
- Forks
- 4k
- Avg merge
- 8h 6m
- Merged PRs (30d)
- 184
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/tvm
-
needs-triage type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
needs-triage type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
needs-triage type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
[Bug][Relax] ReorderTakeAfterMatmul fails on vector dot productsPossibly taken @hiyufan claimed this 10 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
apache/tvm#20595 · 1 comment ·
Maintainers usually reply within 1 day
-
needs-triage type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
Similar issues
-
bug ready-for-dev
Difficulty 1/5 1-3 hours Newbie friendliness 92/100
OpenHands/extensions#897 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
tensorflow/datasets#11253 ·
Maintainers usually reply within 1 day
-
fix(core): a config section with all keys commented out crashes startupPossibly taken @Aryanbhargava18 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
kubeflow/mcp-server#512 ·
Maintainers usually reply within 1 day
-
Stop trusting the compromised eMudhra CA certificatesPossibly taken @anth-volk claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
PolicyEngine/uk-triple-lock#54 ·
Maintainers usually reply within 1 day
-
DBFS append mode silently overwrites existing filesPossibly taken @IlyaKhalafi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
fsspec/filesystem_spec#2429 ·
Maintainers usually reply within 1 day