pymlir icon indicating copy to clipboard operation
pymlir copied to clipboard

No dialect specification in generated MLIR

Open HesamGit opened this issue 2 years ago • 2 comments

The generated MLIR does not have dialect specification. For example, tests/test_builder.py generates instructions without dialect (as shown below):

func -> should be -> func.func constant -> should be -> arith.constant

This causes issues when I use this output with llvm tools (mlir-opt or mlir-translate). They complain about not recognizing "func" or "constant".

module {
  func @saxpy(%_pymlir_fnarg: f64, %_pymlir_fnarg_0: memref<?xf64>, %_pymlir_fnarg_1: memref<?xf64>) {
    %_pymlir_ssa = constant 0 : index
    %_pymlir_ssa_0 = dim %_pymlir_fnarg_0 , %_pymlir_ssa : index
    affine.for %_pymlir_i = 0 to %_pymlir_ssa_0 {
      %_pymlir_ssa_1 = affine.load %_pymlir_fnarg_0 [ (%_pymlir_i) ] : memref<?xf64>
      %_pymlir_ssa_2 = mulf %_pymlir_ssa_1 , %_pymlir_fnarg : f64
      %_pymlir_ssa_3 = affine.load %_pymlir_fnarg_1 [ (%_pymlir_i) ] : memref<?xf64>
      %_pymlir_ssa_4 = addf %_pymlir_ssa_3 , %_pymlir_ssa_2 : f64
      affine.store %_pymlir_ssa_4 , %_pymlir_fnarg_1 [ (%_pymlir_i) ] : memref<?xf64>
    }
    return
  }
}

HesamGit avatar Jan 09 '23 00:01 HesamGit

See #19 and #20 for func. constant seems like a similar issue

blaine-fs avatar Jan 12 '23 03:01 blaine-fs

Yes, the recent changes to MLIR requires us to add the concept of core/standard dialects. This is in progress for func, and will be done for the rest as well. I have a bit of high overhead at the moment so I will not be able to make the necessary changes very soon. Any PRs are welcome!

tbennun avatar Jan 20 '23 15:01 tbennun