[Mlir-commits] [mlir] [ml_program] fix bufferizesToMemoryRead for ml_program.global_store (PR #177387)
Matthias Springer
llvmlistbot at llvm.org
Thu Jan 22 08:13:47 PST 2026
================
@@ -50,3 +50,34 @@ func.func @raw_hazard() -> i64 {
return %extracted : i64
}
+// -----
+
+// CHECK-LABEL: memref.global "private" @state_tensor
+ml_program.global private mutable @"state_tensor"(dense<0.0> : tensor<4x75xf32>) : tensor<4x75xf32>
+
+// CHECK-LABEL: func.func @global_load_store_tensor
+func.func @global_load_store_tensor() -> tensor<4x75xf32> {
+ // CHECK-DAG: %[[C0:.*]] = arith.constant 0
+ // CHECK-DAG: %[[CST:.*]] = arith.constant 1.000000e+00
+ // CHECK-DAG: %[[GLOB:.*]] = memref.get_global @state_tensor
+ // CHECK: %[[VAL:.*]] = memref.load %[[GLOB]][%[[C0]], %[[C0]]]
+ // CHECK: %[[ADD:.*]] = arith.addf %[[VAL]], %[[CST]]
+ // CHECK: %[[ALLOC1:.*]] = memref.alloc() {alignment = 64 : i64}
+ // CHECK: memref.copy %[[GLOB]], %[[ALLOC1]]
+ // CHECK: memref.store %[[ADD]], %[[ALLOC1]][%[[C0]], %[[C0]]]
+ // CHECK: %[[TENSOR:.*]] = bufferization.to_tensor %[[ALLOC1]]
+ // CHECK: %[[ALLOC2:.*]] = memref.alloc() {alignment = 64 : i64}
----------------
matthias-springer wrote:
Your fix is correct, but I'm a bit surprised to see so many allocs here. Do you know where they are coming from?
https://github.com/llvm/llvm-project/pull/177387
More information about the Mlir-commits
mailing list