This is an archive of the discontinued LLVM Phabricator instance.

[mlir][vector] Support unrolling for transfer ops using tensors
ClosedPublic

Authored by ThomasRaoux on Dec 29 2020, 10:05 AM.

Diff Detail

Event Timeline

ThomasRaoux created this revision.Dec 29 2020, 10:05 AM
ThomasRaoux requested review of this revision.Dec 29 2020, 10:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 29 2020, 10:05 AM
nicolasvasilache accepted this revision.Jan 6 2021, 7:41 AM

Looks good but let's please simplify the Value source part.

mlir/lib/Dialect/Vector/VectorTransforms.cpp
655

I find it confusing to use source to represent both a memref and a "maybe tensor". Could we instead just do this?

Value resultTensor;
auto createSlice = [&](unsigned index, ArrayRef<Value> sliceIndices) {
  auto element = builder.create<vector::TupleGetOp>(
      loc, tupleType.getType(index), tuple, builder.getI64IntegerAttr(index));
  Operation *write = builder.create<vector::TransferWriteOp>(
      loc, element.getResult(), writeOp.source(), sliceIndices,
      writeOp.permutation_map(),
      writeOp.masked() ? *writeOp.masked() : ArrayAttr());
  if (!write->getResults().empty())
    resultTensor = write->getResult(0);
};
generateTransferOpSlices(shapedElementType, sourceVectorType, tupleType,
                         targetShape, strides, indices, builder, createSlice);
if (resultTensor)
  result.push_back(resultTensor);
776

same here

This revision is now accepted and ready to land.Jan 6 2021, 7:41 AM

Address review comment

ThomasRaoux marked an inline comment as done.Jan 6 2021, 10:38 AM
ThomasRaoux added inline comments.
mlir/lib/Dialect/Vector/VectorTransforms.cpp
655

Makes sense. The main reason I had done it that way is because for the case with tensor I need to use the previous one when creating a new transfer_write. To solve that I use resultTensor ? resultTensor : writeOp.source() now, hopefully this makes the code clearer.