torch-mlir/projects/onnx_c_importer
Stella Laurenzo 1b40b6384e
[onnx] Add torch-mlir-import-onnx native port as an optional tool/library. (#2694)
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.
2023-12-27 12:13:34 -08:00
..
CMakeLists.txt [onnx] Add torch-mlir-import-onnx native port as an optional tool/library. (#2694) 2023-12-27 12:13:34 -08:00
OnnxImporter.cpp [onnx] Add torch-mlir-import-onnx native port as an optional tool/library. (#2694) 2023-12-27 12:13:34 -08:00
OnnxImporter.h [onnx] Add torch-mlir-import-onnx native port as an optional tool/library. (#2694) 2023-12-27 12:13:34 -08:00
README.md [onnx] Add torch-mlir-import-onnx native port as an optional tool/library. (#2694) 2023-12-27 12:13:34 -08:00
import-onnx-main.cpp [onnx] Add torch-mlir-import-onnx native port as an optional tool/library. (#2694) 2023-12-27 12:13:34 -08:00

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.