Skip to content
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

Merged
merged 6 commits into from
Jun 15, 2023

Conversation

prithayan
Copy link
Contributor

@prithayan prithayan commented Jun 14, 2023

Add the API to get the field names and iterate over an object.

@mikeurbach mikeurbach marked this pull request as ready for review June 15, 2023 05:40
@prithayan prithayan merged commit 1ecd327 into main Jun 15, 2023
5 checks passed
@prithayan prithayan deleted the dev/pbarua/om_get_object_fields branch June 15, 2023 15:48
@@ -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 =
Copy link
Contributor

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>())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for StringAttr.

Copy link
Contributor Author

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.

Copy link
Contributor

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

@teqdruid
Copy link
Contributor

teqdruid commented Jun 21, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants