chore: import upstream snapshot with attribution
Fuzz / Run fuzz harnesses (${{ github.event_name == 'schedule' && 'nightly' || 'smoke' }}) (push) Has been cancelled
Create Releases / call-mac (push) Has been cancelled
Create Releases / call-linux (push) Has been cancelled
Create Releases / call-sdist (push) Has been cancelled
Create Releases / call-win (push) Has been cancelled
Create Releases / call-pyodide (push) Has been cancelled
Windows_No_Exception_CI / build (x64, 3.10) (push) Has been cancelled
Check URLs / build (push) Has been cancelled
Create Releases / Attest CI build artifacts (push) Has been cancelled
Create Releases / Check for Publish release build to pypi (push) Has been cancelled
Create Releases / Check for Publish preview build to test.pypi-weekly (push) Has been cancelled
Create Releases / Publish preview build to test.pypi-weekly (push) Has been cancelled
Create Releases / Check for Publish release build to test.pypi (rc-candidates) (push) Has been cancelled
Create Releases / Publish release build to test.pypi (push) Has been cancelled
Create Releases / Check for Publish preview build to pypi-weekly (push) Has been cancelled
Create Releases / Publish preview build to pypi-weekly (push) Has been cancelled
Create Releases / Publish release build to pypi (push) Has been cancelled
Create Releases / test source distribution (push) Has been cancelled
clang-tidy / clang-tidy (push) Has been cancelled
Lint / Validate SBOM (push) Has been cancelled
Lint / Enforce style (push) Has been cancelled
CI / Test windows-2022, 3.14, External, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test windows-latest, 3.10, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test windows-latest, 3.14, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test windows-latest, 3.14t, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test ubuntu-24.04, 3.14, Internal, debug=1, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test ubuntu-24.04, 3.14, External, debug=0, unity_build=1, onnx_ml=1, autogen=1 (push) Has been cancelled
CI / Test ubuntu-24.04, 3.14, External, debug=0, unity_build=0, onnx_ml=0, autogen=0 (push) Has been cancelled
CI / Test macos-latest, 3.10, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test macos-latest, 3.14, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test macos-latest, 3.14t, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test ubuntu-24.04, 3.14, External, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test ubuntu-24.04, 3.10, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test ubuntu-24.04, 3.14, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test ubuntu-24.04, 3.14t, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
Pixi CI / Install and lint (ubuntu-24.04-arm) (push) Has been cancelled
Pixi CI / Install and lint (windows-2022) (push) Has been cancelled
Pixi CI / Xcode generator build (push) Has been cancelled
Pixi CI / Install and test (macos-latest, default) (push) Has been cancelled
Pixi CI / Install and test (ubuntu-24.04-arm, default) (push) Has been cancelled
Pixi CI / Install and test (ubuntu-latest, default) (push) Has been cancelled
Pixi CI / Install and test (windows-2022, default) (push) Has been cancelled
Pixi CI / Install and test (macos-latest, oldies) (push) Has been cancelled
Pixi CI / Install and test (ubuntu-24.04-arm, oldies) (push) Has been cancelled
Pixi CI / Install and test (ubuntu-latest, oldies) (push) Has been cancelled
Pixi CI / Install and test (windows-2022, oldies) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Copilot Setup Steps / copilot-setup-steps (push) Has been cancelled
Generate and publish ONNX docs / build (push) Has been cancelled
Generate and publish ONNX docs / deploy (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Fuzz / Run fuzz harnesses (${{ github.event_name == 'schedule' && 'nightly' || 'smoke' }}) (push) Has been cancelled
Create Releases / call-mac (push) Has been cancelled
Create Releases / call-linux (push) Has been cancelled
Create Releases / call-sdist (push) Has been cancelled
Create Releases / call-win (push) Has been cancelled
Create Releases / call-pyodide (push) Has been cancelled
Windows_No_Exception_CI / build (x64, 3.10) (push) Has been cancelled
Check URLs / build (push) Has been cancelled
Create Releases / Attest CI build artifacts (push) Has been cancelled
Create Releases / Check for Publish release build to pypi (push) Has been cancelled
Create Releases / Check for Publish preview build to test.pypi-weekly (push) Has been cancelled
Create Releases / Publish preview build to test.pypi-weekly (push) Has been cancelled
Create Releases / Check for Publish release build to test.pypi (rc-candidates) (push) Has been cancelled
Create Releases / Publish release build to test.pypi (push) Has been cancelled
Create Releases / Check for Publish preview build to pypi-weekly (push) Has been cancelled
Create Releases / Publish preview build to pypi-weekly (push) Has been cancelled
Create Releases / Publish release build to pypi (push) Has been cancelled
Create Releases / test source distribution (push) Has been cancelled
clang-tidy / clang-tidy (push) Has been cancelled
Lint / Validate SBOM (push) Has been cancelled
Lint / Enforce style (push) Has been cancelled
CI / Test windows-2022, 3.14, External, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test windows-latest, 3.10, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test windows-latest, 3.14, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test windows-latest, 3.14t, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test ubuntu-24.04, 3.14, Internal, debug=1, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test ubuntu-24.04, 3.14, External, debug=0, unity_build=1, onnx_ml=1, autogen=1 (push) Has been cancelled
CI / Test ubuntu-24.04, 3.14, External, debug=0, unity_build=0, onnx_ml=0, autogen=0 (push) Has been cancelled
CI / Test macos-latest, 3.10, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test macos-latest, 3.14, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test macos-latest, 3.14t, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test ubuntu-24.04, 3.14, External, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test ubuntu-24.04, 3.10, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test ubuntu-24.04, 3.14, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
CI / Test ubuntu-24.04, 3.14t, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Has been cancelled
Pixi CI / Install and lint (ubuntu-24.04-arm) (push) Has been cancelled
Pixi CI / Install and lint (windows-2022) (push) Has been cancelled
Pixi CI / Xcode generator build (push) Has been cancelled
Pixi CI / Install and test (macos-latest, default) (push) Has been cancelled
Pixi CI / Install and test (ubuntu-24.04-arm, default) (push) Has been cancelled
Pixi CI / Install and test (ubuntu-latest, default) (push) Has been cancelled
Pixi CI / Install and test (windows-2022, default) (push) Has been cancelled
Pixi CI / Install and test (macos-latest, oldies) (push) Has been cancelled
Pixi CI / Install and test (ubuntu-24.04-arm, oldies) (push) Has been cancelled
Pixi CI / Install and test (ubuntu-latest, oldies) (push) Has been cancelled
Pixi CI / Install and test (windows-2022, oldies) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Copilot Setup Steps / copilot-setup-steps (push) Has been cancelled
Generate and publish ONNX docs / build (push) Has been cancelled
Generate and publish ONNX docs / deploy (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
# onnx.backend
|
||||
|
||||
## Backend
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.backend.base.Backend
|
||||
:members:
|
||||
```
|
||||
|
||||
## BackendRep
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.backend.base.BackendRep
|
||||
:members:
|
||||
```
|
||||
|
||||
## Device
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.backend.base.Device
|
||||
:members:
|
||||
```
|
||||
|
||||
## DeviceType
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.backend.base.DeviceType
|
||||
:members:
|
||||
```
|
||||
|
||||
## load_model_tests
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.backend.test.loader.load_model_tests
|
||||
```
|
||||
@@ -0,0 +1,17 @@
|
||||
# onnx.checker
|
||||
|
||||
## CheckerContext
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.checker.DEFAULT_CONTEXT
|
||||
:members:
|
||||
```
|
||||
|
||||
## The `onnx.checker` module
|
||||
|
||||
```{eval-rst}
|
||||
.. automodule:: onnx.checker
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
```
|
||||
@@ -0,0 +1,294 @@
|
||||
(l-onnx-classes)=
|
||||
|
||||
# Protos
|
||||
|
||||
This structures are defined with protobuf in files `onnx/*.proto`.
|
||||
It is recommended to use function in module {ref}`l-mod-onnx-helper`
|
||||
to create them instead of directly instantiated them.
|
||||
Every structure can be printed with function `print` and is rendered
|
||||
as a json string.
|
||||
|
||||
## AttributeProto
|
||||
|
||||
This class is used to define an attribute of an operator
|
||||
defined itself by a NodeProto. It is
|
||||
a named attribute containing either singular float, integer, string, graph,
|
||||
and tensor values, or repeated float, integer, string, graph, and tensor values.
|
||||
An AttributeProto MUST contain the name field, and *only one* of the
|
||||
following content fields, effectively enforcing a C/C++ union equivalent.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.AttributeProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-onnx-function-proto)=
|
||||
|
||||
## FunctionProto
|
||||
|
||||
This defines a function. It is not a model but can
|
||||
be used to define custom operators used in a model.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.FunctionProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-onnx-graph-proto)=
|
||||
|
||||
## GraphProto
|
||||
|
||||
This defines a graph or a set of nodes called from a loop or a test
|
||||
for example.
|
||||
A graph defines the computational logic of a model and is comprised of a parameterized
|
||||
list of nodes that form a directed acyclic graph based on their inputs and outputs.
|
||||
This is the equivalent of the *network* or *graph* in many deep learning
|
||||
frameworks.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.GraphProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-onnx-map-proto)=
|
||||
|
||||
## MapProto
|
||||
|
||||
This defines a map or a dictionary. It
|
||||
specifies an associative table, defined by keys and values.
|
||||
MapProto is formed with a repeated field of keys (of type INT8, INT16, INT32,
|
||||
INT64, UINT8, UINT16, UINT32, UINT64, or STRING) and values (of type TENSOR,
|
||||
SPARSE_TENSOR, SEQUENCE, or MAP). Key types and value types have to remain
|
||||
the same throughout the instantiation of the MapProto.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.MapProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-modelproto)=
|
||||
|
||||
## ModelProto
|
||||
|
||||
This defines a model. That is the type every converting library
|
||||
returns after converting a machine learned model.
|
||||
ModelProto is a top-level file/container format for bundling a ML model and
|
||||
associating its computation graph with metadata.
|
||||
The semantics of the model are described by the associated GraphProto's.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.ModelProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-nodeproto)=
|
||||
|
||||
## NodeProto
|
||||
|
||||
This defines an operator. A model is a combination of
|
||||
mathematical functions, each of them represented as an onnx operator,
|
||||
stored in a NodeProto.
|
||||
Computation graphs are made up of a DAG of nodes, which represent what is
|
||||
commonly called a *layer* or *pipeline stage* in machine learning frameworks.
|
||||
For example, it can be a node of type *Conv* that takes in an image, a filter
|
||||
tensor and a bias tensor, and produces the convolved output.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.NodeProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-operatorproto)=
|
||||
|
||||
## OperatorProto
|
||||
|
||||
This class is rarely used by users.
|
||||
An OperatorProto represents the immutable specification of the signature
|
||||
and semantics of an operator.
|
||||
Operators are declared as part of an OperatorSet, which also defines the
|
||||
domain name for the set.
|
||||
Operators are uniquely identified by a three part identifier
|
||||
(domain, op_type, since_version) where
|
||||
|
||||
- *domain* is the domain of an operator set that contains this operator specification.
|
||||
- *op_type* is the name of the operator as referenced by a NodeProto.op_type
|
||||
- *since_version* is the version of the operator set that this operator was initially declared in.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.OperatorProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-operatorsetidproto)=
|
||||
|
||||
## OperatorSetIdProto
|
||||
|
||||
This is the type of attribute `opset_import` of class ModelProto.
|
||||
This attribute specifies the versions of operators used in the model.
|
||||
Every operator or node belongs to a domain. All operators for the same
|
||||
domain share the same version.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.OperatorSetIdProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-operatorsetproto)=
|
||||
|
||||
## OperatorSetProto
|
||||
|
||||
An OperatorSetProto represents an immutable set of immutable operator specifications.
|
||||
The domain of the set (OperatorSetProto.domain) is a reverse-DNS name
|
||||
that disambiguates operator sets defined by independent entities.
|
||||
The version of the set (opset_version) is a monotonically increasing
|
||||
integer that indicates changes to the membership of the operator set.
|
||||
Operator sets are uniquely identified by a two part identifier (domain, opset_version)
|
||||
Like ModelProto, OperatorSetProto is intended as a top-level file/wire format,
|
||||
and thus has the standard format headers in addition to the operator set information.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.OperatorSetProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-optionalproto)=
|
||||
|
||||
## OptionalProto
|
||||
|
||||
Some input or output of a model are optional. This class must
|
||||
be used in this case. An instance of class OptionalProto
|
||||
may contain or not an instance of type TensorProto, SparseTensorProto,
|
||||
SequenceProto, MapProto and OptionalProto.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.OptionalProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-onnx-sequence-proto)=
|
||||
|
||||
## SequenceProto
|
||||
|
||||
This defines a dense, ordered, collection of elements that are of homogeneous types.
|
||||
Sequences can be made out of tensors, maps, or sequences.
|
||||
If a sequence is made out of tensors, the tensors must have the same element
|
||||
type (i.e. int32). In some cases, the tensors in a sequence can have different
|
||||
shapes. Whether the tensors can have different shapes or not depends on the
|
||||
type/shape associated with the corresponding `ValueInfo`. For example,
|
||||
`Sequence<Tensor<float, [M,N]>` means that all tensors have same shape. However,
|
||||
`Sequence<Tensor<float, [omitted,omitted]>` means they can have different
|
||||
shapes (all of rank 2), where *omitted* means the corresponding dimension has
|
||||
no symbolic/constant value. Finally, `Sequence<Tensor<float, omitted>>` means
|
||||
that the different tensors can have different ranks, when the *shape* itself
|
||||
is omitted from the tensor-type. For a more complete description, refer to
|
||||
[Static tensor shapes](https://github.com/onnx/onnx/blob/main/docs/IR.md#static-tensor-shapes).
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.SequenceProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-onnx-sparsetensor-proto)=
|
||||
|
||||
## SparseTensorProto
|
||||
|
||||
This defines a sparse tensor.
|
||||
The sequence of non-default values are encoded as a tensor of shape `[NNZ]`.
|
||||
The default-value is zero for numeric tensors, and empty-string for string tensors.
|
||||
values must have a non-empty name present which serves as a name for SparseTensorProto
|
||||
when used in sparse_initializer list.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.SparseTensorProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-onnx-stringstringentry-proto)=
|
||||
|
||||
## StringStringEntryProto
|
||||
|
||||
This is equivalent to a pair of strings.
|
||||
This is used to store metadata in ModelProto.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.StringStringEntryProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-tensorproto)=
|
||||
|
||||
## TensorProto
|
||||
|
||||
This defines a tensor. A tensor is fully described with a shape
|
||||
(see ShapeProto), the element type (see TypeProto), and the
|
||||
elements themselves. All available types are listed in
|
||||
{ref}`l-mod-onnx-mapping`.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.TensorProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-tensorshapeproto)=
|
||||
|
||||
## TensorShapeProto
|
||||
|
||||
This defines the shape of a tensor or a sparse tensor.
|
||||
It is a list of dimensions. A dimension can be either an integer value
|
||||
or a symbolic variable. A symbolic variable represents an unknown
|
||||
dimension.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.TensorShapeProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-traininginfoproto)=
|
||||
|
||||
## TrainingInfoProto
|
||||
|
||||
TrainingInfoProto stores information for training a model.
|
||||
In particular, this defines two functionalities: an initialization-step
|
||||
and a training-algorithm-step. Initialization resets the model
|
||||
back to its original state as if no training has been performed.
|
||||
Training algorithm improves the model based on input data.
|
||||
The semantics of the initialization-step is that the initializers
|
||||
in ModelProto.graph and in TrainingInfoProto.algorithm are first
|
||||
initialized as specified by the initializers in the graph, and then
|
||||
updated by the *initialization_binding* in every instance in
|
||||
ModelProto.training_info.
|
||||
The field *algorithm* defines a computation graph which represents a
|
||||
training algorithm's step. After the execution of a
|
||||
TrainingInfoProto.algorithm, the initializers specified by *update_binding*
|
||||
may be immediately updated. If the targeted training algorithm contains
|
||||
consecutive update steps (such as block coordinate descent methods),
|
||||
the user needs to create a TrainingInfoProto for each step.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.TrainingInfoProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-typeproto)=
|
||||
|
||||
## TypeProto
|
||||
|
||||
This defines a type of a tensor which consists in an element type
|
||||
and a shape (ShapeProto).
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.TypeProto
|
||||
:members:
|
||||
```
|
||||
|
||||
(l-valueinfoproto)=
|
||||
|
||||
## ValueInfoProto
|
||||
|
||||
This defines a input or output type of a GraphProto.
|
||||
It contains a name, a type (TypeProto), and a documentation string.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.ValueInfoProto
|
||||
:members:
|
||||
```
|
||||
@@ -0,0 +1,44 @@
|
||||
# onnx.compose
|
||||
|
||||
```{eval-rst}
|
||||
.. currentmodule:: onnx.compose
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autosummary::
|
||||
|
||||
merge_graphs
|
||||
merge_models
|
||||
```
|
||||
|
||||
## merge_graphs
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.compose.merge_graphs
|
||||
```
|
||||
|
||||
## merge_models
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.compose.merge_models
|
||||
```
|
||||
|
||||
## prefix
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.compose.add_prefix_graph
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.compose.add_prefix
|
||||
```
|
||||
|
||||
## dimension
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.compose.expand_out_dim
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.compose.expand_out_dim_graph
|
||||
```
|
||||
@@ -0,0 +1,62 @@
|
||||
(l-mod-onnx-defs)=
|
||||
|
||||
# onnx.defs
|
||||
|
||||
(l-api-opset-version)=
|
||||
|
||||
## Opset Version
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.defs.onnx_opset_version
|
||||
```
|
||||
|
||||
## Operators and Functions Schemas
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.defs.has
|
||||
|
||||
.. autofunction:: onnx.defs.get_schema
|
||||
|
||||
.. autofunction:: onnx.defs.get_all_schemas
|
||||
|
||||
.. autofunction:: onnx.defs.get_all_schemas_with_history
|
||||
|
||||
.. autofunction:: onnx.defs.get_function_ops
|
||||
|
||||
.. autofunction:: onnx.defs.register_schema
|
||||
|
||||
.. autofunction:: onnx.defs.deregister_schema
|
||||
```
|
||||
|
||||
## class `OpSchema`
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.defs.OpSchema
|
||||
:members:
|
||||
:undoc-members:
|
||||
```
|
||||
|
||||
## Exceptions
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.defs.SchemaError
|
||||
```
|
||||
|
||||
## Constants
|
||||
|
||||
Domains officially supported in onnx package.
|
||||
|
||||
```{eval-rst}
|
||||
.. exec_code::
|
||||
|
||||
from onnx.defs import (
|
||||
ONNX_DOMAIN,
|
||||
ONNX_ML_DOMAIN,
|
||||
AI_ONNX_PREVIEW_DOMAIN,
|
||||
AI_ONNX_PREVIEW_TRAINING_DOMAIN,
|
||||
)
|
||||
print(f"ONNX_DOMAIN={ONNX_DOMAIN!r}")
|
||||
print(f"ONNX_ML_DOMAIN={ONNX_ML_DOMAIN!r}")
|
||||
print(f"AI_ONNX_PREVIEW_DOMAIN={AI_ONNX_PREVIEW_DOMAIN!r}")
|
||||
print(f"AI_ONNX_PREVIEW_TRAINING_DOMAIN={AI_ONNX_PREVIEW_TRAINING_DOMAIN!r}")
|
||||
```
|
||||
@@ -0,0 +1,61 @@
|
||||
# onnx.external_data_helper
|
||||
|
||||
## convert_model_from_external_data
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.external_data_helper.convert_model_from_external_data
|
||||
```
|
||||
|
||||
## convert_model_to_external_data
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.external_data_helper.convert_model_to_external_data
|
||||
```
|
||||
|
||||
## ExternalDataInfo
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.external_data_helper.ExternalDataInfo
|
||||
```
|
||||
|
||||
## load_external_data_for_model
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.external_data_helper.load_external_data_for_model
|
||||
```
|
||||
|
||||
## load_external_data_for_tensor
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.external_data_helper.load_external_data_for_tensor
|
||||
```
|
||||
|
||||
## remove_external_data_field
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.external_data_helper.remove_external_data_field
|
||||
```
|
||||
|
||||
## save_external_data
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.external_data_helper.save_external_data
|
||||
```
|
||||
|
||||
## set_external_data
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.external_data_helper.set_external_data
|
||||
```
|
||||
|
||||
## uses_external_data
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.external_data_helper.uses_external_data
|
||||
```
|
||||
|
||||
## write_external_data_tensors
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.external_data_helper.write_external_data_tensors
|
||||
```
|
||||
@@ -0,0 +1,163 @@
|
||||
(l-mod-onnx-helper)=
|
||||
|
||||
# onnx.helper
|
||||
|
||||
```{eval-rst}
|
||||
.. currentmodule:: onnx.helper
|
||||
```
|
||||
|
||||
(l-onnx-make-function)=
|
||||
|
||||
## Helper functions to make ONNX graph components
|
||||
|
||||
All functions used to create an ONNX graph.
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_attribute
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_attribute_ref
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_empty_tensor_value_info
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_function
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_graph
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_map
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_map_type_proto
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_model
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_node
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_operatorsetid
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_opsetid
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_model_gen_version
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_optional
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_optional_type_proto
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_sequence
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_sequence_type_proto
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_sparse_tensor
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_sparse_tensor_type_proto
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_sparse_tensor_value_info
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_tensor
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_tensor_sequence_value_info
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_tensor_type_proto
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_training_info
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_tensor_value_info
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.make_value_info
|
||||
```
|
||||
|
||||
## Type Mappings
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.get_all_tensor_dtypes
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.np_dtype_to_tensor_dtype
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.tensor_dtype_to_field
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.tensor_dtype_to_np_dtype
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.tensor_dtype_to_storage_tensor_dtype
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.tensor_dtype_to_string
|
||||
```
|
||||
|
||||
## Tools
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.helper.find_min_ir_version_for
|
||||
```
|
||||
|
||||
## Other functions
|
||||
|
||||
```{eval-rst}
|
||||
.. autosummary::
|
||||
|
||||
get_attribute_value
|
||||
get_node_attr_value
|
||||
set_metadata_props
|
||||
set_model_props
|
||||
printable_attribute
|
||||
printable_dim
|
||||
printable_graph
|
||||
printable_node
|
||||
printable_tensor_proto
|
||||
printable_type
|
||||
printable_value_info
|
||||
```
|
||||
@@ -0,0 +1,71 @@
|
||||
(l-python-onnx-api)=
|
||||
|
||||
# API Reference
|
||||
|
||||
```{tip}
|
||||
The [ir-py project](https://github.com/onnx/ir-py) provides alternative Pythonic APIs for creating and manipulating ONNX models without interaction with Protobuf.
|
||||
```
|
||||
|
||||
## Versioning
|
||||
|
||||
The following example shows how to retrieve onnx version,
|
||||
the onnx opset, the IR version. Every new major release increments the opset version
|
||||
(see {ref}`l-api-opset-version`).
|
||||
|
||||
```{eval-rst}
|
||||
.. exec_code::
|
||||
|
||||
from onnx import __version__, IR_VERSION
|
||||
from onnx.defs import onnx_opset_version
|
||||
print(f"onnx.__version__={__version__!r}, opset={onnx_opset_version()}, IR_VERSION={IR_VERSION}")
|
||||
```
|
||||
|
||||
The intermediate representation (IR) specification is the abstract model for
|
||||
graphs and operators and the concrete format that represents them.
|
||||
Adding a structure or modifying one of them increases the IR version.
|
||||
|
||||
The opset version increases when an operator is added or removed or modified.
|
||||
A higher opset means a longer list of operators and more options to
|
||||
implement an ONNX functions. An operator is usually modified because it
|
||||
supports more input and output type, or an attribute becomes an input.
|
||||
|
||||
## Data Structures
|
||||
|
||||
Every ONNX object is defined based on a [protobuf message](https://googleapis.dev/python/protobuf/latest/google/protobuf/message.html)
|
||||
and has a name ended with suffix `Proto`. For example, {ref}`l-nodeproto` defines
|
||||
an operator, {ref}`l-tensorproto` defines a tensor. Next page lists all of them.
|
||||
|
||||
```{toctree}
|
||||
:maxdepth: 1
|
||||
|
||||
classes
|
||||
serialization
|
||||
```
|
||||
|
||||
## Functions
|
||||
|
||||
An ONNX model can be created directly from the classes described
|
||||
in the previous section, but it is faster to create and
|
||||
verify a model with the following helpers.
|
||||
|
||||
```{toctree}
|
||||
:maxdepth: 1
|
||||
|
||||
backend
|
||||
checker
|
||||
compose
|
||||
defs
|
||||
external_data_helper
|
||||
helper
|
||||
inliner
|
||||
mapping
|
||||
model_container
|
||||
numpy_helper
|
||||
parser
|
||||
printer
|
||||
reference
|
||||
shape_inference
|
||||
tools
|
||||
utils
|
||||
version_converter
|
||||
```
|
||||
@@ -0,0 +1,13 @@
|
||||
# onnx.inliner
|
||||
|
||||
## inline_local_functions
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.inliner.inline_local_functions
|
||||
```
|
||||
|
||||
## inline_selected_functions
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.inliner.inline_selected_functions
|
||||
```
|
||||
@@ -0,0 +1,20 @@
|
||||
# onnx.model_container
|
||||
|
||||
## ModelContainer
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.model_container.ModelContainer
|
||||
:members:
|
||||
```
|
||||
|
||||
## make_large_model
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.model_container.make_large_model
|
||||
```
|
||||
|
||||
## make_large_tensor_proto
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.model_container.make_large_tensor_proto
|
||||
```
|
||||
@@ -0,0 +1,63 @@
|
||||
# onnx.numpy_helper
|
||||
|
||||
```{eval-rst}
|
||||
.. currentmodule:: onnx.numpy_helper
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autosummary::
|
||||
|
||||
from_array
|
||||
from_dict
|
||||
from_list
|
||||
from_optional
|
||||
to_array
|
||||
to_dict
|
||||
to_list
|
||||
to_optional
|
||||
|
||||
```
|
||||
|
||||
(l-numpy-helper-onnx-array)=
|
||||
|
||||
## array
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.numpy_helper.from_array
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.numpy_helper.to_array
|
||||
```
|
||||
|
||||
Arrays with data types not supported natively by NumPy will be return with ``ml_dtypes`` dtypes.
|
||||
|
||||
## sequence
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.numpy_helper.to_list
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.numpy_helper.from_list
|
||||
```
|
||||
|
||||
## dictionary
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.numpy_helper.to_dict
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.numpy_helper.from_dict
|
||||
```
|
||||
|
||||
## optional
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.numpy_helper.to_optional
|
||||
```
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.numpy_helper.from_optional
|
||||
```
|
||||
@@ -0,0 +1,25 @@
|
||||
# onnx.parser
|
||||
|
||||
## parse_node
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.parser.parse_node
|
||||
```
|
||||
|
||||
## parse_function
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.parser.parse_function
|
||||
```
|
||||
|
||||
## parse_graph
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.parser.parse_graph
|
||||
```
|
||||
|
||||
## parse_model
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.parser.parse_model
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
# onnx.printer
|
||||
|
||||
## to_text
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.printer.to_text
|
||||
```
|
||||
@@ -0,0 +1,45 @@
|
||||
(l-reference-implementation)=
|
||||
|
||||
# onnx.reference
|
||||
|
||||
## DefaultNone
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.reference.op_run.DefaultNone
|
||||
:members:
|
||||
```
|
||||
|
||||
## ReferenceEvaluator
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.reference.ReferenceEvaluator
|
||||
:members: input_names, output_names, opsets, run
|
||||
```
|
||||
|
||||
## OpFunction
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.reference.op_run.OpFunction
|
||||
:members: create, eval, input, output, implicit_inputs, domain, need_context, run, make_node
|
||||
```
|
||||
|
||||
## OpRun
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.reference.op_run.OpRun
|
||||
:members: create, eval, input, output, implicit_inputs, domain, need_context, run, make_node
|
||||
```
|
||||
|
||||
## RuntimeTypeError
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.reference.op_run.RuntimeTypeError
|
||||
:members:
|
||||
```
|
||||
|
||||
## SparseTensor
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.reference.op_run.SparseTensor
|
||||
:members:
|
||||
```
|
||||
@@ -0,0 +1,119 @@
|
||||
(l-serialization)=
|
||||
|
||||
# Serialization
|
||||
|
||||
## Save a model and any Proto class
|
||||
|
||||
This ONNX graph needs to be serialized into one contiguous
|
||||
memory buffer. Method `SerializeToString` is available
|
||||
in every ONNX objects.
|
||||
|
||||
```
|
||||
with open("model.onnx", "wb") as f:
|
||||
f.write(onnx_model.SerializeToString())
|
||||
```
|
||||
|
||||
This method has the following signature.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.ModelProto
|
||||
:members: SerializeToString
|
||||
```
|
||||
|
||||
Every Proto class implements method `SerializeToString`.
|
||||
Therefore the following code works with any class described
|
||||
in page {ref}`l-onnx-classes`.
|
||||
|
||||
```
|
||||
with open("proto.pb", "wb") as f:
|
||||
f.write(proto.SerializeToString())
|
||||
```
|
||||
|
||||
Next example shows how to save a {ref}`l-nodeproto`.
|
||||
|
||||
```{eval-rst}
|
||||
.. exec_code::
|
||||
|
||||
from onnx import NodeProto
|
||||
|
||||
node = NodeProto()
|
||||
node.name = "example-type-proto"
|
||||
node.op_type = "Add"
|
||||
node.input.extend(["X", "Y"])
|
||||
node.output.extend(["Z"])
|
||||
|
||||
with open("node.pb", "wb") as f:
|
||||
f.write(node.SerializeToString())
|
||||
```
|
||||
|
||||
## Load a model
|
||||
|
||||
Following function only automates the loading of a class
|
||||
{ref}`l-modelproto`. Next sections shows how to restore
|
||||
any other proto class.
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.load
|
||||
```
|
||||
|
||||
```
|
||||
from onnx import load
|
||||
|
||||
onnx_model = load("model.onnx")
|
||||
```
|
||||
|
||||
Or:
|
||||
|
||||
```
|
||||
from onnx import load
|
||||
|
||||
with open("model.onnx", "rb") as f:
|
||||
onnx_model = load(f)
|
||||
```
|
||||
|
||||
Next function does the same from a bytes array.
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.load_model_from_string
|
||||
|
||||
```
|
||||
|
||||
(l-onnx-load-data)=
|
||||
|
||||
## Load a Proto
|
||||
|
||||
Proto means here any type containing data including a model, a tensor,
|
||||
a sparse tensor, any class listed in page {ref}`l-onnx-classes`.
|
||||
The user must know the type of the data he needs to restore
|
||||
and then call method `ParseFromString`.
|
||||
[protobuf](https://developers.google.com/protocol-buffers)
|
||||
does not store any information about the class
|
||||
of the saved data. Therefore, this class must be known before
|
||||
restoring an object.
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.ModelProto
|
||||
:members: ParseFromString
|
||||
```
|
||||
|
||||
Next example shows how to restore a {ref}`l-nodeproto`.
|
||||
|
||||
```{eval-rst}
|
||||
.. exec_code::
|
||||
|
||||
from onnx import NodeProto
|
||||
|
||||
tp2 = NodeProto()
|
||||
with open("node.pb", "rb") as f:
|
||||
content = f.read()
|
||||
|
||||
tp2.ParseFromString(content)
|
||||
|
||||
print(tp2)
|
||||
```
|
||||
|
||||
A shortcut exists for {ref}`l-tensorproto`:
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.load_tensor_from_string
|
||||
```
|
||||
@@ -0,0 +1,25 @@
|
||||
# onnx.shape_inference
|
||||
|
||||
## infer_shapes
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.shape_inference.infer_shapes
|
||||
```
|
||||
|
||||
## infer_shapes_path
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.shape_inference.infer_shapes_path
|
||||
```
|
||||
|
||||
## infer_node_outputs
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.shape_inference.infer_node_outputs
|
||||
```
|
||||
|
||||
## infer_function_output_types
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.shape_inference.infer_function_output_types
|
||||
```
|
||||
@@ -0,0 +1,14 @@
|
||||
# onnx.tools
|
||||
|
||||
|
||||
## update_inputs_outputs_dims
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.tools.update_model_dims.update_inputs_outputs_dims
|
||||
```
|
||||
|
||||
## replace_initializer_by_constant_of_shape
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.tools.replace_constants.replace_initializer_by_constant_of_shape
|
||||
```
|
||||
@@ -0,0 +1,14 @@
|
||||
# onnx.utils
|
||||
|
||||
## Extractor
|
||||
|
||||
```{eval-rst}
|
||||
.. autoclass:: onnx.utils.Extractor
|
||||
:members:
|
||||
```
|
||||
|
||||
## extract_model
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.utils.extract_model
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
# onnx.version_converter
|
||||
|
||||
## convert_version
|
||||
|
||||
```{eval-rst}
|
||||
.. autofunction:: onnx.version_converter.convert_version
|
||||
```
|
||||
Reference in New Issue
Block a user