-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir][ArmSME] Add test-lower-to-arm-sme pipeline #81732
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 all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
9 changes: 2 additions & 7 deletions
9
mlir/test/Integration/Dialect/Linalg/CPU/ArmSME/matmul-transpose-a.mlir
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
6 changes: 1 addition & 5 deletions
6
mlir/test/Integration/Dialect/Linalg/CPU/ArmSME/multi-tile-matmul.mlir
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
7 changes: 1 addition & 6 deletions
7
mlir/test/Integration/Dialect/Linalg/CPU/ArmSME/use-too-many-tiles.mlir
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
6 changes: 1 addition & 5 deletions
6
mlir/test/Integration/Dialect/Vector/CPU/ArmSME/load-store-128-bit-tile.mlir
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
6 changes: 1 addition & 5 deletions
6
mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-load-vertical.mlir
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
8 changes: 1 addition & 7 deletions
8
mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-multi-tile-transpose.mlir
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
6 changes: 1 addition & 5 deletions
6
mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-outerproduct-f32.mlir
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
6 changes: 1 addition & 5 deletions
6
mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-outerproduct-f64.mlir
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
8 changes: 1 addition & 7 deletions
8
mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-outerproduct-i8i8i32.mlir
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
6 changes: 1 addition & 5 deletions
6
mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-read-2d.mlir
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
7 changes: 1 addition & 6 deletions
7
mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-write-2d.mlir
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
6 changes: 1 addition & 5 deletions
6
mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transpose.mlir
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
6 changes: 1 addition & 5 deletions
6
mlir/test/Integration/Dialect/Vector/CPU/ArmSME/tile_fill.mlir
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
6 changes: 1 addition & 5 deletions
6
mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-load-store.mlir
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
5 changes: 1 addition & 4 deletions
5
mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-ops.mlir
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,16 @@ | ||
# Exclude tests from libMLIR.so | ||
add_mlir_library(MLIRArmSMETestPasses | ||
TestLowerToArmSME.cpp | ||
|
||
EXCLUDE_FROM_LIBMLIR | ||
|
||
LINK_LIBS PUBLIC | ||
MLIRArithToArmSME | ||
MLIRArmSMEToLLVM | ||
MLIRArmSMEToSCF | ||
MLIRIR | ||
MLIRPass | ||
MLIRTransforms | ||
MLIRVectorToArmSME | ||
MLIRVectorToSCF | ||
) |
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,99 @@ | ||
//===- TestLowerToArmSME.cpp - Test lowering to ArmSME as a sink pass -----===// | ||
// | ||
// 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 implements a pass for testing the lowering to ArmSME as a | ||
// generally usable sink pass. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "mlir/Conversion/ArithToArmSME/ArithToArmSME.h" | ||
#include "mlir/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.h" | ||
#include "mlir/Conversion/ArmSMEToSCF/ArmSMEToSCF.h" | ||
#include "mlir/Conversion/VectorToArmSME/VectorToArmSME.h" | ||
#include "mlir/Conversion/VectorToSCF/VectorToSCF.h" | ||
#include "mlir/Dialect/ArmSME/Transforms/Passes.h" | ||
#include "mlir/Dialect/ArmSVE/Transforms/Passes.h" | ||
#include "mlir/IR/DialectRegistry.h" | ||
#include "mlir/Pass/Pass.h" | ||
#include "mlir/Pass/PassManager.h" | ||
#include "mlir/Pass/PassOptions.h" | ||
#include "mlir/Transforms/Passes.h" | ||
|
||
using namespace mlir; | ||
|
||
namespace { | ||
struct TestLowerToArmSMEOptions | ||
: public PassPipelineOptions<TestLowerToArmSMEOptions> { | ||
PassOptions::Option<bool> fuseOuterProducts{ | ||
*this, "fuse-outer-products", | ||
llvm::cl::desc("Fuse outer product operations via " | ||
"'-arm-sme-outer-product-fusion' pass"), | ||
llvm::cl::init(true)}; | ||
}; | ||
|
||
void buildTestLowerToArmSME(OpPassManager &pm, | ||
const TestLowerToArmSMEOptions &options) { | ||
// Legalize vector operations so they can be converted to ArmSME. | ||
pm.addPass(arm_sme::createVectorLegalizationPass()); | ||
|
||
// Sprinkle some cleanups. | ||
pm.addPass(createCanonicalizerPass()); | ||
pm.addPass(createCSEPass()); | ||
|
||
// Passes that convert operations on vectors to ArmSME operations. | ||
|
||
// Convert Arith to ArmSME. | ||
pm.addPass(createArithToArmSMEConversionPass()); | ||
// Convert Vector to ArmSME. | ||
pm.addPass(createConvertVectorToArmSMEPass()); | ||
|
||
// Fuse outer products. | ||
if (options.fuseOuterProducts) | ||
pm.addPass(arm_sme::createOuterProductFusionPass()); | ||
|
||
// Convert operations on high-level vectors to loops. | ||
|
||
// Convert ArmSME to SCF. | ||
pm.addPass(createConvertArmSMEToSCFPass()); | ||
|
||
// Convert Vector to SCF (with full unroll enabled). | ||
pm.addPass(createConvertVectorToSCFPass( | ||
VectorTransferToSCFOptions().enableFullUnroll())); | ||
|
||
// Allocate tiles for ArmSME operations. | ||
// | ||
// Later passes may create further ArmSME ops that implement the | ||
// ArmSMETileOpInterface, but tiles are allocated for root operations, | ||
// all of which should now exist. | ||
pm.addPass(arm_sme::createTileAllocationPass()); | ||
|
||
// Enable streaming-mode and ZA. | ||
pm.addPass(arm_sme::createEnableArmStreamingPass( | ||
arm_sme::ArmStreamingMode::StreamingLocally, arm_sme::ArmZaMode::NewZA, | ||
/*onlyIfRequiredByOps=*/true)); | ||
|
||
// Convert ArmSME to LLVM. | ||
pm.addPass(createConvertArmSMEToLLVMPass()); | ||
|
||
// Sprinkle some cleanups. | ||
pm.addPass(createCanonicalizerPass()); | ||
pm.addPass(createCSEPass()); | ||
} | ||
} // namespace | ||
|
||
namespace mlir { | ||
namespace test { | ||
void registerTestLowerToArmSME() { | ||
PassPipelineRegistration<TestLowerToArmSMEOptions>( | ||
"test-lower-to-arm-sme", | ||
"An example pipeline to lower operations on vectors (arith, vector) to " | ||
"LLVM via ArmSME.", | ||
buildTestLowerToArmSME); | ||
} | ||
} // namespace test | ||
} // namespace mlir |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you leave a comment with the full pipeline in a form that can be passed
mlir-opt
? I'm pretty sure in the future we'll want to try different orders/passes, so I think that'd be helpful.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-dump-pass-pipeline
can be used for that? This is what it looks likeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's still more noisy than I'd like, I'd prefer the simple form (e.g.
-convert-vector-to-arm-sme -convert-arith-to-arm-sme ...
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the comment will be formatted by clang-format and not easy to copy/paste. It'll also have to be kept in sync with the pipeline.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern is this change makes it harder experiment with the passes for an ArmSME test. You either have to use
-dump-pass-pipeline
which is in a pretty inconvenient form, or edit the passes in the pipeline and recompile.I normally copy passes from a test (or from the LLVM lit logs) then play around with the order or adding/removing them, and this obscures that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy/pasting:
seems less convenient than
-dump-pass-pipeline
to me. There's a bit of noise mostly from canonicalization options but it's not the end of the world.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to land this and we can see how things go 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems hardly like a reason to encode this in the codebase IMO, this isn't really maintainable.
More importantly the textual pipeline is the only real correct form to describe a pipeline: the short one is only a convenience for running single passes but ambiguous when forming a more complex pipeline.
The option parsing for example can be very confusing when the same pass is attempted to be executed multiple time with different options.
If you would like to skip the default value for the options that aren't touched, this is likely doable: patch welcome for -dump-pass-pipeline here!