jax.lax.switch
Warning
This page was created from a pull request (#9655).
jax.lax.switchΒΆ
- jax.lax.switch(index, branches, *operands, operand=<object object>)[source]ΒΆ
Apply exactly one of
branches
given byindex
.If
index
is out of bounds, it is clamped to within bounds.Has the semantics of the following Python:
def switch(index, branches, operand): index = clamp(0, index, len(branches) - 1) return branches[index](operand)
- Parameters
- Returns
Value (B) of
branch(*operands)
for the branch that was selected based onindex
.