This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Expose operation attributes to Python bindings
ClosedPublic

Authored by ftynse on Nov 6 2020, 2:28 AM.

Details

Summary

Operations in a MLIR have a dictionary of attributes attached. Expose
those to Python bindings through a pseudo-container that can be indexed
either by attribute name, producing a PyAttribute, or by a contiguous
index for enumeration purposes, producing a PyNamedAttribute.

Depends On D90917

Diff Detail

Event Timeline

ftynse created this revision.Nov 6 2020, 2:28 AM
ftynse requested review of this revision.Nov 6 2020, 2:28 AM
stellaraccident accepted this revision.Nov 6 2020, 7:52 AM

Suspect there is a bug on not going keys. Please fix and add tests.

mlir/lib/Bindings/Python/IRModules.cpp
1294

What happens if the attribute is not found?

mlir/test/Bindings/Python/ir_operation.py
281

Add test for exceptions when out of bounds int and string indexing.

This revision is now accepted and ready to land.Nov 6 2020, 7:52 AM
ftynse updated this revision to Diff 303848.Nov 9 2020, 5:59 AM
ftynse marked 2 inline comments as done.

Address review

mlir/lib/Bindings/Python/IRModules.cpp
1294

Let's throw a KeyError.

This revision was landed with ongoing or failed builds.Nov 9 2020, 6:00 AM
This revision was automatically updated to reflect the committed changes.