This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Support multi-dimensional vectors in MathToLibm conversion.
ClosedPublic

Authored by akuegel on Nov 16 2021, 12:53 AM.

Diff Detail

Event Timeline

akuegel created this revision.Nov 16 2021, 12:53 AM
akuegel requested review of this revision.Nov 16 2021, 12:53 AM
akuegel updated this revision to Diff 387528.Nov 16 2021, 1:08 AM

Also add test with multi-dimensional vector

ftynse accepted this revision.Nov 16 2021, 1:24 AM
ftynse added inline comments.
mlir/lib/Conversion/MathToLibm/MathToLibm.cpp
62

You can just call vecType.getNumElements().

63

Nit: LLVM uses unsigned in loops.

68–73
This revision is now accepted and ready to land.Nov 16 2021, 1:24 AM
akuegel updated this revision to Diff 387532.Nov 16 2021, 1:47 AM
akuegel marked 2 inline comments as done.

Use getNumElements() call.

Thanks for the review :)

mlir/lib/Conversion/MathToLibm/MathToLibm.cpp
68–73

This needs computed strides, I cannot just pass it the shape. I am not sure whether it is worth it to compute the strides first, just that I can call this function.

ftynse added inline comments.Nov 16 2021, 1:52 AM
mlir/lib/Conversion/MathToLibm/MathToLibm.cpp
68–73

There's also computeStrides a couple of lines above. :) So you can call two functions and be done with it instead of doing somewhat non-trivial math.

akuegel updated this revision to Diff 387534.Nov 16 2021, 1:58 AM

Use computeStrides and delinearize instead of custom delinearization.

akuegel added inline comments.Nov 16 2021, 2:00 AM
mlir/lib/Conversion/MathToLibm/MathToLibm.cpp
68–73

It is not the perfect utility function for my use case, but ok, I can understand that it is easier to read to just have two function calls than the custom delinearization. Done.