[llvm] [mlir] [MLIR] Add initial convert-memref-to-emitc pass (PR #85389)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 6 04:03:11 PST 2025


pyl3000 wrote:

Excuse me, I got the following error, how to solve it?
![image](https://github.com/user-attachments/assets/62272e59-6b05-4d40-8ff5-c8df33a8d44f)

` mlir-opt --lower-affine --convert-scf-to-cf --memref-expand --convert-scf-to-emitc --convert-arith-to-emitc --convert-func-to-emitc --one-shot-bufferize=allow-return-allocs-from-loops=true --convert-memref-to-emitc --reconcile-unrealized-casts --optimize-allocation-liveness --mlir-print-ir-after-failure .\matmul-affine.mlir -o matmul-emitc.mlir`

![image](https://github.com/user-attachments/assets/f16f3594-9405-4f7d-b5e3-c0e74a3a1a67)

The input file as follow:

```
module {
  func.func @main() {
    %cst = arith.constant 0.000000e+00 : f64
    %cst_0 = arith.constant 6.000000e+00 : f64
    %cst_1 = arith.constant 5.000000e+00 : f64
    %cst_2 = arith.constant 4.000000e+00 : f64
    %cst_3 = arith.constant 3.000000e+00 : f64
    %cst_4 = arith.constant 2.000000e+00 : f64
    %cst_5 = arith.constant 1.000000e+00 : f64
    %alloc = memref.alloc() : memref<2x2xf64>
    %alloc_6 = memref.alloc() : memref<2x3xf64>
    affine.store %cst_5, %alloc_6[0, 0] : memref<2x3xf64>
    affine.store %cst_4, %alloc_6[0, 1] : memref<2x3xf64>
    affine.store %cst_3, %alloc_6[0, 2] : memref<2x3xf64>
    affine.store %cst_2, %alloc_6[1, 0] : memref<2x3xf64>
    affine.store %cst_1, %alloc_6[1, 1] : memref<2x3xf64>
    affine.store %cst_0, %alloc_6[1, 2] : memref<2x3xf64>
    affine.for %arg0 = 0 to 2 {
      affine.for %arg1 = 0 to 2 {
        affine.store %cst, %alloc[%arg1, %arg0] : memref<2x2xf64>
        affine.for %arg2 = 0 to 3 {
          %0 = affine.load %alloc_6[%arg0, %arg2] : memref<2x3xf64>
          %1 = affine.load %alloc_6[%arg1, %arg2] : memref<2x3xf64>
          %2 = affine.load %alloc[%arg1, %arg0] : memref<2x2xf64>
          %3 = arith.mulf %1, %0 : f64
          %4 = arith.addf %2, %3 : f64
          affine.store %4, %alloc[%arg1, %arg0] : memref<2x2xf64>
        }
      }
    }
  
    memref.dealloc %alloc_6 : memref<2x3xf64>
    memref.dealloc %alloc : memref<2x2xf64>
    return
  }
}
```

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


More information about the llvm-commits mailing list