Page MenuHomePhabricator

[mlir][CAPI] Add CAPI bindings for the sparse_tensor dialect.
ClosedPublic

Authored by stellaraccident on May 9 2021, 4:17 PM.

Details

Summary
  • Adds dialect registration, hand coded 'encoding' attribute and test.
  • An MLIR CAPI tablegen backend for attributes does not exist, and this is a relatively complicated case. I opted to hand code it in a canonical way for now, which will provide a reasonable blueprint for building out the tablegen version in the future.
  • Also added a (local) CMake function for declaring new CAPI tests, since it was getting repetitive/buggy.

Diff Detail

Event Timeline

stellaraccident created this revision.May 9 2021, 4:17 PM
stellaraccident requested review of this revision.May 9 2021, 4:17 PM

Also adding Alex for a look, since I think this is the first such case (dialect attribute) we have in tree.

ftynse accepted this revision.May 10 2021, 6:26 AM
ftynse added inline comments.
mlir/test/CAPI/sparse_tensor.c
26–30

Nit: can this use a raw literal or be wrapper in // clang-format off / // clang-format on to avoid awkward string reformatting?

This revision is now accepted and ready to land.May 10 2021, 6:26 AM
mlir/test/CAPI/sparse_tensor.c
26–30

It's C, so opted for the clang-format option and reflowed.

This revision was landed with ongoing or failed builds.May 10 2021, 9:55 AM
This revision was automatically updated to reflect the committed changes.

This broke the windows build bot, and I missed it. Rolling forward fix in: https://reviews.llvm.org/D102189