Skip to content

Commit e0c16ea

Browse files
Create docs
Signed-off-by: Justin Chu <[email protected]> Co-authored-by: G. Ramalingam <[email protected]>
1 parent 9d93cbb commit e0c16ea

17 files changed

+1151
-4
lines changed

REUSE.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ SPDX-PackageDownloadLocation = "onnx.ai"
99

1010
[[annotations]]
1111
path = [
12-
"**/*.yml",
12+
".editorconfig",
13+
".gitignore",
14+
"**/*.css",
15+
"**/*.ipynb",
1316
"**/*.md",
17+
"**/*.rst",
1418
"**/*.toml",
19+
"**/*.yml",
20+
"CODEOWNERS",
1521
"requirements/**/*.txt",
16-
".editorconfig",
17-
".gitignore",
18-
"CODEOWNERS"
1922
]
2023
precedence = "aggregate"
2124
SPDX-FileCopyrightText = "Copyright (c) ONNX Project Contributors"

docs/_static/css/custom.css

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
.navbar-brand {
2+
padding: 4px 0 2px 0;
3+
}
4+
5+
.bi {
6+
width: 1em;
7+
height: 1em;
8+
display: inline-block;
9+
vertical-align: -0.125em;
10+
fill: currentcolor;
11+
flex-shrink: 0;
12+
}
13+
14+
.article-meta {
15+
display: flex;
16+
align-items: first baseline;
17+
opacity: 80%;
18+
}
19+
20+
.article-meta:not(:last-child) {
21+
margin-bottom: 0.5rem;
22+
}
23+
24+
.article-meta .bi:first-child {
25+
margin-right: 0.5em;
26+
}
27+
28+
.article-authors > ul {
29+
display: inline;
30+
list-style: none;
31+
margin: 0;
32+
padding: 0;
33+
}
34+
35+
.article-authors > ul > li {
36+
display: inline;
37+
}
38+
39+
.article-authors > ul > li:not(:last-child)::after {
40+
content: " • ";
41+
}
42+
43+
.article-date > span {
44+
font-style: italic;
45+
font-size: 0.875rem;
46+
opacity: 80%;
47+
}
48+
49+
.highlight {
50+
overflow-x: auto;
51+
overflow-y: scroll;
52+
}
53+
54+
.code-title {
55+
text-align: center;
56+
font-weight: normal;
57+
font-style: italic;
58+
margin-top: 1.5em;
59+
}
60+
61+
@media screen {
62+
.longcode > .highlight {
63+
max-height: 25em;
64+
}
65+
}
66+
67+
figure.math {
68+
text-align: center;
69+
margin: 1em 0;
70+
}
71+
72+
figure.math svg {
73+
fill: currentColor;
74+
max-width: max(60%, 400px);
75+
}

docs/_templates/classtemplate.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.. role:: hidden
2+
:class: hidden-section
3+
.. currentmodule:: {{ module }}
4+
5+
6+
{{ name | underline}}
7+
8+
.. autoclass:: {{ name }}
9+
:members:
10+
:undoc-members:
11+
:member-order: bysource
12+
13+
..
14+
autogenerated from docs/_templates/classtemplate.rst
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.. role:: hidden
2+
:class: hidden-section
3+
.. currentmodule:: {{ module }}
4+
5+
6+
{{ name | underline}}
7+
8+
.. autoclass:: {{ name }}
9+
:members:
10+
:undoc-members:
11+
:inherited-members:
12+
:member-order: bysource
13+
14+
15+
..
16+
autogenerated from docs/_templates/classtemplate.rst
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.. role:: hidden
2+
:class: hidden-section
3+
.. currentmodule:: {{ module }}
4+
5+
6+
{{ name | underline}}
7+
8+
.. autofunction:: {{ name }}
9+
10+
11+
..
12+
autogenerated from docs/_templates/functiontemplate.rst

