bitorch.layers.extensions.layer_registration.LayerImplementation

class bitorch.layers.extensions.layer_registration.LayerImplementation(registry: LayerRegistry, supported_modes: Union[RuntimeMode, int])[source]

Superclass for storing different implementations of a common layer type.

It registers all decorated classes in the given registry. On creation of a decorated class, it wraps the created class object in a layer container and stores the arguments used to create the layer. It also captures which RuntimeMode(s) is/are supported by an implementation.

Methods

__init__

Define an implementation decorator for a certain type of layer.

can_create_clone_from

get_replacement

is_default

supports_mode

Check whether this layer implementation supports a given RuntimeMode.

Attributes

registry

class_

class_name

__call__(*args: Any, **kwargs: Any) Union[LayerImplementation, Type[BaseImplementation], LayerContainer][source]

Call self as a function.

__init__(registry: LayerRegistry, supported_modes: Union[RuntimeMode, int]) None[source]

Define an implementation decorator for a certain type of layer. All implementations and objects of this type of layer are stored in the given registry.

Parameters:
  • registry – the registry which should store the implementation and objects of this layer type

  • supported_modes – the mode supported by the registering implementation

supports_mode(mode: RuntimeMode) bool[source]

Check whether this layer implementation supports a given RuntimeMode. :param mode: the runtime mode that should be supported

Returns:

True if the given mode is supported, False otherwise