Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,8 @@ cython_debug/
.pypirc

.DS_Store

# Generated files
*.onnx
!testdata/**/*.onnx
docs/**/generated/*
11 changes: 7 additions & 4 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ SPDX-PackageDownloadLocation = "onnx.ai"

[[annotations]]
path = [
"**/*.yml",
".editorconfig",
".gitignore",
"**/*.css",
"**/*.ipynb",
"**/*.md",
"**/*.rst",
"**/*.toml",
"**/*.yml",
"CODEOWNERS",
"requirements/**/*.txt",
".editorconfig",
".gitignore",
"CODEOWNERS"
]
precedence = "aggregate"
SPDX-FileCopyrightText = "Copyright (c) ONNX Project Contributors"
Expand Down
75 changes: 75 additions & 0 deletions docs/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
.navbar-brand {
padding: 4px 0 2px 0;
}

.bi {
width: 1em;
height: 1em;
display: inline-block;
vertical-align: -0.125em;
fill: currentcolor;
flex-shrink: 0;
}

.article-meta {
display: flex;
align-items: first baseline;
opacity: 80%;
}

.article-meta:not(:last-child) {
margin-bottom: 0.5rem;
}

.article-meta .bi:first-child {
margin-right: 0.5em;
}

.article-authors > ul {
display: inline;
list-style: none;
margin: 0;
padding: 0;
}

.article-authors > ul > li {
display: inline;
}

.article-authors > ul > li:not(:last-child)::after {
content: " • ";
}

.article-date > span {
font-style: italic;
font-size: 0.875rem;
opacity: 80%;
}

.highlight {
overflow-x: auto;
overflow-y: scroll;
}

.code-title {
text-align: center;
font-weight: normal;
font-style: italic;
margin-top: 1.5em;
}

@media screen {
.longcode > .highlight {
max-height: 25em;
}
}

figure.math {
text-align: center;
margin: 1em 0;
}

figure.math svg {
fill: currentColor;
max-width: max(60%, 400px);
}
14 changes: 14 additions & 0 deletions docs/_templates/classtemplate.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. role:: hidden
:class: hidden-section
.. currentmodule:: {{ module }}


{{ name | underline}}

.. autoclass:: {{ name }}
:members:
:undoc-members:
:member-order: bysource

..
autogenerated from docs/_templates/classtemplate.rst
16 changes: 16 additions & 0 deletions docs/_templates/classtemplate_inherited.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. role:: hidden
:class: hidden-section
.. currentmodule:: {{ module }}


{{ name | underline}}

.. autoclass:: {{ name }}
:members:
:undoc-members:
:inherited-members:
:member-order: bysource


..
autogenerated from docs/_templates/classtemplate.rst
12 changes: 12 additions & 0 deletions docs/_templates/functiontemplate.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. role:: hidden
:class: hidden-section
.. currentmodule:: {{ module }}


{{ name | underline}}

.. autofunction:: {{ name }}


..
autogenerated from docs/_templates/functiontemplate.rst
65 changes: 65 additions & 0 deletions docs/api/core.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# onnx_ir

```{eval-rst}
.. automodule::onnx_ir
.. currentmodule:: onnxscript
```

## Functions and constructors

```{eval-rst}
.. autosummary::
:toctree: generated
:template: functiontemplate.rst
:nosignatures:

ir.load
ir.save
ir.from_proto
ir.from_onnx_text
ir.to_proto
ir.tensor
ir.node
```

## Classes

```{eval-rst}
.. autosummary::
:toctree: generated
:template: classtemplate_inherited.rst
:nosignatures:

ir.TensorProtocol
ir.Value
ir.Node
ir.Graph
ir.Model
ir.GraphView
ir.Function
ir.Attr
ir.RefAttr
ir.Shape
ir.SymbolicDim
ir.TypeAndShape
ir.TensorType
ir.SparseTensorType
ir.SequenceType
ir.OptionalType
ir.Tensor
ir.ExternalTensor
ir.StringTensor
ir.LazyTensor
```

## Enums

```{eval-rst}
.. autosummary::
:toctree: generated
:template: classtemplate.rst
:nosignatures:

ir.DataType
ir.AttributeType
```
13 changes: 13 additions & 0 deletions docs/api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# IR APIs

