-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
[mlir][ArmSME] Add enable_arm_streaming_ignore
attribute
#66911
Conversation
This attribute makes the `enable_arm_streaming` pass ignore a function (i.e. not add the enable streaming/za attributes). The main use case for this is to prevent helper functions within tests being made streaming functions.
@llvm/pr-subscribers-mlir-sme @llvm/pr-subscribers-mlir ChangesThis attribute makes the Full diff: https://github.com/llvm/llvm-project/pull/66911.diff 2 Files Affected:
diff --git a/mlir/lib/Dialect/ArmSME/Transforms/EnableArmStreaming.cpp b/mlir/lib/Dialect/ArmSME/Transforms/EnableArmStreaming.cpp
index 97c38b546349510..1d3a090e861013b 100644
--- a/mlir/lib/Dialect/ArmSME/Transforms/EnableArmStreaming.cpp
+++ b/mlir/lib/Dialect/ArmSME/Transforms/EnableArmStreaming.cpp
@@ -52,6 +52,8 @@ using namespace mlir::arm_sme;
static constexpr char kArmStreamingAttr[] = "arm_streaming";
static constexpr char kArmLocallyStreamingAttr[] = "arm_locally_streaming";
static constexpr char kArmZAAttr[] = "arm_za";
+static constexpr char kEnableArmStreamingIgnoreAttr[] =
+ "enable_arm_streaming_ignore";
namespace {
struct EnableArmStreamingPass
@@ -61,7 +63,9 @@ struct EnableArmStreamingPass
this->enableZA = enableZA;
}
void runOnOperation() override {
- std::string attr;
+ if (getOperation()->getAttr(kEnableArmStreamingIgnoreAttr))
+ return;
+ StringRef attr;
switch (mode) {
case ArmStreaming::Default:
attr = kArmStreamingAttr;
diff --git a/mlir/test/Dialect/ArmSME/enable-arm-streaming.mlir b/mlir/test/Dialect/ArmSME/enable-arm-streaming.mlir
index f5cc83192f9f6e1..e7bbe8c0047687d 100644
--- a/mlir/test/Dialect/ArmSME/enable-arm-streaming.mlir
+++ b/mlir/test/Dialect/ArmSME/enable-arm-streaming.mlir
@@ -9,3 +9,11 @@
// CHECK-ENABLE-ZA-LABEL: @arm_streaming
// CHECK-ENABLE-ZA-SAME: attributes {arm_streaming, arm_za}
func.func @arm_streaming() { return }
+
+// CHECK-LABEL: @not_arm_streaming
+// CHECK-SAME: attributes {enable_arm_streaming_ignore}
+// CHECK-LOCALLY-LABEL: @not_arm_streaming
+// CHECK-LOCALLY-SAME: attributes {enable_arm_streaming_ignore}
+// CHECK-ENABLE-ZA-LABEL: @not_arm_streaming
+// CHECK-ENABLE-ZA-SAME: attributes {enable_arm_streaming_ignore}
+func.func @not_arm_streaming() attributes {enable_arm_streaming_ignore} { return }
|
RE: #66691 (comment) I think |
Any chance to add a test that would demonstrate this? |
I'm not sure what that'd be other than the test here (which shows the streaming attributes are not added no matter what |
I think the test you've added is sufficient. |
// CHECK-LABEL: @not_arm_streaming | ||
// CHECK-SAME: attributes {enable_arm_streaming_ignore} | ||
// CHECK-LOCALLY-LABEL: @not_arm_streaming | ||
// CHECK-LOCALLY-SAME: attributes {enable_arm_streaming_ignore} | ||
// CHECK-ENABLE-ZA-LABEL: @not_arm_streaming | ||
// CHECK-ENABLE-ZA-SAME: attributes {enable_arm_streaming_ignore} |
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.
I was after something like this - I think that CHECK-NOT
is more descriptive in this context (i.e., we want to make sure that in presence of enable_arm_streaming_ignore
we won't see these streaming SVE attributes)
// CHECK-LABEL: @not_arm_streaming | |
// CHECK-SAME: attributes {enable_arm_streaming_ignore} | |
// CHECK-LOCALLY-LABEL: @not_arm_streaming | |
// CHECK-LOCALLY-SAME: attributes {enable_arm_streaming_ignore} | |
// CHECK-ENABLE-ZA-LABEL: @not_arm_streaming | |
// CHECK-ENABLE-ZA-SAME: attributes {enable_arm_streaming_ignore} | |
// CHECK-LABEL: @not_arm_streaming | |
// CHECK-NOT: arm_streaming | |
// CHECK-LOCALLY-LABEL: @not_arm_streaming | |
// CHECK-LOCALLY-NOT: arm_locally_streaming | |
// CHECK-ENABLE-ZA-LABEL: @not_arm_streaming | |
// CHECK-ENABLE-ZA-NOT: arm_za |
I could've explained better first time round, apologies :)
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.
I've added CHECK-NOTs between the matches now (still with the CHECK-SAMEs too). I'm a little wary of just using CHECK-NOT alone (since if it's checking the wrong line it can falsely pass too).
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 way this is written now, I think that you could have the following output and the test would pass (which is not what we want):
func.func @not_arm_streaming() attributes {enable_arm_streaming_ignore, arm_locally_streaming} { return }
So you'd need this to be 100% sure:
// CHECK-LABEL: @not_arm_streaming
// CHECK-NOT: arm_streaming
// CHECK-LOCALLY-LABEL: @not_arm_streaming
// CHECK-NOT: arm_streaming
This should be sufficient though:
// CHECK-LABEL: @not_arm_streaming
// CHECK-NOT: arm_streaming
This way, you match the label (which is unique) and the make sure that there's no arm_streaming
attribute starting from the label all the way to EOF.
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.
You have to do:
// CHECK-LABEL: @not_arm_streaming
// CHECK-NOT: arm_streaming
// CHECK-LOCALLY-LABEL: @not_arm_streaming
// CHECK-NOT: arm_streaming
Because arm_streaming
is a substring of enable_arm_streaming_ignore
. There's probably some syntax for whole word matches, but I think that just using // CHECK-SAME:
is a little simpler and easier to understand here.
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.
There's probably some syntax for whole word matches
There's -match-full-lines
This reverts commit 1889687.
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.
LGTM, ta!
// CHECK-LABEL: @not_arm_streaming | ||
// CHECK-SAME: attributes {enable_arm_streaming_ignore} | ||
// CHECK-LOCALLY-LABEL: @not_arm_streaming | ||
// CHECK-LOCALLY-SAME: attributes {enable_arm_streaming_ignore} | ||
// CHECK-ENABLE-ZA-LABEL: @not_arm_streaming | ||
// CHECK-ENABLE-ZA-SAME: attributes {enable_arm_streaming_ignore} |
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.
There's probably some syntax for whole word matches
There's -match-full-lines
…6691) This adds a custom lowering for SME that loops over each row of the tile, extracting it via an SME MOVA, then printing with a normal 1D vector.print. This makes writing SME integration tests easier and less verbose. Depends on: llvm#66910, llvm#66911
This attribute makes the
enable_arm_streaming
pass ignore a function (i.e. not add the enable streaming/za attributes). The main use case for this is to prevent helper functions within tests being made streaming functions.