Class OnnxExport
java.lang.Object
ai.beestream.jitnn.onnx.OnnxExport
Writes a jitNN forward pass as an ONNX model (opset 20), for ONNX Runtime and the other ONNX
tools. The forward pass is recorded once on example inputs, without running it: every recorded
operator becomes ONNX operators, parameters and other constants become initializers, and the
example inputs become the graph inputs. Shapes are those of the example inputs (no dynamic
axes). Weights are written in FP32. Operators without an ONNX mapping are reported by name.
model.train(false);
OnnxExport.export(Path.of("model.onnx"), x -> model.forward(x[0]), new Tensor[] { example }, new String[] { "input" }, "output");
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidexport(Path, Function, Tensor[], String[], String)for a one-input model.static voidexport(Path file, Function<Tensor[], Tensor> forward, Tensor[] inputs, String[] inputNames, String outputName) Recordsforwardoninputs(put the model in evaluation mode first) and writes it tofilewith graph inputsinputNamesand the outputoutputName.
-
Method Details
-
export
public static void export(Path file, Function<Tensor, Tensor> forward, Tensor example) throws IOExceptionexport(Path, Function, Tensor[], String[], String)for a one-input model.- Throws:
IOException
-
export
public static void export(Path file, Function<Tensor[], Tensor> forward, Tensor[] inputs, String[] inputNames, String outputName) throws IOExceptionRecordsforwardoninputs(put the model in evaluation mode first) and writes it tofilewith graph inputsinputNamesand the outputoutputName.- Throws:
IOException
-