Skip to content

feat(onnx-to-hip): stamp Slice params before constant externalization - #607

Open
amd-mounikk wants to merge 13 commits into
ROCm:mainfrom
amd-mounikk:feat/slice-shape-fold
Open

feat(onnx-to-hip): stamp Slice params before constant externalization#607
amd-mounikk wants to merge 13 commits into
ROCm:mainfrom
amd-mounikk:feat/slice-shape-fold

Conversation

@amd-mounikk

Copy link
Copy Markdown
Contributor

Summary

  • Add SliceShapeFold pre-lowering pass to stamp compile-time onnx.Slice starts/ends/axes/steps onto the op as hipdnn.slice_* attributes before lowerOnnxConstants externalizes operand constants.
  • Update SliceDecompose to prefer stamped attributes so slices rewrite to tensor.extract_slice instead of falling through to the hip.slice runtime stub.
  • Add LIT coverage for SwinV2 window and downsample stride slice patterns.

Motivation

Production builds externalize even small 1-element i64 Slice param constants into memref.global entries. Without stamping params before externalization, SliceDecompose cannot read compile-time values and every slice falls through to the stub runtime op. This blocks models like SwinV2 that rely on window/partition slices.

Test plan

  • pre-commit run --all-files
  • ctest --test-dir ../build/hip-ep_20260724 -C Release -R MorphizenMLIRLitTests --verbose
  • Verify SwinV2 slice paths compile to tensor.extract_slice (no hip.slice stub)

amd-mounikk and others added 11 commits July 27, 2026 10:47
Add end-to-end ReduceL2 lowering from onnx.ReduceL2 through hip.reduce_l2,
HipToLLVM runtime dispatch, and a HIP kernel. Includes mock runtime support,
LIT conversion/e2e tests, and numeric coverage in test_reduce.py.
Fix lintrunner/clang-format alignment in ReduceL2Conversion.cpp and
wrap_reduce_l2 declaration in hipdnn_ep_runtime.h.
Port ReduceProd-style axes extraction and buildReduceL2Init so dynamic
input dims lower correctly; add LIT and numeric coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Align mock wrap_reduce_l2 with the 11-arg ABI, harden the noop memcpy path, and clear stale HIP errors before hip_reduce_l2 kernel launch.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add SliceShapeFold pre-lowering pass to capture compile-time starts,
ends, axes, and steps onto onnx.Slice as hipdnn.slice_* attributes before
lowerOnnxConstants externalizes the operand constants. Update SliceDecompose
to prefer these stamped attributes so slices decompose to tensor.extract_slice
instead of falling through to the hip.slice runtime stub.

Add LIT coverage for SwinV2 window and downsample stride slice patterns.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown

Thanks for opening a PR!

This project follows LLVM's incremental-development and AI-tool-use
guidance. See CONTRIBUTING.md
for the project workflow.

Before requesting review, please check that:

  1. The change is focused. Substantial work links the relevant issue
    or design discussion.
  2. The PR documents relevant test results and updates affected
    documentation.
  3. If AI tools provided substantial assistance, the description
    explains what was assisted and how it was validated, and commit
    trailers identify the tool. The contributor has reviewed and
    understands the result.

Reviewers are assigned through
CODEOWNERS where ownership
is configured.

Probe legacy onnx-hipdnn-ep asset paths on the self-hosted GPU runner
when runner.workspace/model is missing after the hip-ep rename. Also
make perf-result publishing non-fatal for fork PRs that cannot post
comments with GITHUB_TOKEN.

Co-authored-by: Cursor <cursoragent@cursor.com>
@amd-mounikk
amd-mounikk marked this pull request as ready for review July 31, 2026 05:34
Mirror the perf publish step: fork PRs cannot post comments with
GITHUB_TOKEN, so write results to the step summary and exit cleanly.

Co-authored-by: Cursor <cursoragent@cursor.com>
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