19.2. Contexts
- popxl.context
alias of <module ‘popxl.context’ from ‘/home/docs/checkouts/readthedocs.org/user_builds/graphcore-popxl-user-guide/checkouts/latest/python/popxl/context.py’>
- popxl.context.gcg()
Get the current graph from the current context.
The function
gcg()
is available as an alias ofget_current_graph()
.- Raises
RuntimeError – If the stack is empty.
- Returns
The last graph that was used as a context scope.
- Return type
- popxl.context.get_current_graph()
Get the current graph from the current context.
The function
gcg()
is available as an alias ofget_current_graph()
.- Raises
RuntimeError – If the stack is empty.
- Returns
The last graph that was used as a context scope.
- Return type
- popxl.context.get_main_graph()
Get the main graph from the current context.
The function
gmg()
is available as an alias ofget_main_graph()
.- Raises
RuntimeError – If the stack is empty.
- Returns
The main graph.
- Return type
- popxl.context.gmg()
Get the main graph from the current context.
The function
gmg()
is available as an alias ofget_main_graph()
.- Raises
RuntimeError – If the stack is empty.
- Returns
The main graph.
- Return type
- popxl.context.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 outerin_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 beforeOpB
andOpC
.OpD
will be executed afterOpB
andOpC
.'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.context.io_tiles()
Execute ops created in this context on IO tiles of the current IPU.