This is an archive of the discontinued LLVM Phabricator instance.

Add Python bindings for the builtin dialect
ClosedPublic

Authored by mehdi_amini on Jan 19 2021, 9:54 PM.

Details

Summary

This includes some minor customization for FuncOp and ModuleOp.

Diff Detail

Event Timeline

mehdi_amini created this revision.Jan 19 2021, 9:54 PM
mehdi_amini requested review of this revision.Jan 19 2021, 9:54 PM
rriddle added inline comments.Jan 19 2021, 9:56 PM
mlir/lib/Bindings/Python/BuiltinOps.td
2

Linalg?

stellaraccident accepted this revision.Jan 19 2021, 10:09 PM

Thanks. Lg modulo comments

mlir/lib/Bindings/Python/mlir/dialects/_builtin.py
30

Prefer the ternary form:

sym_visibility = ... if visibility is not None else None

35

Doesn't this return the region on the c++ side?

38

See if it works with this removed. It should bind by class name by default.

This revision is now accepted and ready to land.Jan 19 2021, 10:09 PM
mlir/lib/Bindings/Python/mlir/dialects/_builtin.py
35

Also, functions without a body are legal

ftynse accepted this revision.Jan 20 2021, 12:28 AM
ftynse added inline comments.
mlir/test/Bindings/Python/dialects/builtin.py
25

Maybe also define FuncOp.add_body ?

mehdi_amini marked 5 inline comments as done.

Address comment, add more helpers/properties on FuncOp, extend the test

mlir/lib/Bindings/Python/mlir/dialects/_builtin.py
35

Good point! PTAL

38

Indeed, I had to fix a bug in the class_decorator magic but now it works :)

mlir/test/Bindings/Python/dialects/builtin.py
25

add_entry_block to align with C++

Minor update to add_entry_block + test fix

Add a body_builder callback

Landing now, feel free to add more comments as needed!

This revision was automatically updated to reflect the committed changes.