-
Notifications
You must be signed in to change notification settings - Fork 277
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
[OM] Get the field names from an Object #5402
Conversation
@@ -55,6 +56,18 @@ struct Object { | |||
return omEvaluatorObjectValueGetPrimitive(result); | |||
} | |||
|
|||
// Get a list with the names of all the fields in the Object. | |||
std::vector<std::string> getFieldNames() { | |||
ArrayAttr fieldNames = |
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 cannot use ArrayAttr
in pybind11 code. You must use the CAPI for interacting with MLIR objects/classes... 'cause linking issues.
cast<ArrayAttr>(unwrap(omEvaluatorObjectGetFieldNames(object))); | ||
|
||
std::vector<std::string> slots; | ||
for (auto fieldName : fieldNames.getAsRange<StringAttr>()) |
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.
Same for StringAttr
.
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.
Oh sorry, didn't realize that, will create a new PR to fix it.
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.
@prithayan no worries, it was my bad, and fixed in 80531eb
Mike already fixed it. Thanks!
…On Tue, Jun 20, 2023, 6:09 PM Prithayan Barua ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In lib/Bindings/Python/OMModule.cpp
<#5402 (comment)>:
> @@ -55,6 +56,18 @@ struct Object {
return omEvaluatorObjectValueGetPrimitive(result);
}
+ // Get a list with the names of all the fields in the Object.
+ std::vector<std::string> getFieldNames() {
+ ArrayAttr fieldNames =
+ cast<ArrayAttr>(unwrap(omEvaluatorObjectGetFieldNames(object)));
+
+ std::vector<std::string> slots;
+ for (auto fieldName : fieldNames.getAsRange<StringAttr>())
Oh sorry, didn't realize that, will create a new PR to fix it.
—
Reply to this email directly, view it on GitHub
<#5402 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALNXYCAMEKWFGTNV3VUHPLXMJCV3ANCNFSM6AAAAAAZGW3X34>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Add the API to get the field names and iterate over an object.