This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Support 0-D vectors in `VectorPrintOpConversion`
ClosedPublic

Authored by michalt on Nov 24 2021, 10:50 AM.

Diff Detail

Event Timeline

michalt created this revision.Nov 24 2021, 10:50 AM
michalt requested review of this revision.Nov 24 2021, 10:50 AM
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
60

rank <= 1 plz

1015

I think the API needs to change here.
emitRanks(...VectorType) -> emitRanks(...Type)

and then inside the function:

VectorType vectorType = type.dyn_cast<VectorType>() ... 
if (!vectorType) {
  assert(rank == 0 && "scalar case expects rank == 0");
 ...
}
1056

The ternary conditions already look too tricky here I find
I'd early-exit on:

if (rank <= 1) {
      auto reducedType = vector.getElementType();
      auto llvmType = typeConverter->convertType(reducedType);
      Value nestedVal = extractOne(rewriter, *getTypeConverter(), loc, value,
                                   llvmType, rank, d);
     return emitRanks(rewriter, op, nestedVal, reducedType, printer, /*lowerRank=*/0,
}

and then you have an opportunity to make the ternaries below simpler.

michalt updated this revision to Diff 389788.Nov 25 2021, 7:34 AM
michalt marked 3 inline comments as done.

Address review comments

This revision is now accepted and ready to land.Nov 25 2021, 12:09 PM