[AIROCMLIR-1093] Support arbitrary element types for expand_strides#2434
[AIROCMLIR-1093] Support arbitrary element types for expand_strides#2434justinrosner wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR broadens rock.expand_strides type support to unblock MIGraphX E2E models that produce non-contiguous i32 outputs (e.g., quantized convolutions). It does so by relaxing the operand element-type constraints while moving rank/element-type consistency checks to declarative ODS traits, and adds regression coverage.
Changes:
- Update
rock.expand_stridesto accept any tensor/memref element type, while requiring operand rank match + operand element-type match via declarative traits. - Simplify
ExpandStridesOp::verify()by removing redundant rank/element-type checks now covered by traits, keeping the shape-extent check. - Add new Rock dialect tests (tensor + memref
i32) and an E2E repro for non-contiguousi32quant-conv output layouts.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| mlir/include/mlir/Dialect/Rock/IR/RockOps.td | Loosens expand_strides operand type constraints to any element type and adds declarative verification traits for rank + element-type matching. |
| mlir/lib/Dialect/Rock/IR/RockDialect.cpp | Removes now-redundant rank/element-type checks from ExpandStridesOp::verify(), leaving dimension-size validation. |
| mlir/test/Dialect/Rock/ops.mlir | Adds positive tests for rock.expand_strides on i32 tensors and memrefs. |
| mlir/test/Dialect/Rock/invalid.mlir | Updates expected diagnostics to match trait-driven verifier messages for rank/element-type mismatch cases. |
| mlir/test/fusion/pr-e2e/mixr-quant-conv-non-contiguous-strides.mlir | Adds an E2E regression test exercising the motivating i32 non-contiguous output-layout scenario. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This does not require a port to rocmlirTriton. See the comments here in the initial rocmlirTriton implementation for further details: https://github.com/ROCm/rocmlirTriton/pull/114 |
There was a problem hiding this comment.
Verdict: APPROVE -- submitted as COMMENT (automated reviews are advisory) · Findings: 0 (0 Critical, 0 Major, 0 Minor)
Scope
Relaxes rock.expand_strides to accept any tensor/memref element type (motivated by MIGraphX quantized convolutions with non-contiguous i32 outputs). Replaces the TensorOrMemRefOf<[F32,F16,BF16,I8]> operand constraint with AnyTensorOrMemRef, and moves the rank-match and element-type-match checks from the hand-written verify() into the declarative AllRanksMatch/SameOperandsElementType traits. Touches RockOps.td, RockDialect.cpp, two Lit tests, and adds one E2E fusion test.
Findings
No blocking issues found.
Notes
- The refactor is idiomatic MLIR: using declarative traits over hand-rolled checks satisfies the DRY guidance in the checklist. The removal of the manual rank check in
RockDialect.cpp:880is safe because trait verifiers run before the op'sverify(), so the remainingllvm::zip_equalover shapes is guaranteed equal ranks first. - The
invalid.mlirdiagnostics were correctly updated to the trait-generated wording, andops.mliradds both tensor and memref i32 positive cases. The op retainshasVerifier = 1with a meaningfulverify()body (output-dim >= input-dim), so the checklist's op-verifier requirement still holds. SameOperandsElementTypeconstrains only the two operands, not the optional result; this matches the pre-existing behavior (the oldverify()never checked the result element type either), so no regression is introduced.- Reviewer @umangyadav already flagged moving
mlir/test/fusion/pr-e2e/mixr-quant-conv-non-contiguous-strides.mlirto the nightly suite; worth resolving that thread before merge. A minor trailing blank line was added at the end ofops.mlir— harmless but easy to drop.
CI status
All functional checks pass (C/C++ premerge, Python format/lint, Python perf). The auto-review pipeline's own review check is expected to be in-progress and is not a CI failure.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2434 +/- ##
===========================================
+ Coverage 82.57% 83.51% +0.95%
===========================================
Files 120 120
Lines 42852 42934 +82
Branches 7110 7138 +28
===========================================
+ Hits 35381 35856 +475
+ Misses 4815 4501 -314
+ Partials 2656 2577 -79
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Motivation
Certain MIGraphX E2E models have quantized convolutions with non-contiguous i32 output layouts. The operation previously restricted operands to floating-point and i8 types, causing verification to reject valid i32 outputs.
Technical Details
This PR updates the
expand_stridesin the following ways:rock.expand_stridesto accept any tensor or memref element type.Test Plan
Test Result
Submission Checklist