docs/api/core.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# onnx_ir
2+
3+
```{eval-rst}
4+
.. automodule::onnx_ir
5+
.. currentmodule:: onnxscript
6+
```
7+
8+
## Functions and constructors
9+
10+
```{eval-rst}
11+
.. autosummary::
12+
:toctree: generated
13+
:template: functiontemplate.rst
14+
:nosignatures:
15+
16+
ir.load
17+
ir.save
18+
ir.from_proto
19+
ir.from_onnx_text
20+
ir.to_proto
21+
ir.tensor
22+
ir.node
23+
```
24+
25+
## Classes
26+
27+
```{eval-rst}
28+
.. autosummary::
29+
:toctree: generated
30+
:template: classtemplate_inherited.rst
31+
:nosignatures:
32+
33+
ir.TensorProtocol
34+
ir.Value
35+
ir.Node
36+
ir.Graph
37+
ir.Model
38+
ir.GraphView
39+
ir.Function
40+
ir.Attr
41+
ir.RefAttr
42+
ir.Shape
43+
ir.SymbolicDim
44+
ir.TypeAndShape
45+
ir.TensorType
46+
ir.SparseTensorType
47+
ir.SequenceType
48+
ir.OptionalType
49+
ir.Tensor
50+
ir.ExternalTensor
51+
ir.StringTensor
52+
ir.LazyTensor
53+
```
54+
55+
## Enums
56+
57+
```{eval-rst}
58+
.. autosummary::
59+
:toctree: generated
60+
:template: classtemplate.rst
61+
:nosignatures:
62+
63+
ir.DataType
64+
ir.AttributeType
65+
```

docs/api/index.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# IR APIs
2+
3+
```{toctree}
4+
:maxdepth: 1
5+
6+
core
7+
ir_convenience
8+
ir_external_data
9+
ir_passes
10+
ir_passes_common
11+
ir_traversal
12+
ir_tape
13+
```

docs/api/ir_convenience.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# ir.convenience
2+
3+
```{eval-rst}
4+
.. automodule::onnx_ir.convenience
5+
.. currentmodule:: onnx_ir.convenience
6+
```
7+
8+
9+
```{eval-rst}
10+
.. autofunction:: convert_attribute
11+
.. autofunction:: convert_attributes
12+
.. autofunction:: replace_all_uses_with
13+
.. autofunction:: replace_nodes_and_values
14+
.. autofunction:: create_value_mapping
15+
```

docs/api/ir_external_data.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# ir.external_data
2+
3+
```{eval-rst}
4+
.. automodule::onnx_ir.external_data
5+
.. currentmodule:: onnx_ir.external_data
6+
```
7+
8+
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.
9+
10+
## Functions
11+
12+
```{eval-rst}
13+
.. autofunction:: load_to_model
14+
.. autofunction:: unload_from_model
15+
.. autofunction:: convert_tensors_to_external
16+
.. autofunction:: convert_tensors_from_external
17+
.. autofunction:: set_base_dir
18+
```
19+
20+
<!-- TODO: Create examples -->

docs/api/ir_passes.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# ir.passes
2+
3+
```{eval-rst}
4+
.. automodule::onnx_ir.passes
5+
.. currentmodule:: onnxscript
6+
```
7+
8+
## Use built-in passes
9+
10+
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.
11+
12+
## Pass infrastructure
13+
14+
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>`.
15+
16+
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.
17+
18+
```{eval-rst}
19+
.. autosummary::
20+
:toctree: generated
21+
:template: classtemplate.rst
22+
:nosignatures:
23+
24+
ir.passes.PassBase
25+
ir.passes.InPlacePass
26+
ir.passes.FunctionalPass
27+
ir.passes.Sequential
28+
ir.passes.PassResult
29+
ir.passes.PassManager
30+
```
31+
32+
## Errors
33+
34+
```{eval-rst}
35+
.. autoexception:: onnx_ir.passes.InvariantError
36+
.. autoexception:: onnx_ir.passes.PreconditionError
37+
.. autoexception:: onnx_ir.passes.PostconditionError
38+
.. autoexception:: onnx_ir.passes.PassError
39+
```

0 commit comments

Comments
 (0)