-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[mlir][dlti] Query by strings #126716
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
[mlir][dlti] Query by strings #126716
Conversation
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
Adds DLTI utility to query using strings directly as keys.
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-dlti Author: Adam Siemieniuk (adam-smnk) ChangesAdds DLTI utility to query using strings directly as keys. Full diff: https://github.com/llvm/llvm-project/pull/126716.diff 2 Files Affected:
diff --git a/mlir/include/mlir/Dialect/DLTI/DLTI.h b/mlir/include/mlir/Dialect/DLTI/DLTI.h
index f268fea340a6fb1..4004c2f64e6da03 100644
--- a/mlir/include/mlir/Dialect/DLTI/DLTI.h
+++ b/mlir/include/mlir/Dialect/DLTI/DLTI.h
@@ -28,6 +28,12 @@ namespace dlti {
/// query interface-implementing attrs, starting from attr obtained from `op`.
FailureOr<Attribute> query(Operation *op, ArrayRef<DataLayoutEntryKey> keys,
bool emitError = false);
+
+/// Perform a DLTI-query at `op` using string `keys` as DLTI entry keys,
+/// recursively querying on query interface-implementing attrs, starting from
+/// attr obtained from `op`.
+FailureOr<Attribute> query(Operation *op, ArrayRef<StringRef> keys,
+ bool emitError = false);
} // namespace dlti
} // namespace mlir
diff --git a/mlir/lib/Dialect/DLTI/DLTI.cpp b/mlir/lib/Dialect/DLTI/DLTI.cpp
index 2510e774f2b2aa1..86bee1933268bcf 100644
--- a/mlir/lib/Dialect/DLTI/DLTI.cpp
+++ b/mlir/lib/Dialect/DLTI/DLTI.cpp
@@ -508,6 +508,9 @@ getClosestQueryable(Operation *op) {
FailureOr<Attribute>
dlti::query(Operation *op, ArrayRef<DataLayoutEntryKey> keys, bool emitError) {
+ if (!op)
+ return failure();
+
if (keys.empty()) {
if (emitError) {
auto diag = op->emitError() << "target op of failed DLTI query";
@@ -562,6 +565,19 @@ dlti::query(Operation *op, ArrayRef<DataLayoutEntryKey> keys, bool emitError) {
return currentAttr;
}
+FailureOr<Attribute> dlti::query(Operation *op, ArrayRef<StringRef> keys,
+ bool emitError) {
+ if (!op)
+ return failure();
+
+ MLIRContext *ctx = op->getContext();
+ SmallVector<DataLayoutEntryKey> entryKeys;
+ for (StringRef key : keys)
+ entryKeys.push_back(StringAttr::get(ctx, key));
+
+ return dlti::query(op, entryKeys, emitError);
+}
+
constexpr const StringLiteral mlir::DLTIDialect::kDataLayoutAttrName;
constexpr const StringLiteral mlir::DLTIDialect::kDataLayoutEndiannessKey;
constexpr const StringLiteral mlir::DLTIDialect::kDataLayoutEndiannessBig;
|
rolfmorel
reviewed
Feb 11, 2025
rolfmorel
reviewed
Feb 11, 2025
rolfmorel
approved these changes
Feb 11, 2025
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.
Excepting the two nits up above, LGTM.
joker-eph
reviewed
Feb 11, 2025
flovent
pushed a commit
to flovent/llvm-project
that referenced
this pull request
Feb 13, 2025
Adds DLTI utility to query using strings directly as keys.
joaosaffran
pushed a commit
to joaosaffran/llvm-project
that referenced
this pull request
Feb 14, 2025
Adds DLTI utility to query using strings directly as keys.
adam-smnk
added a commit
to adam-smnk/llvm-project
that referenced
this pull request
Feb 19, 2025
Fixes upfront space allocation after llvm#126716
adam-smnk
added a commit
that referenced
this pull request
Feb 19, 2025
Fixes upfront space allocation after #126716
sivan-shani
pushed a commit
to sivan-shani/llvm-project
that referenced
this pull request
Feb 24, 2025
Adds DLTI utility to query using strings directly as keys.
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.
Adds DLTI utility to query using strings directly as keys.