[Mlir-commits] [mlir] [MLIR][Linalg] Fix crash on duplicate dimensions in linalg.broadcast (PR #211203)

Andrzej WarzyƄski llvmlistbot at llvm.org
Thu Jul 23 07:09:42 PDT 2026


================
@@ -599,6 +599,36 @@ func.func @broadcast_memref(%input: memref<8x32xf32>,
 
 // -----
 
+func.func @broadcast_0d_tensor(%input: tensor<i32>,
+                               %init: tensor<32x2xi32>) -> tensor<32x2xi32> {
+  %bcast = linalg.broadcast
+      ins(%input:tensor<i32>)
+      outs(%init:tensor<32x2xi32>)
+      dimensions = [0, 1]
+  func.return %bcast : tensor<32x2xi32>
+}
+// CHECK-LABEL: func @broadcast_0d_tensor
+//      CHECK:    linalg.broadcast ins(%{{.*}} : tensor<i32>)
+// CHECK-SAME:    outs(%{{.*}} : tensor<32x2xi32>)
+// CHECK-SAME:    dimensions = [0, 1]
+
+// -----
+
+func.func @broadcast_0d_memref(%input: memref<f32>,
+                               %init: memref<8x16xf32>) {
+  linalg.broadcast
+      ins(%input:memref<f32>)
+      outs(%init:memref<8x16xf32>)
+      dimensions = [0, 1]
+  func.return
+}
+// CHECK-LABEL: func @broadcast_0d_memref
+//      CHECK:    linalg.broadcast ins(%{{.*}} : memref<f32>)
+// CHECK-SAME:    outs(%{{.*}} : memref<8x16xf32>)
+// CHECK-SAME:    dimensions = [0, 1]
+
----------------
banach-space wrote:

No need to test both tensor and memref. IIUC, the code path does not depend on the type of the shaped type (i.e. `tensor` vs `memref`).

https://github.com/llvm/llvm-project/pull/211203


More information about the Mlir-commits mailing list