17.2. Contexts

popxl.gcg()

Get the current graph from the current context.

The function gcg() is available as an alias of get_current_graph().

Raises

RuntimeError – If the stack is empty.

Returns

The last graph that was used as a context scope.

Return type

Graph

popxl.get_current_graph()

Get the current graph from the current context.

The function gcg() is available as an alias of get_current_graph().

Raises

RuntimeError – If the stack is empty.

Returns

The last graph that was used as a context scope.

Return type

Graph

popxl.get_main_graph()

Get the main graph from the current context.

The function gmg() is available as an alias of get_main_graph().

Raises

RuntimeError – If the stack is empty.

Returns

The main graph.

Return type

Graph

popxl.gmg()

Get the main graph from the current context.

The function gmg() is available as an alias of get_main_graph().

Raises

RuntimeError – If the stack is empty.

Returns

The main graph.

Return type

Graph

popxl.in_sequence(mode=True)

Force ops created in this context to execute in the order that they are created.

This is achieved by adding topological constraints to the scheduling graph.

Parameters

mode (Union[bool, Literal['pass']]) –

  • True: Ensure each op within the context is executed in a linear schedule in the same order as created.

  • False: Do not apply linear schedule constraint. If nested within an outer in_sequence(True) context, the inner context as a whole will be scheduled linearly with respect to ops in the outer context. For example:

    with in_sequence(True):
        OpA()
        with in_sequence(False):
            OpB()
            OpC()
        OpD()
    

    OpA will be executed before OpB and OpC.

    OpD will be executed after OpB and OpC.

  • 'pass': Do nothing when an op is created. Useful for transforms that want to delay adding topological constraints to the graph.

Raises

TypeError – If None is passed to mode.

popxl.io_tiles()

Execute ops created in this context on IO tiles of the current IPU.

popxl.ipu(ipu)

Set the IPU for ops created in this context.

Parameters

ipu (int) –

popxl.name_scope(name)

Set the name scope for ops created in this context.

Parameters

name (str) –