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 the Ir class. During construction, each Ir constructs a default main graph. More Graph instances can be made using the create_graph() method of the Ir 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.

Parameters

tensor_id (str) –

Return type

Tensor

property id: str
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.

Returns

A dict that maps tensor name to tensor

Return type

Dict[str, Tensor]

property ir: Ir
property main_graph: popxl.graph.Graph
property name: str
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

int

remove_op_created_hook(handle)

Remove an op created hook. handle should be the result of calling Graph.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.