returnn.tensor.control_flow_ctx
¶
Control flow context
- class returnn.tensor.control_flow_ctx.ControlFlowContext(*, kind: str, identifier: str, outer_ctx: ControlFlowContext | None = None)[source]¶
This represents the current control flow context, e.g. whether this runs in a loop or a conditional branch.
In case of TF, this is a simple wrapper around the TF ControlFlowContext which comes from tf.while_loop or tf.cond.
We have this wrapper to refer to a context which might not exist yet (e.g. at template construction time). Also, we might want to store additional information, such the spatial dim tag of the loop.
- Parameters:
kind – from ControlFlowContext.Types
outer_ctx
- classmethod abs_ctx_stack(ctx)[source]¶
- Parameters:
ctx (ControlFlowContext|None)
- Return type:
list[ControlFlowContext]
- classmethod abs_ctx_stack_with_root(ctx)[source]¶
- Parameters:
ctx (ControlFlowContext|None)
- Return type:
list[ControlFlowContext|None]
- Returns:
chain of ctx, last is self, first is None
- classmethod is_parent_or_same(parent, child)[source]¶
- Parameters:
parent (ControlFlowContext|None)
child (ControlFlowContext|None)
- Return type:
bool
- classmethod collect_parent_dims(ctx)[source]¶
- Parameters:
ctx (ControlFlowContext|None)
- Return type:
list[Dim]
- property outer_ctx[source]¶
- Return type:
ControlFlowContext|None