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

[FIX] Python Bindings DenseIntElementsAttr as Vector<? x Index> type #126

Conversation

cmcgirr-amd
Copy link

We noticed when reading the attribute:

denseattr = dense<[1, 2, 3, 4]> : vector<4xindex>

the python binding code would fail:

DenseIntElementsAttr(op.attributes["denseattr "])

When converting the attribute to the dense representation. In C++ we can represent the DenseIntElementsAttr as a vector type with index elements. This PR attempts to resolve this issue for python bindings as well.

@mgehre-amd
Copy link
Collaborator

Can you please change the commit title to something like [mlir][python] allow DenseIntElementsAttr for index type to prepare for upstreaming?

This comment was marked as resolved.

@cmcgirr-amd cmcgirr-amd force-pushed the christopher.FXML-4134_python_bindings_index_type branch 3 times, most recently from 4b1f345 to f8ef350 Compare March 8, 2024 17:29
Model the IndexType as size_t when converting to a python integer. This should
follow the definition of the IndexType as system-dependent.

This solves the following issue when for example an attribute is defined
as:

```
denseattr = dense<[1, 2, 3, 4]> : vector<4xindex>
```

which is a valid DenseElementsAttr. The change will fix an access issue
when reading the attribute in python. E.g.

```
DenseIntElementsAttr(op.attributes["denseattr"])
```

Co-authored-by: Tiago Trevisan Jost <tiago.trevisanjost@amd.com>
Co-authored-by: Matthias Gehre <matthias.gehre@amd.com>
@cmcgirr-amd cmcgirr-amd force-pushed the christopher.FXML-4134_python_bindings_index_type branch from f8ef350 to 37e4ced Compare March 8, 2024 17:32
@cmcgirr-amd cmcgirr-amd merged commit eb28bbc into feature/fused-ops Mar 8, 2024
4 checks passed
@cmcgirr-amd cmcgirr-amd deleted the christopher.FXML-4134_python_bindings_index_type branch March 8, 2024 17:46
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.

3 participants