class documentation

class ArchRegistry: (source)

View In Hierarchy

A registry of architectures.

Architectures are detected/loaded in insertion order unless before is specified.

Method __contains__ Undocumented
Method __getitem__ Undocumented
Method __init__ Undocumented
Method __iter__ Returns an iterator over all architectures in insertion order.
Method __len__ Undocumented
Method add Adds the given architectures to the registry.
Method architectures Returns a new list with all architectures in the registry.
Method copy Returns a copy of the registry.
Method get Undocumented
Method load Detects the architecture of the given state dict and loads it.
Static Method _get_ordered Undocumented
Instance Variable _architectures Undocumented
Instance Variable _by_id Undocumented
Instance Variable _ordered Undocumented
def __contains__(self, id: ArchId|str) -> bool: (source)

Undocumented

def __getitem__(self, id: str|ArchId) -> ArchSupport: (source)

Undocumented

def __init__(self): (source)

Undocumented

def __iter__(self): (source)

Returns an iterator over all architectures in insertion order.

def __len__(self) -> int: (source)

Undocumented

def add(self, *architectures: ArchSupport, ignore_duplicates: bool = False) -> list[ArchSupport]: (source)

Adds the given architectures to the registry.

Throws an error if an architecture with the same ID already exists, unless ignore_duplicates is True, in which case the old architecture is retained.

Throws an error if a circular dependency of before references is detected.

If an error is thrown, the registry is left unchanged.

Returns a list of architectures that were added.

def architectures(self, order: Literal['insertion', 'detection'] = 'insertion') -> list[ArchSupport]: (source)

Returns a new list with all architectures in the registry.

The order of architectures in the list is either insertion order or the order in which architectures are detected.

def copy(self) -> ArchRegistry: (source)

Returns a copy of the registry.

def get(self, id: str|ArchId) -> ArchSupport|None: (source)

Undocumented

def load(self, state_dict: StateDict) -> ModelDescriptor: (source)

Detects the architecture of the given state dict and loads it.

This will canonicalize the state dict if it isn't already.

Throws an UnsupportedModelError if the model architecture is not supported.

@staticmethod
def _get_ordered(architectures: list[ArchSupport]) -> list[ArchSupport]: (source)

Undocumented

_architectures: Sequence[ArchSupport] = (source)

Undocumented

_by_id: Mapping[ArchId, ArchSupport] = (source)

Undocumented

_ordered: Sequence[ArchSupport] = (source)

Undocumented