Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XeTile][Canonicalization] Bug fix in VectorBroadcast Canonicalization. #956

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions lib/Dialect/XeTile/Transforms/Canonicalization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,11 @@ struct VectorBroadcastToXetileBroadcastOpPattern
newOp->setDiscardableAttrs(discardableAttrs);
return mlir::success();
}
// If ranks are same, inner dimension is stretched in vector.broadcast. So
// broadcast dimension is 1 for this case.
// If ranks are same, decide the broadcast dimension based on the source
// vector shape.
auto broadcastDim = (sourceShape[0] == 1) ? 0 : 1;
auto newOp = rewriter.replaceOpWithNewOp<imex::xetile::BroadcastOp>(
op, resultTy, op.getSource(), llvm::ArrayRef<int64_t>({1}));
op, resultTy, op.getSource(), llvm::ArrayRef<int64_t>({broadcastDim}));
newOp->setDiscardableAttrs(discardableAttrs);
return mlir::success();
}
Expand Down
13 changes: 13 additions & 0 deletions test/Dialect/XeTile/Transforms/canonicalization.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,19 @@ gpu.module @test_module {
// CHECK: %[[T1:.*]] = xetile.broadcast %[[T0]] [0] : vector<1x16xf32> -> vector<8x16xf32>
// CHECK: gpu.return %[[T1]] : vector<8x16xf32>

// -----
gpu.module @test_module {
gpu.func @test_broadcast_3(%arg0 : vector<1x16xf32>) -> vector<8x16xf32> {
%0 = vector.broadcast %arg0 : vector<1x16xf32> to vector<8x16xf32>
gpu.return %0 : vector<8x16xf32>
}
}

// CHECK-LABEL: @test_broadcast_3
// CHECK-SAME: %[[ARG0:[a-zA-Z0-9]+]]: vector<1x16xf32>) -> vector<8x16xf32>
// CHECK: %[[T0:.*]] = xetile.broadcast %[[ARG0]] [0] : vector<1x16xf32> -> vector<8x16xf32>
// CHECK: gpu.return %[[T0]] : vector<8x16xf32>

// -----
gpu.module @test_module {
gpu.func @test_multireduction_1(%arg0 : vector<64x256xf32>, %arg1 : vector<256xf32>) -> vector<256xf32> {
Expand Down
Loading