feat(hipsr): add compute and compute_yield ops - #614
Closed
zpye wants to merge 1 commit into
Closed
Conversation
hipsr.compute groups the operations that implement one high-level computation into a single DPS op with an isolated body region, so an ONNX op needing several tensor or shape operations does not leave intermediate values in the enclosing block. A hipsr.placeholder accepts only block arguments and constant or placeholder results as inputs, so loose intermediates would otherwise block placeholder-based output shaping. The op carries no hand-written verifier. Every rule the design proposed checking by hand already comes from a trait or interface: SizedRegion<1> and SingleBlock for the block count, SingleBlockImplicitTerminator for the terminator, RegionBranchOpInterface for both control-flow edges, DestinationStyleOpInterface for init and result tying, and IsolatedFromAbove for boundary crossings. test/lit/Dialect/Hipsr/ compute.mlir asserts the message each mechanism emits. Two traits from the design are left out on purpose. PromotableRegionOpInterface does not exist in the pinned MLIR, and the Promotable* family it resembles is Mem2Reg/SROA slot promotion rather than region flattening. ConditionallySpeculatable only feeds isPure, whose consumers are LICM and related hoisting paths; the hipsr pipeline has no loops to hoist a compute out of, and RecursiveMemoryEffects already lets dead-code elimination erase an unused one. This step adds the ops only, with no conversion-pattern users and no bufferization model, so a compute that reached one-shot bufferize would fail. That is unreachable today because -hipsr-bufferize does not exist. Made-with: Cursor Co-authored-by: Cursor <cursoragent@cursor.com>
|
Thanks for opening a PR! This project follows LLVM's incremental-development and AI-tool-use Before requesting review, please check that:
Reviewers are assigned through |
zpye
marked this pull request as ready for review
July 31, 2026 11:30
zpye
requested review from
amd-mingw,
edelaye,
fhanuman,
qianglin-amd and
wcy123
as code owners
July 31, 2026 11:30
Collaborator
Author
|
Superseded by #615, which carries the same commit from a branch in this repository so that CI runs with full repository access. Closing this one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
hipsr.computeandhipsr.compute_yield.hipsr.computeis a DPS op whose isolated single-block region groups the operations that implement one high-level computation, so an ONNX op needing several tensor or shape operations stays a single hipsr op.Ops only: nothing emits one yet, so no existing behavior changes.
Related issue or design
None.
Why
hipsr.placeholderaccepts only block arguments and constant or placeholder results as inputs. Without a grouping op, a multi-operation lowering leaves intermediates in the enclosing block, and the placeholder of a later op would have to take one as an input, which its verifier rejects.The body is
IsolatedFromAbove, so the context, inputs, and inits enter it as entry-block arguments in that order.There is no hand-written verifier.
SizedRegion<1>,SingleBlock,SingleBlockImplicitTerminator,RegionBranchOpInterface,DestinationStyleOpInterface, andIsolatedFromAbovealready produce every check, and the tests assert the message each one emits.What
hipsr.compute:!hipsr.contextfirst, then variadicinsandoutsinits, variadic tensor results, one$bodyregion.Hipsr_TensorOrDeviceMemRef, so the op survives bufferization to device memrefs. Memref inits mean zero tensor results, which the optional result-type group allows.Variadic<AnyType>, so the body can also take values like anindexextent.hipsr.compute_yieldmirrorshipsr.pool_domain_yield.hipsr.placeholderjob, and-hipsr-populate-shape-regionskips this op.Test plan
New
test/lit/Dialect/Hipsr/compute.mlir: three positive cases (tensor init, multiple inits with a non-tensor input, device-memref inits with no results) and ten negative cases, one per verification mechanism. Expected diagnostics were copied from realhip-mlir-optoutput.Both failures are pre-existing on
mainand unrelated:test_gather_block_quantized.mlir(--convert-onnx-to-hip) andtest_compress_model.mlir(--hipdnn-pipeline).pre-commit run --all-filespasses.Notes for reviewers
hipsr.computereaching one-shot bufferize would fail. Unreachable today because-hipsr-bufferizedoes not exist.(resultTypes, ctx, inputs, inits)builder leaves the body blockless, so the first conversion pattern must create the entry block itself;@empty_bodyand@missing_context_argumentpin the diagnostics it sees otherwise.Checklist
descriptionblocks carry the contract.AI assistance: drafted with Cursor. Diagnostics were captured from real tool output and the test numbers come from local build and CTest runs. The commit carries
Made-withandCo-authored-bytrailers.