[Affine] Failed to legalize operation 'affine.parallel' marked as erased when using `affine.store` with `affine.parallel`
| Bugzilla Link | 48359 |
| Resolution | FIXED |
| Resolved on | Dec 22, 2020 09:07 |
| Version | unspecified |
| OS | All |
| CC | @joker-eph,@bondhugula |
| Fixed by commit(s) | https://github.com/llvm/llvm-project/commit/3e07b0b9d3363fb767cbbaa2593fa91ac393fb7e |
Extended Description
Using affine.parallel with result value and the affine.store together will trigger a lowering error.
OS: macOS 10.15.7 and Ubuntu20.04
Source code:
func @conv_2d(%arg0: memref<?x?xf32>, %arg1: memref<?x?xf32>, %arg2: memref<?x?xf32>) { %c0 = constant 0 : index %filter_dim = dim %arg1, %c0 : memref<?x?xf32> %output_dim = dim %arg2, %c0 : memref<?x?xf32> affine.parallel (%x, %y) = (%c0, %c0) to (%output_dim, %output_dim) { %0 = affine.parallel (%kx, %ky) = (%c0, %c0) to (%filter_dim, %filter_dim) reduce ("addf") -> (f32) { %1 = affine.load %arg0[%x + %kx, %y + %ky] : memref<?x?xf32> %2 = affine.load %arg1[%kx, %ky] : memref<?x?xf32> %3 = mulf %1, %2 : f32 affine.yield %3 : f32 } affine.store %0, %arg2[%x, %y] : memref<?x?xf32> } return }
Use the mlir-opt with -lower-affine, it will report an error:
error: failed to legalize operation 'affine.parallel' marked as erased
Bug Fixed successfully. Please refer to the below differential revision. Differential Revision: https://reviews.llvm.org/D93090