Skip to content

[Relax][ONNX] Add cosine-sum window converters - #20819

Open
hiyufan wants to merge 1 commit into
apache:mainfrom
hiyufan:feat/onnx-window-functions-20124
Open

hiyufan wants to merge 1 commit into
apache:mainfrom
hiyufan:feat/onnx-window-functions-20124

Conversation

@hiyufan

@hiyufan hiyufan commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

The Relax ONNX frontend rejects HannWindow, HammingWindow and BlackmanWindow models. Add shared cosine-sum lowering using existing Relax operators and the existing tensor-to-shape helper for runtime lengths.

Support int32/int64 size inputs, initializer/runtime lengths, periodic/symmetric modes, the default float32 output and numeric output casts. Compute in float32, use ONNX's Hamming coefficients, and add the constant offset after the cosine terms to match native window-kernel rounding before integer casts. Validate the periodic attribute and positive initializer lengths.

Related to #20124 (these three window operators only).

Validation on main e345029c, Python 3.11, LLVM 21.1.8, ONNX 1.23.2 and ONNX Runtime 1.31.0:

  • Before the converters: all 30 selected checker-valid cases fail to import, covering all three operators.
  • All 120 added window tests passed across the matrix and dynamic-VM reuse runs. Coverage includes default/explicit periodic mode, initializer/runtime sizes, int32/int64 size dtypes, float16/float32/float64/int32 outputs, bfloat16 casts, lengths 1/2/7, invalid initializer lengths and invalid periodic values. Six reuse tests run the same compiled VM at lengths 1, 2, 7 and 10.
  • Values, shapes and dtypes are checked against ONNX Runtime. Bfloat16 outputs use its float32 result followed by an independent NumPy bfloat16 cast.
  • Adjacent Range tests: 11 passed; two float32 count tests return 32 elements versus ONNX Runtime's 33. Both failures reproduce on an untouched main worktree with the same native build and dependencies: test_range_constant_float and test_range_dynamic_scalar_inputs[-7.8--1.4-0.2-1-float32]. The Range converter is unchanged.
  • File-scoped Ruff, ASF header/file-type and whitespace checks passed.

Prepared with OpenAI Codex assistance. The LLVM build and validation above were executed locally using the pinned TIRx/FFI sources.

@hiyufan
hiyufan marked this pull request as ready for review October 25, 2026 11:27

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.

1 participant