This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Python] Fix conversion of non-zero offset memrefs to np.arrays
ClosedPublic

Authored by ubfx on Aug 22 2023, 1:09 AM.

Details

Summary

Memref descriptors contain an offset field that denotes the start of
the content of the memref relative to the alignedPtr. This offset is
not considered when converting a memref descriptor to a np.array in the
Python runtime library, essentially treating all memrefs as if they had
an offset of zero. This patch introduces the necessary pointer arithmetic
to find the actual beginning of the memref contents to the memref->numpy
conversion functions.

There is an ongoing discussion about whether the offset field is needed
at all in the memref descriptor.
Until that is decided, the Python runtime and CRunnerUtils should
still correctly implement the offset handling.

Related: https://reviews.llvm.org/D157008

Diff Detail

Event Timeline

ubfx created this revision.Aug 22 2023, 1:09 AM
Herald added a project: Restricted Project. · View Herald Transcript
ubfx requested review of this revision.Aug 22 2023, 1:09 AM
ftynse accepted this revision.Sep 4 2023, 6:05 AM
This revision is now accepted and ready to land.Sep 4 2023, 6:05 AM
ubfx added a comment.Sep 4 2023, 7:41 AM

Thank you for the review @ftynse, would you mind landing this revision for me?