WOLFRAM

Wolfram Language & System Documentation Center Wolfram Language Home Page »

ONNX (.onnx)

Background & Context

Import & Export

Import Elements

Options

Examples

open allclose all

Basic Examples  (2)

Import a net in ONNX format:

Show the Import elements available in this file:

Export a net in ONNX format:

Import Elements  (14)

ArrayAssociation  (1)

Obtain an association mapping names to arrays for a given ONNX net:

ArrayList  (1)

Obtain a list of arrays for a given ONNX net:

Description  (1)

Obtain the description for a given ONNX net:

ONNXGraph  (1)

Obtain the ONNX representation of a given net:

ModelDomain  (1)

Obtain the ONNX model domain of a given net:

ModelVersion  (1)

Obtain the ONNX model version of a given net:

Net  (1)

Import the ONNX model as a Wolfram Language net:

This is the default element:

NetExternalObject  (1)

Import the ONNX model as a NetExternalObject:

IRVersion  (1)

Obtain the version of the ONNX intermediate representation of a given net:

OperatorSetVersion  (1)

Obtain the ONNX operator sets used by a given net:

ProducerName  (1)

Obtain the name of the tool used to produce a given net:

ProducerVersion  (1)

Obtain the version of the tool used to produce a given net:

RawData  (1)

Obtain the full unprocessed contents of a given ONNX file:

UninitializedNet  (1)

Import the ONNX model as an uninitialized Wolfram Language net:

Import Options  (1)

"Arrays"  (1)

Arrays used by a net can be contained in separate ONNX tensor proto files. Import an uninitialized net:

Import the net together with its arrays by specifying an array file (multiple array files can be specified in a list):

Export Options  (5)

"Description"  (1)

Specify the model description metadata:

Check the description:

"ExternalArrays"  (1)

Create a simple net and export it with multiple external array files:

Every array of the net was exported to an individual file named after the array, for example, "1_Weights":

The main model file keeps a reference to the relative path of all array files, so the arrays are automatically included when the model is imported:

Export the net with all external arrays in a single file:

A single file called "Arrays" is created that contains all the arrays of the net:

The main model file keeps a reference to the relative path of the combined array file, so the arrays are automatically included when the model is imported:

When the model size is larger than 2GB, a single external array file is automatically created and a warning message is emitted:

"GraphName"  (1)

Specify the graph name metadata:

Check the graph name:

"ModelVersion"  (1)

Specify the model version metadata:

Check the model version:

"OperatorSetVersion"  (1)

Create a PaddingLayer and export it in operator set 10:

Check the operator set version:

In operator set 10, the ONNX "Pad" operator takes one input and has static attributes for its padding sizes and values:

The model file can be converted back because Import supports operator set 10:

Export the same layer in operator set 11:

Check the operator set version:

In operator set 11, padding sizes and values of the "Pad" operator were moved from attributes to inputs. The operator now has two additional inputs and two fewer attributes:

The model file can be converted back because Import supports operator set 11:

Possible Issues  (1)

Any NetEncoder or NetDecoder is automatically removed by Export, as ONNX does not support them. Create a net with a NetEncoder and a NetDecoder and export it:

Importing the model back shows that no NetEncoder or NetDecoder are present:

Top