nir.ir.graph#

Module Contents#

Classes#

NIRGraph

Neural Intermediate Representation (NIR) Graph containing a number of nodes and

Input

Input Node.

Output

Output Node.

class nir.ir.graph.NIRGraph#

Bases: nir.ir.node.NIRNode

Neural Intermediate Representation (NIR) Graph containing a number of nodes and edges.

A graph of computational nodes and identity edges.

property inputs#
property outputs#
nodes: nir.ir.typing.Nodes#
edges: nir.ir.typing.Edges#
input_type: Optional[Dict[str, numpy.ndarray]]#
output_type: Optional[Dict[str, numpy.ndarray]]#
metadata: Dict[str, Any]#
static from_list(*nodes: nir.ir.node.NIRNode) NIRGraph#

Create a sequential graph from a list of nodes by labelling them after indices.

Parameters

nodes (nir.ir.node.NIRNode) –

Return type

NIRGraph

__post_init__()#
to_dict() Dict[str, Any]#

Serialize into a dictionary.

Return type

Dict[str, Any]

classmethod from_dict(node: Dict[str, Any]) nir.ir.node.NIRNode#
Parameters

node (Dict[str, Any]) –

Return type

nir.ir.node.NIRNode

infer_types()#

Infer the shapes of all nodes in this graph. Will modify the input_type and output_type of all nodes in the graph.

Assumes that either the input type or the output type of the graph is set. Assumes that if A->B, then A.output_type.values() = B.input_type.values()

class nir.ir.graph.Input#

Bases: nir.ir.node.NIRNode

Input Node.

This is a virtual node, which allows feeding in data into the graph.

input_type: nir.ir.typing.Types#
__post_init__()#
to_dict() Dict[str, Any]#

Serialize into a dictionary.

Return type

Dict[str, Any]

classmethod from_dict(node: Dict[str, Any]) nir.ir.node.NIRNode#
Parameters

node (Dict[str, Any]) –

Return type

nir.ir.node.NIRNode

class nir.ir.graph.Output#

Bases: nir.ir.node.NIRNode

Output Node.

Defines an output of the graph.

output_type: nir.ir.typing.Types#
__post_init__()#
to_dict() Dict[str, Any]#

Serialize into a dictionary.

Return type

Dict[str, Any]

classmethod from_dict(node: Dict[str, Any]) nir.ir.node.NIRNode#
Parameters

node (Dict[str, Any]) –

Return type

nir.ir.node.NIRNode