-
Notifications
You must be signed in to change notification settings - Fork 328
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
Add ONNXToLinalg Conversion #1848
Comments
This is great! The fact that this translation enables the use of existing upstream passes is a huge plus. But in the same spirit, how do you feel about lowering to linalg-on-tensor instead of memref and then use the upstream bufferization passes to lower to memref? I worry that in trying to lower to memref directly, the ONNXToLinalg pass might get too complicated. |
I think it is doable to lower to linalg-on-tensor. There are two possible paths:
|
@sstamenova |
I put some results of #1891 here.
After Lowering to Linalg
After Krnl:
After Linalg bufferization:
After both Linalg and Krnl to affine
|
We have a team even this Tuesday, so we won't be able to attend. However, we can do this the Tuesday following. |
Let's try Dec 13 (Tuesday). |
It is a good idea, if onnx is lowered to linalg, we can do tiling and packing in linalg. And how is the current progress? |
Microsoft was looking into this, I have not heard much on this front in a while. |
I can't speak on behalf of the Microsoft folks, but it's now possible to convert ONNX to StableHLO and use the changes in openxla/stablehlo#1817 to lower to LinAlg. The ONNX-to-StableHLO conversion has some gaps, so it needs some work, but most ONNX operations go through without issues. |
I found that the proposal from Microsoft of using Linalg worth of exploring. The Linalg has some good features and there are existing optimization passes and backend.
I am working on a draft to add passes to lower some ONNX Op to Linalg while the current lowering to knrl is kept working. The passes will look like:
The order of 1 and 2, and that of 3 and 4 may be switchable.
In my experiment, I will only translate one ONNX op (currently, ONNXMatMul is chosen for simplicity) to Linalg. I will use memref for Linalg Op. I feel it may be easier to incorporate ONNX shape inference result for allocation and ONNXToKrnl conversion to lower to memref, instead of using the Linalg detensor pass. Will this decision be a problem for future optimization?
If the framework is set up, collaboration is needed to implement conversion of more ONNX Ops to Linalg. Which lowering should be applied to each ONNX Ops may be controlled by options and restricted by expressiveness of dialect. If the conversion to Linalg is disabled, onnx-mlir works as it does now.
Comments are welcomed.
The text was updated successfully, but these errors were encountered: