Can I convert from the ONNX dialect back to .onnx? #3017
-
I'm working on a project where I'd like to: Convert .onnx model to MLIR -> Apply transformations on the MLIR output -> Convert back to .onnx so I can compare the number of MACs in the new model with the original, for example. Is this possible? It looks like the options after converting to MLIR are limited. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I believe you have 2 ways to do it. One is in ONNX directly; while I have no direct experience with it, ONNX Runtime (ORT) does ingest a ONNX graph, can optimize it, and regenerate an ONNX output. You can use ORT as an example, I believe ONNX should have ways to do that directly using python tools. Obviously, the changes you will do are not using MLIR. The other approach is to use onnx-mlir, which ingest ONNX representations and lower it to an MLIR ONNX dialect. We already have many optimizations/transforms that operate in this ONNX dialect within the ONNX-MLIR project. However, at this time, we do not have an ONNX exporter, only MLIR based exporters. While we have no bandwidth to create such an exporter, we would be open to have one integrated in the project, especially if there is a willingness to maintain it through successive ONNX releases. Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Thanks, Alexandre - that's good to know. |
Beta Was this translation helpful? Give feedback.
I believe you have 2 ways to do it.
One is in ONNX directly; while I have no direct experience with it, ONNX Runtime (ORT) does ingest a ONNX graph, can optimize it, and regenerate an ONNX output. You can use ORT as an example, I believe ONNX should have ways to do that directly using python tools. Obviously, the changes you will do are not using MLIR.
The other approach is to use onnx-mlir, which ingest ONNX representations and lower it to an MLIR ONNX dialect. We already have many optimizations/transforms that operate in this ONNX dialect within the ONNX-MLIR project. However, at this time, we do not have an ONNX exporter, only MLIR based exporters. While we have no bandwidth to create …