This is an archive of the discontinued LLVM Phabricator instance.

[mlir][nfc] Clarify the limitation on scalable vectors
ClosedPublic

Authored by awarzynski on Jul 2 2023, 8:59 AM.

Details

Summary

When converting/lowering to LLVM, MLIR does not support n-D scalable
vectors at the moment. This patch simply clarifies an assert that's
meant to catch such unsupported cases.

Note that we may want to relax this condition in the future.

Diff Detail

Event Timeline

awarzynski created this revision.Jul 2 2023, 8:59 AM
Herald added a project: Restricted Project. · View Herald Transcript
awarzynski requested review of this revision.Jul 2 2023, 8:59 AM
dcaballe accepted this revision.Jul 2 2023, 9:56 AM

Thanks!

This revision is now accepted and ready to land.Jul 2 2023, 9:56 AM
c-rhodes added inline comments.Jul 3 2023, 1:53 AM
mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
473–476

this type conversion runs before the pattern I'm adding in D152508 and this assert this will break that.

Matt added a subscriber: Matt.Jul 3 2023, 3:26 PM

I've done a bit of digging and summarized my findings here: https://github.com/openxla/iree/issues/14294.

Tl;Dr It's a bit tricky and convoluted :) Basically, we need to find a way to prevent LLVM type converter to treat scalable 2-d vectors _when_ targeting ArmSME. For SME such types are legal, though obfuscated. Importantly, LLVM does not support such types and we need to make sure that the "SME lowering" takes care of everything.

I am about to send an update so that you can see what solution I came up with.

Rebase on top of D154867, add a workaround for SME

c-rhodes added inline comments.Jul 13 2023, 3:13 AM
mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h
37 ↗(On Diff #539140)

How about flipping to disable since that's what the intention is here? And also add "type"

mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
460

I think it's worth highlighting here why this is, i.e. LLVM doesn't support arrays for scalable vectors.

474

nit: use getRank

mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
100 ↗(On Diff #539140)

nit: introduced

103–104 ↗(On Diff #539140)

nit: I would rephrase to mentioned the problem "The LLVM type converter converts vectors of rank > 1 to arrays of vectors, but LLVM doesn't support arrays of scalable vectors."

105–106 ↗(On Diff #539140)

how about this, and moving it above where converter is created?

@c-rhodes , thanks for the review! I am realising that rather than extending LLVMConverter, we could just create a custom type converter for SME that inherits from LLVMConverter and effectively disables conversions for VectorType: https://reviews.llvm.org/D155365. This way LLVMConverter remains intact, which IMHO is a cleaner way to approach this. I will updating this shortly.

Move the TypeConversion "fix" to https://reviews.llvm.org/D155365, address Cullen's comments

Why is there no SVESME.md on mlir-www with the current status and supported features?

Why is there no SVESME.md on mlir-www with the current status and supported features?

What do you mean by mlir-www? https://mlir.llvm.org/? I don't see any dedicated space there to track WIP projects. A lot of MLIR folks use Discourse to communicate updates and that's what we try to do on semi-regular basis, see:

IMHO, this patch is too small to deserve a dedicated post.

mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
473–476

Fixed by introducing a custom TypeConverter in: https://reviews.llvm.org/D155365

The git repository behind mlir.llvm.org:
https://github.com/llvm/mlir-www

c-rhodes accepted this revision.Jul 18 2023, 2:14 AM

LGTM cheers

This revision was landed with ongoing or failed builds.Jul 19 2023, 12:01 AM
This revision was automatically updated to reflect the committed changes.