Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
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); | |
| 777 | same here | |
| 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. | |
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);