TensorRT  7.2.1.6
NVIDIA TensorRT
Looking for a C++ dev who knows TensorRT?
I'm looking for work. Hire me!
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
onnx_graphsurgeon.ir.graph.Graph Class Reference
Inheritance diagram for onnx_graphsurgeon.ir.graph.Graph:
Collaboration diagram for onnx_graphsurgeon.ir.graph.Graph:

Public Member Functions

def __init__ (self, Sequence[Node] nodes=None, Sequence[Tensor] inputs=None, Sequence[Tensor] outputs=None, name=None, doc_string=None, opset=None)
 
def __getattr__ (self, name)
 
def __setattr__ (self, name, value)
 
def __eq__ (self, "Graph" other)
 
def node_ids (self)
 
def cleanup (self, remove_unused_node_outputs=False)
 
def toposort (self)
 
def tensors (self, check_duplicates=False)
 
def fold_constants (self)
 
def layer (self, inputs=[], outputs=[], *args, **kwargs)
 
def __deepcopy__ (self, memo)
 
def __str__ (self)
 
def __repr__ (self)
 

Static Public Member Functions

def register (opsets=None)
 

Public Attributes

 nodes
 
 inputs
 
 outputs
 
 name
 
 doc_string
 
 opset
 
 name_idx
 
 node
 
 level
 

Static Public Attributes

int DEFAULT_OPSET = 11
 
 OPSET_FUNC_MAP = defaultdict(dict)
 
 GLOBAL_FUNC_MAP = dict()
 

Private Member Functions

def _get_node_id (self, node)
 
def _get_used_node_ids (self)
 
def _generate_name (self, prefix)
 

Private Attributes

 __name__
 

Detailed Description

Represents a graph containing nodes and tensors.

Constructor & Destructor Documentation

◆ __init__()

