Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,27 +144,17 @@ static LinalgOp fuse(OpBuilder &b, LinalgOp producer,
b, loc, producer, getTiledOperands(producer), ivs, tileSizes, sizeBounds,
/**omitPartialTileCheck=*/false));

// Iterate over the results in order.
// Extract the subtensor type from the linearized range.
// Since we do not enforce any canonicalizations on the fly, this is always
// fully dynamic at construction time.
// Take result types from the tiled init operands.
MutableOperandRange producerDpsInits = producer.getDpsInitsMutable();
SmallVector<Type, 4> resultTypes;
resultTypes.reserve(producer->getNumResults());
for (Value operand : producer.getDpsInits()) {
auto tensorType = dyn_cast<RankedTensorType>(operand.getType());
if (!tensorType)
continue;
unsigned rank = tensorType.getRank();
SmallVector<int64_t, 4> staticOffsetsVector(
rank, ShapedType::kDynamic);
SmallVector<int64_t, 4> staticSizesVector(rank, ShapedType::kDynamic);
SmallVector<int64_t, 4> staticStridesVector(
rank, ShapedType::kDynamic);
resultTypes.push_back(tensor::ExtractSliceOp::inferResultType(
tensorType, staticOffsetsVector, staticSizesVector,
staticStridesVector));
int64_t firstInitOperandIdx =
static_cast<OperandRange>(producerDpsInits).getBeginOperandIndex();
for (int64_t i = 0, e = producer->getNumResults(); i < e; ++i) {
resultTypes.push_back(clonedShapes[firstInitOperandIdx + i].getType());
}

// Clone the producer with new operands and result types.
LinalgOp clonedOp = clone(b, producer, resultTypes, clonedShapes);

// Shift all IndexOp results by the tile offset.
Expand Down