Skip to content

[Fix][Relax][ONNX] Keep constant Concat as tensor data - #21100

Open
Nanmur wants to merge 1 commit into
apache:mainfrom
Nanmur:codex/fix-onnx-concat-int64-data
Open

Nanmur wants to merge 1 commit into
apache:mainfrom
Nanmur:codex/fix-onnx-concat-int64-data

Conversation

@Nanmur

@Nanmur Nanmur commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #20889.

Problem

Concat currently classifies every 1-D INT64 constant as shape-like before reaching its tensor constant-folding branch. Consequently, Concat(Constant([1]), Constant([2])) returns a ShapeExpr, and its ordinary tensor Add consumer fails with Node add_data cannot handle ShapeExpr inputs.

Change

Move the existing tensor constant-folding path before shape specialization. Concatenating actual constants now returns a tensor constant regardless of its dtype. Mixed symbolic ShapeExpr/constant construction and the existing parameter-resolution path remain unchanged.

This is deliberately scoped to actual constant operands (including initializers when keep_params_in_input=False). It does not redefine the existing shape specialization of all-INT64 parameter Vars retained under keep_params_in_input=True.

Regression coverage

  • INT64 Constant nodes, embedded initializers, and mixed runtime operands, followed by Add; also verify the Concat output itself.
  • Axis 0 and -1, and both parameter modes where applicable.
  • Mixed runtime input/initializer concatenation retains replaceable runtime parameters.
  • Both constant and symbolic Concat-derived Reshape targets, including retained initializer shape values.

Local validation

  • Original main Concat converter: 6 failed, 16 passed, with the six failures reproducing the reported ShapeExpr/Add error.
  • Patched converter: 22 passed, with LLVM compilation, VM execution, dtype/shape checks, and exact comparisons against ONNX ReferenceEvaluator.
  • Ruff 0.12.3 check and format check passed; git diff --check passed.

Validation used the main Concat class loaded verbatim into an existing local TVM 0.26.dev0 LLVM runtime, with compatibility aliases kept outside this PR. This is not a full rebuild or full-suite result for current main; upstream CI is still required.

Test command for a current-main build:

python -m pytest tests/python/relax/test_frontend_onnx_concat_int64.py -q

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] [Relax][ONNX] Constant INT64 Concat data becomes ShapeExpr and breaks Add

1 participant