onnx-ir 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of onnx-ir might be problematic. Click here for more details.
- onnx_ir-0.0.1/LICENSE +22 -0
- onnx_ir-0.0.1/MANIFEST.in +1 -0
- onnx_ir-0.0.1/PKG-INFO +73 -0
- onnx_ir-0.0.1/README.md +25 -0
- onnx_ir-0.0.1/pyproject.toml +106 -0
- onnx_ir-0.0.1/setup.cfg +4 -0
- onnx_ir-0.0.1/src/onnx_ir/__init__.py +154 -0
- onnx_ir-0.0.1/src/onnx_ir/_convenience.py +439 -0
- onnx_ir-0.0.1/src/onnx_ir/_core.py +2875 -0
- onnx_ir-0.0.1/src/onnx_ir/_display.py +49 -0
- onnx_ir-0.0.1/src/onnx_ir/_enums.py +154 -0
- onnx_ir-0.0.1/src/onnx_ir/_external_data.py +323 -0
- onnx_ir-0.0.1/src/onnx_ir/_graph_comparison.py +23 -0
- onnx_ir-0.0.1/src/onnx_ir/_internal/version_utils.py +118 -0
- onnx_ir-0.0.1/src/onnx_ir/_io.py +50 -0
- onnx_ir-0.0.1/src/onnx_ir/_linked_list.py +276 -0
- onnx_ir-0.0.1/src/onnx_ir/_metadata.py +44 -0
- onnx_ir-0.0.1/src/onnx_ir/_name_authority.py +72 -0
- onnx_ir-0.0.1/src/onnx_ir/_protocols.py +598 -0
- onnx_ir-0.0.1/src/onnx_ir/_tape.py +104 -0
- onnx_ir-0.0.1/src/onnx_ir/_thirdparty/asciichartpy.py +313 -0
- onnx_ir-0.0.1/src/onnx_ir/_type_casting.py +91 -0
- onnx_ir-0.0.1/src/onnx_ir/convenience.py +32 -0
- onnx_ir-0.0.1/src/onnx_ir/passes/__init__.py +33 -0
- onnx_ir-0.0.1/src/onnx_ir/passes/_pass_infra.py +172 -0
- onnx_ir-0.0.1/src/onnx_ir/serde.py +1551 -0
- onnx_ir-0.0.1/src/onnx_ir/traversal.py +82 -0
- onnx_ir-0.0.1/src/onnx_ir.egg-info/PKG-INFO +73 -0
- onnx_ir-0.0.1/src/onnx_ir.egg-info/SOURCES.txt +30 -0
- onnx_ir-0.0.1/src/onnx_ir.egg-info/dependency_links.txt +1 -0
- onnx_ir-0.0.1/src/onnx_ir.egg-info/requires.txt +4 -0
- onnx_ir-0.0.1/src/onnx_ir.egg-info/top_level.txt +1 -0
onnx_ir-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Justin Chu
|
|
4
|
+
Copyright (c) Microsoft Corporation
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
global-exclude *_test.py
|
onnx_ir-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: onnx-ir
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Author-email: Justin Chu <justinchu@microsoft.com>
|
|
5
|
+
License: MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2025 Justin Chu
|
|
8
|
+
Copyright (c) Microsoft Corporation
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Classifier: Development Status :: 4 - Beta
|
|
29
|
+
Classifier: Environment :: Console
|
|
30
|
+
Classifier: Intended Audience :: Developers
|
|
31
|
+
Classifier: Operating System :: POSIX
|
|
32
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
33
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
40
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
41
|
+
Requires-Python: >=3.8
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
License-File: LICENSE
|
|
44
|
+
Requires-Dist: numpy
|
|
45
|
+
Requires-Dist: onnx>=1.16
|
|
46
|
+
Requires-Dist: typing_extensions>=4.10
|
|
47
|
+
Requires-Dist: ml_dtypes
|
|
48
|
+
|
|
49
|
+
# ONNX IR
|
|
50
|
+
|
|
51
|
+
> [!NOTE]
|
|
52
|
+
> This is an adaptation of the `onnxscript.ir` module from the ONNX Script project: https://github.com/microsoft/onnxscript/tree/main/onnxscript/ir
|
|
53
|
+
|
|
54
|
+
An in-memory IR that supports the full ONNX spec, designed for graph construction, analysis and transformation.
|
|
55
|
+
|
|
56
|
+
## Features ✨
|
|
57
|
+
|
|
58
|
+
- Full ONNX spec support: all valid models representable by ONNX protobuf, and a subset of invalid models (so you can load and fix them).
|
|
59
|
+
- Low memory footprint: mmap'ed external tensors; unified interface for ONNX TensorProto, Numpy arrays and PyTorch Tensors etc. No tensor size limitation. Zero copies.
|
|
60
|
+
- Straightforward access patterns: Access value information and traverse the graph topology at ease.
|
|
61
|
+
- Robust mutation: Create as many iterators as you like on the graph while mutating it.
|
|
62
|
+
- Speed: Performant graph manipulation, serialization/deserialization to Protobuf.
|
|
63
|
+
- Pythonic and familiar APIs: Classes define Pythonic apis and still map to ONNX protobuf concepts in an intuitive way.
|
|
64
|
+
- No protobuf dependency: The IR does not require protobuf once the model is converted to the IR representation, decoupling from the serialization format.
|
|
65
|
+
|
|
66
|
+
## Code Organization 🗺️
|
|
67
|
+
|
|
68
|
+
- [`_protocols.py`](_protocols.py): Interfaces defined for all entities in the IR.
|
|
69
|
+
- [`_core.py`](_core.py): Implementation of the core entities in the IR, including `Model`, `Graph`, `Node`, `Value`, and others.
|
|
70
|
+
- [`_enums.py`](_enums.py): Definition of the type enums that correspond to the `DataType` and `AttributeType` in `onnx.proto`.
|
|
71
|
+
- [`_name_authority.py`](_name_authority.py): The authority for giving names to entities in the graph, used internally.
|
|
72
|
+
- [`_linked_list.py`](_linked_list.py): The data structure as the node container in the graph that supports robust iteration and mutation. Internal.
|
|
73
|
+
- [`_metadata.py`](_metadata.py): Metadata store for all entities in the IR.
|
onnx_ir-0.0.1/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# ONNX IR
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This is an adaptation of the `onnxscript.ir` module from the ONNX Script project: https://github.com/microsoft/onnxscript/tree/main/onnxscript/ir
|
|
5
|
+
|
|
6
|
+
An in-memory IR that supports the full ONNX spec, designed for graph construction, analysis and transformation.
|
|
7
|
+
|
|
8
|
+
## Features ✨
|
|
9
|
+
|
|
10
|
+
- Full ONNX spec support: all valid models representable by ONNX protobuf, and a subset of invalid models (so you can load and fix them).
|
|
11
|
+
- Low memory footprint: mmap'ed external tensors; unified interface for ONNX TensorProto, Numpy arrays and PyTorch Tensors etc. No tensor size limitation. Zero copies.
|
|
12
|
+
- Straightforward access patterns: Access value information and traverse the graph topology at ease.
|
|
13
|
+
- Robust mutation: Create as many iterators as you like on the graph while mutating it.
|
|
14
|
+
- Speed: Performant graph manipulation, serialization/deserialization to Protobuf.
|
|
15
|
+
- Pythonic and familiar APIs: Classes define Pythonic apis and still map to ONNX protobuf concepts in an intuitive way.
|
|
16
|
+
- No protobuf dependency: The IR does not require protobuf once the model is converted to the IR representation, decoupling from the serialization format.
|
|
17
|
+
|
|
18
|
+
## Code Organization 🗺️
|
|
19
|
+
|
|
20
|
+
- [`_protocols.py`](_protocols.py): Interfaces defined for all entities in the IR.
|
|
21
|
+
- [`_core.py`](_core.py): Implementation of the core entities in the IR, including `Model`, `Graph`, `Node`, `Value`, and others.
|
|
22
|
+
- [`_enums.py`](_enums.py): Definition of the type enums that correspond to the `DataType` and `AttributeType` in `onnx.proto`.
|
|
23
|
+
- [`_name_authority.py`](_name_authority.py): The authority for giving names to entities in the graph, used internally.
|
|
24
|
+
- [`_linked_list.py`](_linked_list.py): The data structure as the node container in the graph that supports robust iteration and mutation. Internal.
|
|
25
|
+
- [`_metadata.py`](_metadata.py): Metadata store for all entities in the IR.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "onnx-ir"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
authors = [{ name = "Justin Chu", email = "justinchu@microsoft.com" }]
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = { file = "LICENSE" }
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 4 - Beta",
|
|
14
|
+
"Environment :: Console",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"Operating System :: POSIX",
|
|
17
|
+
"Operating System :: MacOS :: MacOS X",
|
|
18
|
+
"Operating System :: Microsoft :: Windows",
|
|
19
|
+
"Programming Language :: Python :: 3.8",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"License :: OSI Approved :: MIT License",
|
|
26
|
+
]
|
|
27
|
+
dependencies = ["numpy", "onnx>=1.16", "typing_extensions>=4.10", "ml_dtypes"]
|
|
28
|
+
|
|
29
|
+
[tool.ruff]
|
|
30
|
+
line-length = 95
|
|
31
|
+
target-version = "py38"
|
|
32
|
+
|
|
33
|
+
[tool.ruff.lint]
|
|
34
|
+
select = [
|
|
35
|
+
"B", # flake8-bugbear
|
|
36
|
+
"C4", # flake8-comprehensions
|
|
37
|
+
"D", # pydocstyle
|
|
38
|
+
"E", # pycodestyle
|
|
39
|
+
"F", # Pyflakes
|
|
40
|
+
"G", # flake8-logging-format
|
|
41
|
+
"I", # isort
|
|
42
|
+
"ISC", # flake8-implicit-str-concat
|
|
43
|
+
"LOG", # flake8-logging
|
|
44
|
+
"N", # pep8-naming
|
|
45
|
+
"NPY", # modern numpy
|
|
46
|
+
"PERF", # Perflint
|
|
47
|
+
"PIE", # flake8-pie
|
|
48
|
+
"PYI", # flake8-pyi
|
|
49
|
+
"RUF", # Ruff-specific rules
|
|
50
|
+
"SIM", # flake8-simplify
|
|
51
|
+
"SLOT", # flake8-slot
|
|
52
|
+
"T10", # flake8-debugger
|
|
53
|
+
"TID", # Disallow relative imports
|
|
54
|
+
"TRY", # flake8-try-except-raise
|
|
55
|
+
"UP", # pyupgrade
|
|
56
|
+
"W", # pycodestyle
|
|
57
|
+
"YTT", # flake8-2020
|
|
58
|
+
]
|
|
59
|
+
# Select preview rules
|
|
60
|
+
preview = true
|
|
61
|
+
ignore = [
|
|
62
|
+
"B9", # Opinionated bugbear rules
|
|
63
|
+
"C408", # Sometimes it is preferable when we construct kwargs
|
|
64
|
+
"D1", # D1 is for missing docstrings, which is not yet enforced.
|
|
65
|
+
"D202", # D202 Too strict. "No blank lines allowed after function docstring"
|
|
66
|
+
"D205", # D205 Too strict. "1 blank line required between summary line and description"
|
|
67
|
+
"D212",
|
|
68
|
+
"D400",
|
|
69
|
+
"D401", # First line of docstring should be in imperative mood
|
|
70
|
+
"D415", # D415 Not yet enforced. "First line should end with a period, question mark, or exclamation point"
|
|
71
|
+
"E1", "E2", "E3", # Pycodestyle formatting rules that conflicts with the formatter
|
|
72
|
+
"E501", # Line length. Not enforced because black will handle formatting
|
|
73
|
+
"SIM103", # "Return the condition directly" obscures logic sometimes
|
|
74
|
+
"N802", # Nxx: ONNX Script function sometimes use upper case for names.
|
|
75
|
+
"N803",
|
|
76
|
+
"N806",
|
|
77
|
+
"N999", # Invalid module name
|
|
78
|
+
"NPY002", # We may not always need a generator
|
|
79
|
+
"PERF203", # try-except in loops sometimes necessary
|
|
80
|
+
"PERF401", # List comprehension is not always readable
|
|
81
|
+
"PYI041", # int | float is more clear
|
|
82
|
+
"RUF022", # We don't need to sort __all__ for elements to be grouped
|
|
83
|
+
"RUF031", # Parentheses for tuple in subscripts is more readable
|
|
84
|
+
"RUF052", # Variables with `_` prefix may not be dummy variables in all cases
|
|
85
|
+
"SIM102", # Collapible if statements are not always more readable
|
|
86
|
+
"SIM108", # We don't always encourage ternary operators
|
|
87
|
+
"SIM114", # Don't always combine if branches for debugability
|
|
88
|
+
"SIM116", # Don't use dict lookup to replace if-else
|
|
89
|
+
"TRY003", # Messages can be constructed in the exception
|
|
90
|
+
]
|
|
91
|
+
ignore-init-module-imports = true
|
|
92
|
+
|
|
93
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
|
|
94
|
+
"pathlib".msg = "Using pathlib can impact performance. Use os.path instead"
|
|
95
|
+
|
|
96
|
+
[tool.ruff.lint.per-file-ignores]
|
|
97
|
+
"__init__.py" = ["TID252"] # Allow relative imports in init files
|
|
98
|
+
"setup.py" = ["TID251"] # pathlib is allowed in supporting code
|
|
99
|
+
"**/*_test.py" = ["TID251"] # pathlib is allowed in tests
|
|
100
|
+
|
|
101
|
+
[tool.ruff.lint.flake8-tidy-imports]
|
|
102
|
+
# Disallow all relative imports.
|
|
103
|
+
ban-relative-imports = "all"
|
|
104
|
+
|
|
105
|
+
[tool.ruff.lint.pydocstyle]
|
|
106
|
+
convention = "google"
|
onnx_ir-0.0.1/setup.cfg
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
"""In-memory intermediate representation for ONNX graphs."""
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
# Modules
|
|
7
|
+
"serde",
|
|
8
|
+
# IR classes
|
|
9
|
+
"Tensor",
|
|
10
|
+
"ExternalTensor",
|
|
11
|
+
"StringTensor",
|
|
12
|
+
"SymbolicDim",
|
|
13
|
+
"Shape",
|
|
14
|
+
"TensorType",
|
|
15
|
+
"OptionalType",
|
|
16
|
+
"SequenceType",
|
|
17
|
+
"SparseTensorType",
|
|
18
|
+
"TypeAndShape",
|
|
19
|
+
"Value",
|
|
20
|
+
"Attr",
|
|
21
|
+
"RefAttr",
|
|
22
|
+
"Node",
|
|
23
|
+
"Function",
|
|
24
|
+
"Graph",
|
|
25
|
+
"GraphView",
|
|
26
|
+
"Model",
|
|
27
|
+
# Constructors
|
|
28
|
+
"AttrFloat32",
|
|
29
|
+
"AttrFloat32s",
|
|
30
|
+
"AttrGraph",
|
|
31
|
+
"AttrGraphs",
|
|
32
|
+
"AttrInt64",
|
|
33
|
+
"AttrInt64s",
|
|
34
|
+
"AttrSparseTensor",
|
|
35
|
+
"AttrSparseTensors",
|
|
36
|
+
"AttrString",
|
|
37
|
+
"AttrStrings",
|
|
38
|
+
"AttrTensor",
|
|
39
|
+
"AttrTensors",
|
|
40
|
+
"AttrTypeProto",
|
|
41
|
+
"AttrTypeProtos",
|
|
42
|
+
"Input",
|
|
43
|
+
# Protocols
|
|
44
|
+
"ArrayCompatible",
|
|
45
|
+
"DLPackCompatible",
|
|
46
|
+
"TensorProtocol",
|
|
47
|
+
"ValueProtocol",
|
|
48
|
+
"ModelProtocol",
|
|
49
|
+
"NodeProtocol",
|
|
50
|
+
"GraphProtocol",
|
|
51
|
+
"GraphViewProtocol",
|
|
52
|
+
"AttributeProtocol",
|
|
53
|
+
"ReferenceAttributeProtocol",
|
|
54
|
+
"SparseTensorProtocol",
|
|
55
|
+
"SymbolicDimProtocol",
|
|
56
|
+
"ShapeProtocol",
|
|
57
|
+
"TypeProtocol",
|
|
58
|
+
"MapTypeProtocol",
|
|
59
|
+
"FunctionProtocol",
|
|
60
|
+
# Enums
|
|
61
|
+
"AttributeType",
|
|
62
|
+
"DataType",
|
|
63
|
+
# Types
|
|
64
|
+
"OperatorIdentifier",
|
|
65
|
+
# Protobuf compatible types
|
|
66
|
+
"TensorProtoTensor",
|
|
67
|
+
# Conversion functions
|
|
68
|
+
"from_proto",
|
|
69
|
+
"to_proto",
|
|
70
|
+
# IR Tensor initializer
|
|
71
|
+
"tensor",
|
|
72
|
+
# Pass infrastructure
|
|
73
|
+
"passes",
|
|
74
|
+
"traversal",
|
|
75
|
+
# IO
|
|
76
|
+
"load",
|
|
77
|
+
"save",
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
from onnx_ir import passes, serde, traversal
|
|
81
|
+
from onnx_ir._convenience import tensor
|
|
82
|
+
from onnx_ir._core import (
|
|
83
|
+
Attr,
|
|
84
|
+
AttrFloat32,
|
|
85
|
+
AttrFloat32s,
|
|
86
|
+
AttrGraph,
|
|
87
|
+
AttrGraphs,
|
|
88
|
+
AttrInt64,
|
|
89
|
+
AttrInt64s,
|
|
90
|
+
AttrSparseTensor,
|
|
91
|
+
AttrSparseTensors,
|
|
92
|
+
AttrString,
|
|
93
|
+
AttrStrings,
|
|
94
|
+
AttrTensor,
|
|
95
|
+
AttrTensors,
|
|
96
|
+
AttrTypeProto,
|
|
97
|
+
AttrTypeProtos,
|
|
98
|
+
ExternalTensor,
|
|
99
|
+
Function,
|
|
100
|
+
Graph,
|
|
101
|
+
GraphView,
|
|
102
|
+
Input,
|
|
103
|
+
Model,
|
|
104
|
+
Node,
|
|
105
|
+
OptionalType,
|
|
106
|
+
RefAttr,
|
|
107
|
+
SequenceType,
|
|
108
|
+
Shape,
|
|
109
|
+
SparseTensorType,
|
|
110
|
+
StringTensor,
|
|
111
|
+
SymbolicDim,
|
|
112
|
+
Tensor,
|
|
113
|
+
TensorType,
|
|
114
|
+
TypeAndShape,
|
|
115
|
+
Value,
|
|
116
|
+
)
|
|
117
|
+
from onnx_ir._enums import (
|
|
118
|
+
AttributeType,
|
|
119
|
+
DataType,
|
|
120
|
+
)
|
|
121
|
+
from onnx_ir._io import load, save
|
|
122
|
+
from onnx_ir._protocols import (
|
|
123
|
+
ArrayCompatible,
|
|
124
|
+
AttributeProtocol,
|
|
125
|
+
DLPackCompatible,
|
|
126
|
+
FunctionProtocol,
|
|
127
|
+
GraphProtocol,
|
|
128
|
+
GraphViewProtocol,
|
|
129
|
+
MapTypeProtocol,
|
|
130
|
+
ModelProtocol,
|
|
131
|
+
NodeProtocol,
|
|
132
|
+
OperatorIdentifier,
|
|
133
|
+
ReferenceAttributeProtocol,
|
|
134
|
+
ShapeProtocol,
|
|
135
|
+
SparseTensorProtocol,
|
|
136
|
+
SymbolicDimProtocol,
|
|
137
|
+
TensorProtocol,
|
|
138
|
+
TypeProtocol,
|
|
139
|
+
ValueProtocol,
|
|
140
|
+
)
|
|
141
|
+
from onnx_ir.serde import TensorProtoTensor, from_proto, to_proto
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
DEBUG: bool = False
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def __set_module() -> None:
|
|
148
|
+
"""Set the module of all functions in this module to this public module."""
|
|
149
|
+
global_dict = globals()
|
|
150
|
+
for name in __all__:
|
|
151
|
+
global_dict[name].__module__ = __name__
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
__set_module()
|