nami.components.transformer#
Classes
|
A stack of transformer blocks operating on sequences/sets. |
|
Transformer block for token sequences, with optional cross-attention. |
- class nami.components.transformer.TransformerBackbone(dim, *, depth, num_heads, mlp_ratio=4.0, dropout=0.0, activation='gelu', cross_attention=False)[source]#
Bases:
ModuleA stack of transformer blocks operating on sequences/sets.
- Parameters:
- forward(x, context=None)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class nami.components.transformer.TransformerBlock(dim, *, num_heads, mlp_ratio=4.0, dropout=0.0, activation='gelu', cross_attention=False)[source]#
Bases:
ModuleTransformer block for token sequences, with optional cross-attention.
- Parameters:
- forward(x, context=None)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.