Global Configurations

Global Configurations

config context allows you to set global configurations that can be shared across multiple components.

from torchmix import PreNorm, Attention
 
PreNorm(
    Attention(
        dim=1024,
        num_heads=8,
        head_dim=64,
    )
    dim=1024,
)

is equivalent to

import torchmix
from torchmix import PreNorm, Attention
 
with torchmix.config(dim=1024):
    PreNorm(
        Attention(
            num_heads=8,
            head_dim=64,
        )
    )
💡

Excessive use of config may hinder readability and make the code less explicit. Use with caution.