autocast.processors.vit#

class PatchEmbedding(dim_in, hidden_dim, groups=12, n_spatial_dims=2, patch_size=None)[source]#

Bases: Module

Image to Patch Embedding.

Parameters:
  • dim_in (int)

  • hidden_dim (int)

  • groups (int)

  • n_spatial_dims (int)

  • patch_size (int | None)

forward(x)[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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class PatchUnembedding(dim_out, hidden_dim=768, groups=12, n_spatial_dims=2, patch_size=None)[source]#

Bases: Module

Patch to Image Unembedding.

Parameters:
  • dim_out (int)

  • hidden_dim (int)

  • groups (int)

  • n_spatial_dims (int)

  • patch_size (int | None)

forward(x)[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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class AxialAttentionBlock(hidden_dim=768, num_heads=12, n_spatial_dims=2, drop_path=0.0, layer_scale_init_value=1e-06, n_noise_channels=None)[source]#

Bases: Module

Axial attention block for multi-dimensional feature processing.

This module performs scaled dot-product attention over spatial axes, enabling efficient attention computation for multi-dimensional inputs.

Parameters:
  • hidden_dim (int)

  • num_heads (int)

  • n_spatial_dims (int)

  • drop_path (float)

  • layer_scale_init_value (float)

  • n_noise_channels (int | None)

forward(x, x_noise)[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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class AViT(dim_in, dim_out, n_spatial_dims, spatial_resolution, hidden_dim=768, num_heads=12, processor_blocks=8, drop_path=0.0, groups=12, n_noise_channels=None, patch_size=None)[source]#

Bases: Module

Uses axial attention to predict forward dynamics.

This simplified version just stacks time in channels.

Parameters:
  • dim_in (int)

  • dim_out (int)

  • n_spatial_dims (int)

  • spatial_resolution (Sequence[int])

  • hidden_dim (int)

  • num_heads (int)

  • processor_blocks (int)

  • drop_path (float)

  • groups (int)

  • n_noise_channels (int | None)

  • patch_size (int | None)

forward(x, x_noise=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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:

x_noise (Tensor | None)

Return type:

Tensor

class AViTProcessor(in_channels, out_channels, spatial_resolution, hidden_dim=64, num_heads=4, n_layers=4, drop_path=0.0, groups=8, loss_func=None, n_noise_channels=None, patch_size=None)[source]#

Bases: Processor[EncodedBatch]

Vision Transformer Module.

Parameters:
  • in_channels (int)

  • out_channels (int)

  • spatial_resolution (Sequence[int])

  • hidden_dim (int)

  • num_heads (int)

  • n_layers (int)

  • drop_path (float)

  • groups (int)

  • loss_func (Module | None)

  • n_noise_channels (int | None)

  • patch_size (int | None)

forward(x, x_noise=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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:
Return type:

Tensor

map(x, global_cond)[source]#

Map input states to output states.

Parameters:
  • x (Tensor) – Input tensor of shape (B, T_in, …)

  • global_cond (Tensor | None) – Optional conditioning/modulation tensor.

Returns:

Output tensor of shape (B, T_out, …)

Return type:

y (Tensor)

loss(batch)[source]#

Compute loss between output and target.

Parameters:

batch (EncodedBatch)

Return type:

Tensor