Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate pure MLIR? #3083

Open
yuucyf opened this issue Feb 20, 2025 · 2 comments
Open

How to generate pure MLIR? #3083

yuucyf opened this issue Feb 20, 2025 · 2 comments

Comments

@yuucyf
Copy link

yuucyf commented Feb 20, 2025

When using onnx-mlir, the --EmitMLIR parameter is described as "Lower the input to MLIR built-in transformation dialect," which might lead one to believe it generates pure MLIR code. However, after actual use, it becomes clear that the generated file still contains krnl operations, such as krnl.global, krnl.entry_point, and so on.

So, does onnx-mlir provide a way to generate pure MLIR? Currently, I’m unsure how many krnl operations are included in the MLIR file generated by --EmitMLIR, and how these operations can be converted to MLIR built-in IR. Can anyone help clarify this?

@AlexandreEichenberger
Copy link
Collaborator

You are correct, we are using KRNL operations inside of the EmitMLIR target as some KRNL operations are lowered all the way to LLVM lowering. -EmitMLIR means we removed all of the ONNX dialect operation.

If you want to intersect with dialects only found in MLIR official repo, then you will need to lower to TOSA or StableHLO. This is a path that we at IBM do not use, so you will have to touch base with developers that use this path to get more info on this.

@yuucyf
Copy link
Author

yuucyf commented Mar 3, 2025

You are correct, we are using KRNL operations inside of the EmitMLIR target as some KRNL operations are lowered all the way to LLVM lowering. -EmitMLIR means we removed all of the ONNX dialect operation.

If you want to intersect with dialects only found in MLIR official repo, then you will need to lower to TOSA or StableHLO. This is a path that we at IBM do not use, so you will have to touch base with developers that use this path to get more info on this.

KRNL operations are used in the EmitMLIR target. Is it possible to lower all KRNL operations in EmitMLIR target(or EmitPureMLIR target) to pure MLIR?

For example:
krnl.global() => memref.global() & memref.get_global() ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants