[code-reflection] Integrated: Onnx
Paul Sandoz
psandoz at openjdk.org
Mon Feb 3 23:04:39 UTC 2025
On Mon, 3 Feb 2025 22:32:51 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
> Initial work on a Java ONNX script prototype, a Java equivalent of (Python) [ONNX script](https://github.com/microsoft/onnxscript). The intention is to enable developers to author ONNX functions using a subset of Java and enable easy interaction between Java and the ONNX Runtime (ORT).
>
> Here are the main aspects:
> - A Java ONNX function is a Java method whose implementation contains a restricted set of expressions and statements, primarily consisting of invocation expressions to the Java ONNX operator API.
> - A Java ONNX function is identified for code reflection so its Java code model can be accessed and translated to an ONNX code model consisting of operations instantiated from the Java ONNX IR API that model ONNX operators.
> - A Java ONNX model is exportable to an ONNX model, in protobuf, which can be executed by the ONNX runtime. The Foriegn Function and Memory API is used to interoperate with the ONNX runtime.
> - In addition the Java ONNX function may be invoked. Each invocation to a method of the Java ONNX operator API is interpreted dynamically using the ONNX runtime. This is useful for debugging.
>
> This PR contains the Java ONNX operator API and Java ONNX IR API. Both APIs are generated from a representation of the ONNX schema, which contains a description of each operator supported by ONNX. A JSON document representing the ONNX schema is generated from a Python script. The JSON document is parsed in Java into a simple in-memory representation and that representation is traversed to generate the source code of both APIs. The Java ONNX IR API contains sufficient schema information to reflect over ONNX operators.
>
> A simple test, a CNN implementation, is contributed by @Craigacp. This will initially serve as the primary test case for inference on MNIST data, with weights/biases extracted from an ONNX model exported from an equivalent model trained in Python. Over time we will add further examples.
This pull request has now been integrated.
Changeset: 3b874574
Author: Paul Sandoz <psandoz at openjdk.org>
URL: https://git.openjdk.org/babylon/commit/3b87457432d4cfb147960c2edb2eabd25e50f6f1
Stats: 38221 lines in 38 files changed: 38221 ins; 0 del; 0 mod
Onnx
-------------
PR: https://git.openjdk.org/babylon/pull/306
More information about the babylon-dev
mailing list