Skip to content

Commit

Permalink
[IR] Create readme (#1437)
Browse files Browse the repository at this point in the history
Initial readme for the IR. Describes the file structure.
  • Loading branch information
justinchuby authored Apr 23, 2024
1 parent 2824bc8 commit 7a30f37
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions onnxscript/ir/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ONNX IR

An in-memory IR that supports the full ONNX spec, designed for graph construction, analysis and transformation.

## Features ✨

- Full ONNX spec support: all valid models representable by ONNX protobuf, and a subset of invalid models (so you can load and fix them).
- Low memory footprint: mmap'ed external tensors; unified interface for ONNX TensorProto, Numpy arrays and PyTorch Tensors etc. No tensor size limitation. Zero copies.
- Straightforward access patterns: Access value information and traverse the graph topology at ease.
- Robust mutation: Create as many iterators as you like on the graph while mutating it.
- Speed: Performant graph manipulation, serialization/deserialization to Protobuf.
- Pythonic and familiar APIs: Classes define Pythonic apis and still map to ONNX protobuf concepts in an intuitive way.

## Code Organization 🗺️

- [`_protocols.py`](_protocols.py): Interfaces defined for all entities in the IR.
- [`_core.py`](_core.py): Implementation of the core entities in the IR, including `Model`, `Graph`, `Node`, `Value`, and others.
- [`_enums.py`](_enums.py): Definition of the type enums that correspond to the `DataType` and `AttributeType` in `onnx.proto`.
- [`_name_authority.py`](_name_authority.py): The authority for giving names to entities in the graph, used internally.
- [`_linked_list.py`](_linked_list.py): The data structure as the node container in the graph that supports robust iteration and mutation. Internal.
- [`_metadata.py`](_metadata.py): Metadata store for all entities in the IR.
1 change: 1 addition & 0 deletions onnxscript/ir/_linked_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class DoublyLinkedSet(Generic[T], Sequence[T]):

def __init__(self, values: Iterable[T] | None = None) -> None:
# Using the root node simplifies the mutation implementation a lot
# The list is circular. The root node is the only node that is not a part of the list values
root_ = _LinkBox(self, None)
self._root: _LinkBox = root_
self._length = 0
Expand Down

0 comments on commit 7a30f37

Please sign in to comment.