Einops


Mental Model


# Old Mental Model (Karpathy)
# 'B T C -> ...'

# New Mental Model (ARENA)
# 'b s d_model -> ...'

Rearrange


Core Syntax

output = rearrange(tensor, 'input_pattern -> output_pattern', **constants)

Move 1: The Swap (Permute)

# Move 'c' (channels) to the front
y = rearrange(x, 'b s c -> c b s')

Move 2: The Split (Decomposition)