This is an archive of the discontinued LLVM Phabricator instance.

[mlir][python][ctypes] fix ctype python binding complication for complex
ClosedPublic

Authored by aartbik on May 25 2022, 1:46 PM.

Details

Summary

There is no direct ctypes for MLIR's complex (and thus np.complex128
and np.complex64) yet, causing the mlir python binding methods for
memrefs to crash. This revision fixes this by passing complex arrays
as tuples of floats, correcting at the boundaries for the proper view.

NOTE: some of these changes (4 -> 2) were forced by the new "linting"

Diff Detail

Event Timeline

aartbik created this revision.May 25 2022, 1:46 PM
aartbik requested review of this revision.May 25 2022, 1:46 PM
aartbik edited the summary of this revision. (Show Details)May 25 2022, 1:48 PM
aartbik edited the summary of this revision. (Show Details)May 25 2022, 2:37 PM

I think Mehdi wrote some of this originally. I'll review as well but need to study it...

Can you add tests for this?

aartbik updated this revision to Diff 432400.May 26 2022, 3:37 PM

added tests for c128 and c64, ranked and unranked, memrefs

added tests for c128 and c64, ranked and unranked, memrefs

Always good to have tests!

(note that this was fully tested in another context obviously, but this should indeed by in-tree too)

aartbik updated this revision to Diff 432408.May 26 2022, 4:22 PM

rebased with main

mehdi_amini accepted this revision.Jun 1 2022, 9:35 AM
This revision is now accepted and ready to land.Jun 1 2022, 9:35 AM