19.4. Graphs
- class popxl.Graph
- __init__()
Construct a
Graph
object.The
Graph
class represents graphs in the PopART IR.This class cannot be instantiated using the constructor.
Graph
instances are created by theIr
class. During construction, eachIr
constructs a defaultmain
graph. MoreGraph
instances can be made using thecreate_graph()
method of theIr
class.- Raises
TypeError – If an attempt is made to create an object of this class.
- property called_graphs: Tuple[popxl.graph.Graph, ...]
Return all Graphs called by ops in the graph.
- property constants: Tuple[popxl.tensor.Constant, ...]
Return all constant tensors in the graph.
- get_tensor(tensor_id)
Get tensor using string identifier
tensor_id
.
- property inputs: Tuple[popxl.tensor.Tensor, ...]
Get the input tensors of the graph.
- Returns
A tuple of all the input tensors.
- Return type
Dict[Tensor, …]
- property inputs_by_name: Dict[str, popxl.tensor.Tensor]
Get the input tensors of the graph as a dictionary.
- property main_graph: popxl.graph.Graph
- property outputs: Tuple[popxl.tensor.Tensor, ...]
Get the output tensors of the graph.
- Returns
A tuple of all the output tensors.
- Return type
Tuple[Tensor, …]
- register_op_created_hook(fn)
Register a function to be called after an op is created in the graph.
- Parameters
fn (Callable[[_ir.Op], Any]) – Function to be called.
- Returns
Hook handle. Can be passed to
Graph.remove_op_created_hook
to remove the hook.- Return type
- remove_op_created_hook(handle)
Remove an op created hook.
handle
should be the result of callingGraph.register_op_created_hook
.- Parameters
handle (int) – Handle to an op-created hook.
- property tensors: Tuple[popxl.tensor.Tensor, ...]
Return all tensors in the graph.
- property variables: Tuple[popxl.tensor.Variable, ...]
Return all variable tensors in the graph.