```{toctree}
:maxdepth: 1

core
ir_convenience
ir_external_data
ir_passes
ir_passes_common
ir_traversal
ir_tape
```
15 changes: 15 additions & 0 deletions docs/api/ir_convenience.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ir.convenience

```{eval-rst}
.. automodule::onnx_ir.convenience
.. currentmodule:: onnx_ir.convenience
```


```{eval-rst}
.. autofunction:: convert_attribute
.. autofunction:: convert_attributes
.. autofunction:: replace_all_uses_with
.. autofunction:: replace_nodes_and_values
.. autofunction:: create_value_mapping
```
20 changes: 20 additions & 0 deletions docs/api/ir_external_data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# ir.external_data

```{eval-rst}
.. automodule::onnx_ir.external_data
.. currentmodule:: onnx_ir.external_data
```

The `onnx_ir.external_data` module provides utilities for handling external data in ONNX models. It enables the conversion of tensors to and from external data files, allowing for efficient storage and manipulation of large tensor data. This is particularly useful for models with large initializers that exceed memory constraints.

## Functions

```{eval-rst}
.. autofunction:: load_to_model
.. autofunction:: unload_from_model
.. autofunction:: convert_tensors_to_external
.. autofunction:: convert_tensors_from_external
.. autofunction:: set_base_dir
```

<!-- TODO: Create examples -->
39 changes: 39 additions & 0 deletions docs/api/ir_passes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ir.passes

```{eval-rst}
.. automodule::onnx_ir.passes
.. currentmodule:: onnxscript
```

## Use built-in passes

Common, reusable passes are implemented in `onnx_ir.passes.common`. You can use {py:class}`onnx_ir.passes.Sequential <onnx_ir.passes.Sequential>` to chain passes or use {py:class}`onnx_ir.passes.PassManager <onnx_ir.passes.PassManager>` which supports early stopping if no changes are made.

## Pass infrastructure

Inherent {py:class}`onnx_ir.passes.InPlacePass <onnx_ir.passes.InPlacePass>` or {py:class}`onnx_ir.passes.FunctionalPass <onnx_ir.passes.FunctionalPass>` to define a pass. You will need to implement the `call` method which returns a {py:class}`onnx_ir.passes.PassResult <onnx_ir.passes.PassResult>`.

Alternatively, inherent the base class `onnx_ir.passes.PassBase <onnx_ir.passes.PassBase>` and override the two properties `changes_input` and `in_place` to set properties of the pass.

```{eval-rst}
.. autosummary::
:toctree: generated
:template: classtemplate.rst
:nosignatures:

ir.passes.PassBase
ir.passes.InPlacePass
ir.passes.FunctionalPass
ir.passes.Sequential
ir.passes.PassResult
ir.passes.PassManager
```

## Errors

```{eval-rst}
.. autoexception:: onnx_ir.passes.InvariantError
.. autoexception:: onnx_ir.passes.PreconditionError
.. autoexception:: onnx_ir.passes.PostconditionError
.. autoexception:: onnx_ir.passes.PassError
```
12 changes: 12 additions & 0 deletions docs/api/ir_passes_common.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ir.passes.common

Built-in passes provided by the ONNX IR

```{eval-rst}
.. automodule:: onnx_ir.passes.common
:show-inheritance:
:members:
:undoc-members:
:exclude-members: call

```
18 changes: 18 additions & 0 deletions docs/api/ir_tape.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ir.tape

```{eval-rst}
.. automodule:: onnx_ir.tape
.. currentmodule:: onnx_ir.tape
```

The `onnx_ir.tape` module provides utilities for recording nodes and initializers to construct computational graphs or functions.

## The `Tape` class

The `Tape` class is a recorder that collects nodes and initializers created during the construction of a graph or function. It supports creating nodes with single or multiple outputs and registering initializers.

```{eval-rst}
.. autoclass:: Tape
:members:
:undoc-members:
```
13 changes: 13 additions & 0 deletions docs/api/ir_traversal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ir.traversal

```{eval-rst}
.. automodule:: onnx_ir.traversal
.. currentmodule:: onnx_ir.traversal
```

```{eval-rst}
.. autoclass:: RecursiveGraphIterator
:members:
:undoc-members:
:special-members:
```
Loading