cornell-zhang / hcl-dialect

HeteroCL-MLIR dialect for accelerator design
https://cornell-zhang.github.io/heterocl/index.html
Other
37 stars 15 forks source link

[Pass] Preserve strided layouts for LLVM backend #203

Closed chhzh123 closed 10 months ago

chhzh123 commented 10 months ago

With memref.subview, we may create some programs like this, which can be directly executed with LLVM backend. However, the current remove-stride-map pass automatically removes those layout maps, causing the error. This PR fixes this issues by only removing the maps describing array partititon.

module {
  func.func @kernel(%arg0: memref<5x10x15xf32>, %arg1: index, %arg2: index) -> memref<15xf32> attributes {itypes = "___", otypes = "_"} {
    %subview = memref.subview %arg0[%arg1, %arg2, 0] [1, 1, 15] [1, 1, 1] : memref<5x10x15xf32> to memref<15xf32, strided<[1], offset: ?>>
    %alloc = memref.alloc() {from = "A"} : memref<15xf32>
    memref.copy %subview, %alloc : memref<15xf32, strided<[1], offset: ?>> to memref<15xf32>
    return %alloc : memref<15xf32>
  }
}