forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 4
Consider linalg.index an affine dim #537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0014ce5
Consider linalg.index an affine dim
cferry-AMD 402c8d3
Use a trait to avoid two-way dialect dependence
cferry-AMD 1b76b91
End-of-file empty lines
cferry-AMD 182dd49
Add a test with affine.if to make sure it doesn't get a symbol
cferry-AMD b9293b0
Add origin of changes within contents
cferry-AMD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| //===- AffineTraits.h - MLIR Affine Traits --------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file defines traits brought in by the Affine dialect. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| #ifndef AFFINE_TRAITS_H | ||
| #define AFFINE_TRAITS_H | ||
|
|
||
| #include "mlir/IR/OpDefinition.h" | ||
|
|
||
| namespace mlir::OpTrait { | ||
|
|
||
| template <typename ConcreteType> | ||
| class AffineDim : public TraitBase<ConcreteType, AffineDim> { | ||
| public: | ||
| static LogicalResult verifyTrait(Operation *op) { return success(); } | ||
| }; | ||
|
|
||
| } // namespace mlir::OpTrait | ||
|
|
||
| #endif // AFFINE_TRAITS_H |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===- AffineTraits.td - Affine dialect traits -------------*- tablegen -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Defines traits brought in by the MLIR Affine dialect. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| #ifndef AFFINE_TRAITS | ||
| #define AFFINE_TRAITS | ||
|
|
||
| include "mlir/IR/OpBase.td" | ||
|
|
||
| // Trait to declare that an op result is an affine dimension identifier. | ||
| // Prevents the result from being seen as a symbol into AffineMaps | ||
| // and IntegerSets. | ||
| def AffineDim : NativeOpTrait<"AffineDim">; | ||
|
|
||
| #endif // AFFINE_TRAITS | ||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // RUN: mlir-opt -canonicalize %s | FileCheck %s | ||
|
|
||
| // Check that linalg.index does not cause folding of affine.if set to | ||
| // a symbolic set. | ||
cferry-AMD marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // CHECK: = affine_set<(d0) : (-d0 + 5 >= 0)> | ||
| #set = affine_set<(d0) : (-d0 + 5 >= 0)> | ||
|
|
||
| func.func @linalg_index_affine_if(%in: tensor<10xf32>) -> tensor<10xf32> { | ||
| %empty = tensor.empty() : tensor<10xf32> | ||
| %out = linalg.generic { | ||
| indexing_maps = [affine_map<(i) -> (i)>, affine_map<(i) -> (i)>], | ||
| iterator_types = ["parallel"]} | ||
| ins(%in : tensor<10xf32>) | ||
| outs(%empty : tensor<10xf32>) { | ||
| ^bb0(%a: f32, %b: f32): | ||
| %c42f = arith.constant 42.0 : f32 | ||
| %i = linalg.index 0 : index | ||
| %ret = affine.if #set(%i) -> f32 { | ||
| affine.yield %a : f32 | ||
| } else { | ||
| affine.yield %c42f : f32 | ||
| } | ||
| linalg.yield %ret : f32 | ||
| } -> tensor<10xf32> | ||
| return %out : tensor<10xf32> | ||
| } | ||
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
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
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.