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.
This PR introduces an operation
finch.stepper
and a corresponding passfinch-looplet-stepper
.It is a reimplemented version of https://github.com/finch-tensor/Finch.jl/blob/main/src/looplets/steppers.jl in Finch.jl
1.
finch.stepper
operationinclude/Finch/FinchOps.td
This operation defines the Stepper Looplet, which represents repetitive patterns in child looplets.
Stepper takes four function arguments that always return with
finch.return
:seek:
coordinate:index -> position:index
Returns the position of the child looplet whose range includes the given input coordinate.
stop:
position:index -> coordinate:index
Returns the coordinate at which the child looplet at the given position ends.
body:
position:index -> child:looplet
Returns the child looplet located at the specified position.
next:
position:index -> position:index
Returns the subsequent position following the given position.
finch.stepper seek(crd):pos, stop(pos):crd, body(pos):looplet, next(pos):pos
can be thought as a functionExample mlir :
2.
finch-looplet-stepper
passLowers finch.access of finch.stepper inside scf.for
A pseudocode of lowering a single stepper looks like :
to
3. Test cases
You can find tests at https://github.com/finch-tensor/Finch-mlir/blob/b453a57d9193e73ee64f55d60987be51fd30bec0/test/Finch/looplet-stepper.mlir
cmake --build build --target check-finch
will run this test automatically, but if you want to run manually, do :./build/bin/finch-opt ./test/Finch/looplet-stepper.mlir --finch-looplet-stepper