mirror of https://github.com/llvm/torch-mlir
1b40b6384e
As noted in the plan when this work started, we need to produce an ORT EP plugin for a downstream project, and this will necessitate a C-based ONNX importer (as opposed to the existing Python one). Because this comes with dependencies that we do not want to impart on various projects, this is optional in torch-mlir. It is also factored so that it can be used as standalone sources in downstreams that need it. Since it only depends on public C APIs on the MLIR side, this will make build coupling a lot better (since a C++ dep is not needed on the compiler and it is trivial to dynamically load). Our original plan was just to maintain this fork off to the side in our ORT plugin, but once work started, it seemed better to write it clean and contribute it upstream for anyone to use. We expect that for non-ORT use, the Python importer will have better ergonomics for most folks. I will follow-up with a test suite refactor so that we can drive the Python or C importer. This is a relatively mechanical port from Python to C, borrowing some scaffolding from the old JitIR importer. It does attempt to lay some groundwork for external data, which will need to be implemented on the Python side as well. |
||
---|---|---|
.. | ||
CMakeLists.txt | ||
OnnxImporter.cpp | ||
OnnxImporter.h | ||
README.md | ||
import-onnx-main.cpp |
README.md
ONNX C Importer
This project provides a C implementation of the onnx_importer.py
, which is
the canonical source. It is provided as sample code for anyone who wishes to
integrate it into their system. By design, it only depends on the ONNX API
and the MLIR C API via the mlir-c
headers. As such, it should be easy to
build into any system that already has those things by adding the sources.