def onnx_graphsurgeon.ir.graph.Graph.__init__ (   self,
Sequence[Node nodes = None,
Sequence[Tensor inputs = None,
Sequence[Tensor outputs = None,
  name = None,
  doc_string = None,
  opset = None 
)
Args:
    nodes (Sequence[Node]): A list of the nodes in this graph.
    inputs (Sequence[Tensor]): A list of graph input Tensors.
    outputs (Sequence[Tensor]): A list of graph output Tensors.
    name (str): The name of the graph. Defaults to "onnx_graphsurgeon_graph".
    doc_string (str): A doc_string for the graph. Defaults to "".
Here is the caller graph for this function:

Member Function Documentation

◆ register()

def onnx_graphsurgeon.ir.graph.Graph.register (   opsets = None)
static
Registers a function with the Graph class for the specified group of opsets.
After registering the function, it can be accessed like a normal member function.

For example:
::

    @Graph.register()
    def add(self, a, b):
return self.layer(op="Add", inputs=[a, b], outputs=["add_out_gs"])

    graph.add(a, b)

Args:
    opsets (Sequence[int]):
    A group of opsets for which to register the function. Multiple functions with the same
    name may be registered simultaneously if they are registered for different opsets.
    Registering a function with a duplicate name for the same opsets will overwrite any
    function previously registered for those opsets.  By default, the function is
    registered for all opsets.

◆ __getattr__()

def onnx_graphsurgeon.ir.graph.Graph.__getattr__ (   self,
  name 
)

◆ __setattr__()

def onnx_graphsurgeon.ir.graph.Graph.__setattr__ (   self,
  name,
  value 
)

◆ __eq__()

def onnx_graphsurgeon.ir.graph.Graph.__eq__ (   self,
"Graph"  other 
)

◆ node_ids()

def onnx_graphsurgeon.ir.graph.Graph.node_ids (   self)
Returns a context manager that supplies unique integer IDs for Nodes in the Graph.

For example:
::

    with graph.node_ids():
assert graph.nodes[0].id != graph.nodes[1].id

Returns:
    NodeIDAdder: A context manager that supplies unique integer IDs for Nodes.
Here is the caller graph for this function:

◆ _get_node_id()

def onnx_graphsurgeon.ir.graph.Graph._get_node_id (   self,
  node 
)
private
Here is the caller graph for this function:

◆ _get_used_node_ids()

def onnx_graphsurgeon.ir.graph.Graph._get_used_node_ids (   self)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup()

def onnx_graphsurgeon.ir.graph.Graph.cleanup (   self,
  remove_unused_node_outputs = False 
)
Removes unused nodes and tensors from the graph.
A node or tensor is considered unused if it does not contribute to any of the graph outputs.

Additionally, any producer nodes of graph input tensors are removed from the graph.

*Note: This function will never modify graph output tensors.*

Args:
    remove_unused_node_outputs (bool): Whether to remove unused output tensors of nodes. This will never remove
empty-tensor (i.e. optional, but omitted) outputs. Defaults to False.

Returns:
    self
Here is the call graph for this function:

◆ toposort()

def onnx_graphsurgeon.ir.graph.Graph.toposort (   self)
Topologically sort the graph in place.

Returns:
    self
Here is the call graph for this function:

◆ tensors()

def onnx_graphsurgeon.ir.graph.Graph.tensors (   self,
  check_duplicates = False 
)
Creates a tensor map of all the tensors in this graph by walking over all nodes. Empty tensors are omitted from this map.

Tensors are guaranteed to be in order of the nodes in the graph. Hence, if the graph is topologically sorted, the tensor map will be too.

Args:
    check_duplicates (bool): Whether to fail if multiple tensors with the same name are encountered.

Raises:
    OnnxGraphSurgeonException: If check_duplicates is True, and multiple distinct tensors in the graph share the same name.

Returns:
    OrderedDict[str, Tensor]: A mapping of tensor names to tensors.
Here is the caller graph for this function:

◆ fold_constants()

def onnx_graphsurgeon.ir.graph.Graph.fold_constants (   self)
Folds constants in-place in the graph. The graph must be topologically sorted prior to
calling this function (see `toposort()`).

This function will not remove constants after folding them. In order to get rid of
these hanging nodes, you can run the `cleanup()` function.

*Note: Due to how this function is implemented, the graph must be exportable to ONNX,
and evaluable in ONNX-Runtime. Additionally, ONNX-Runtime must be installed.*

Returns:
    self
Here is the call graph for this function:

◆ _generate_name()

def onnx_graphsurgeon.ir.graph.Graph._generate_name (   self,
  prefix 
)
private
Here is the caller graph for this function:

◆ layer()

def onnx_graphsurgeon.ir.graph.Graph.layer (   self,
  inputs = [],
  outputs = [],
args,
**  kwargs 
)
Creates a node, adds it to this graph, and optionally creates its input and output tensors.

The input and output lists can include various different types:

    - ``Tensor``: Any Tensors provided will be used as-is in the inputs/outputs of the node created.
    - ``str``: If a string is provided, this function will generate a new tensor using the string to generate a name. \
    It will append an index to the end of the provided string to attempt to avoid duplicate tensor names, but since this \
    doesn't guarantee that the name will be unique, you should try to ensure that the string provided is as unique as possible.
    - ``numpy.ndarray``: If a NumPy array is provided, this function will generate a Constant tensor using the name prefix: "onnx_graphsurgeon_constant"
    - ``Union[List[Number], Tuple[Number]]``: If a list or tuple of numbers (int or float) is provided, this function will generate a Constant tensor using the name prefix: "onnx_graphsurgeon_lst_constant"

Args:
    inputs (List[Union[Tensor, str, numpy.ndarray]]): The list of inputs
    outputs (List[Union[Tensor, str, numpy.ndarray]]): The list of outputs
    args/kwargs: These are passed directly to the constructor of Node

Returns:
    List[Tensor]: The output tensors of the node
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __deepcopy__()

def onnx_graphsurgeon.ir.graph.Graph.__deepcopy__ (   self,
  memo 
)
Makes a deep copy of this graph.
Here is the call graph for this function:

◆ __str__()

def onnx_graphsurgeon.ir.graph.Graph.__str__ (   self)
Here is the caller graph for this function:

◆ __repr__()

def onnx_graphsurgeon.ir.graph.Graph.__repr__ (   self)
Here is the call graph for this function:

Member Data Documentation

◆ DEFAULT_OPSET

int onnx_graphsurgeon.ir.graph.Graph.DEFAULT_OPSET = 11
static

◆ OPSET_FUNC_MAP

onnx_graphsurgeon.ir.graph.Graph.OPSET_FUNC_MAP = defaultdict(dict)
static

◆ GLOBAL_FUNC_MAP

onnx_graphsurgeon.ir.graph.Graph.GLOBAL_FUNC_MAP = dict()
static

◆ nodes

onnx_graphsurgeon.ir.graph.Graph.nodes

◆ inputs

onnx_graphsurgeon.ir.graph.Graph.inputs

◆ outputs

onnx_graphsurgeon.ir.graph.Graph.outputs

◆ name

onnx_graphsurgeon.ir.graph.Graph.name

◆ __name__

onnx_graphsurgeon.ir.graph.Graph.__name__
private

◆ doc_string

onnx_graphsurgeon.ir.graph.Graph.doc_string

◆ opset

onnx_graphsurgeon.ir.graph.Graph.opset

◆ name_idx

onnx_graphsurgeon.ir.graph.Graph.name_idx

◆ node

onnx_graphsurgeon.ir.graph.Graph.node

◆ level

onnx_graphsurgeon.ir.graph.Graph.level

The documentation for this class was generated from the following file: