add WhileCyclicTranposePropagate transform pattern#2450
Open
mofeing wants to merge 9 commits into
Open
Conversation
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
WhileBodyBoundaryTranposePropagateWhileCyclicTranposePropagate
WhileCyclicTranposePropagateWhileCyclicTranposePropagate transform pattern
Member
|
@avik-pal can you review? |
Collaborator
Author
|
just detected a couple of bugs that make |
Collaborator
Author
|
okay, so the problem I'm running into is that if I add it to the same transform sequence, it goes on an infinite loop on the but if I run the same test on different steps, it works perfectly. MWEthis gets stuck ./bazel-bin/enzymexlamlir-opt \
--enzyme-hlo-generate-td="patterns=transpose_while;transpose_transpose;while_cyclic_transpose_propagate(1);transpose_transpose;transpose_is_reshape" --transform-interpreter --enzyme-hlo-remove-transform \
--allow-unregistered-dialect test/lit_tests/while-transpose-test.mlir --verify-each=1but this works and generates the correct code ./bazel-bin/enzymexlamlir-opt \
--enzyme-hlo-generate-td="patterns=transpose_while;transpose_transpose" --transform-interpreter --enzyme-hlo-remove-transform \
--enzyme-hlo-generate-td="patterns=while_cyclic_transpose_propagate(1)" --transform-interpreter --enzyme-hlo-remove-transform \
--enzyme-hlo-generate-td="patterns=transpose_transpose;transpose_is_reshape" --transform-interpreter --enzyme-hlo-remove-transform \
--allow-unregistered-dialect test/lit_tests/while-transpose-test.mlir --verify-each=1module {
func.func @test_while_transpose_elimination(%arg0: tensor<2x3xf32>, %arg1: tensor<i64>) -> tensor<3x2xf32> {
%c = stablehlo.constant dense<1> : tensor<i64>
%c_0 = stablehlo.constant dense<true> : tensor<i1>
%0 = stablehlo.transpose %arg0, dims = [1, 0] : (tensor<2x3xf32>) -> tensor<3x2xf32>
%1:2 = stablehlo.while(%iterArg = %0, %iterArg_1 = %arg1) : tensor<3x2xf32>, tensor<i64>
cond {
stablehlo.return %c_0 : tensor<i1>
} do {
%2 = stablehlo.transpose %iterArg, dims = [1, 0] : (tensor<3x2xf32>) -> tensor<2x3xf32>
%3 = "unregistered.custom_transform"(%2) : (tensor<2x3xf32>) -> tensor<3x2xf32>
%4 = stablehlo.add %iterArg_1, %c : tensor<i64>
stablehlo.return %3, %4 : tensor<3x2xf32>, tensor<i64>
}
return %1#0 : tensor<3x2xf32>
}
} |
Collaborator
|
There is a |
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.
this should fix the problem in @luraess's code https://github.com/luraess/PlayReactant/blob/main/scripts/diff2D_bench.jl