Skip to content

Commit c8763f0

Browse files
authored
[mlir][tensor] Fix consumer fusion for tensor.pack without explicit outer_dims_perm attribute (#106687)
1 parent f1615e3 commit c8763f0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ struct PackOpTiling
286286
SmallVector<OpFoldResult> outerDimOffsets, outerDimSizes;
287287
DenseMap<int64_t, OpFoldResult> dimAndTileMapping =
288288
packOp.getDimAndTileMapping();
289-
for (auto dim : packOp.getOuterDimsPerm()) {
289+
for (auto dim : llvm::seq<int64_t>(packOp.getSourceRank())) {
290290
if (dimAndTileMapping.count(dim)) {
291291
FailureOr<int64_t> cstSize =
292292
ValueBoundsConstraintSet::computeConstantBound(
@@ -327,7 +327,7 @@ struct PackOpTiling
327327
outerDimSizes.push_back(sizes[dim]);
328328
}
329329
}
330-
330+
applyPermToRange(outerDimOffsets, outerDimSizes, packOp.getOuterDimsPerm());
331331
resultOffsets = outerDimOffsets;
332332
resultSizes = outerDimSizes;
333333
return success();

mlir/test/Interfaces/TilingInterface/tile-and-fuse-consumer.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ module {
337337
}
338338
}
339339
%output = tensor.empty() : tensor<4x32x16xf32>
340-
%pack = tensor.pack %1 outer_dims_perm = [0, 1] inner_dims_pos = [0] inner_tiles = [16] into %output : tensor<64x32xf32> -> tensor<4x32x16xf32>
340+
%pack = tensor.pack %1 inner_dims_pos = [0] inner_tiles = [16] into %output : tensor<64x32xf32> -> tensor<4x32x16xf32>
341341
return %pack : tensor<4x32x16xf32>
342342
}
343343
}
@@ -366,7 +366,7 @@ module attributes {transform.with_named_sequence} {
366366
// CHECK: %[[PACK_RESULT_OFFSET:.*]] = affine.apply #[[PACK_RESULT_MAP]](%[[IV1]])
367367
// CHECK: %[[TILED_PACK_DEST:.*]] = tensor.extract_slice %[[PACK_OUT_ARG]][%[[PACK_RESULT_OFFSET]], %[[IV2]], 0] [2, 32, 16] [1, 1, 1]
368368
// CHECK: %[[TILED_PACK_OUT:.*]] = tensor.pack %[[GENERIC_OUT]]
369-
// CHECK-SAME: outer_dims_perm = [0, 1] inner_dims_pos = [0] inner_tiles = [16]
369+
// CHECK-SAME: inner_dims_pos = [0] inner_tiles = [16]
370370
// CHECK-SAME: into %[[TILED_PACK_DEST]]
371371
// CHECK: scf.forall.in_parallel {
372372
// CHECK: tensor.parallel_insert_slice %[[TILED_PACK_OUT]] into %[[PACK_OUT_ARG]][%[[PACK_RESULT_OFFSET]], %[[IV2]], 0] [2, 32, 16] [1, 1, 1]

0 commit comments

Comments
 (0)