[Mlir-commits] [mlir] [MLIR][Linalg] Fix crash on duplicate dimensions in linalg.broadcast (PR #211203)
Hugo Trachino
llvmlistbot at llvm.org
Wed Jul 22 02:21:38 PDT 2026
================
@@ -1196,6 +1196,43 @@ func.func @broadcast_size_1_extension_not_supported(
// -----
+func.func @broadcast_duplicate_dims(
+ %input: tensor<i32>, %init: tensor<32x2xi32>) -> tensor<32x2xi32> {
+ // expected-error @+1 {{'linalg.broadcast' op dimensions should not contain duplicates}}
+ %bcast = linalg.broadcast
+ ins(%input:tensor<i32>)
+ outs(%init:tensor<32x2xi32>)
+ dimensions = [0, 0]
+ func.return %bcast : tensor<32x2xi32>
+}
+
+// -----
+
+func.func @broadcast_duplicate_dims_rank1(
+ %input: tensor<4xf32>, %init: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {
+ // expected-error @+1 {{'linalg.broadcast' op dimensions should not contain duplicates}}
+ %bcast = linalg.broadcast
+ ins(%input:tensor<4xf32>)
+ outs(%init:tensor<4x8x16xf32>)
+ dimensions = [1, 1]
+ func.return %bcast : tensor<4x8x16xf32>
+}
+
+// -----
+
+func.func @broadcast_duplicate_dims_rank2(
+ %input: tensor<4x8xf32>, %init: tensor<4x8x16x32xf32>)
+ -> tensor<4x8x16x32xf32> {
+ // expected-error @+1 {{'linalg.broadcast' op dimensions should not contain duplicates}}
+ %bcast = linalg.broadcast
+ ins(%input:tensor<4x8xf32>)
+ outs(%init:tensor<4x8x16x32xf32>)
+ dimensions = [3, 3]
+ func.return %bcast : tensor<4x8x16x32xf32>
+}
+
+// -----
+
----------------
nujaa wrote:
All those tests fall in the same condition, I don't think it is relevant to add all 3 of them.
https://github.com/llvm/llvm-project/pull/211203
More information about the Mlir-commits
mailing list