bitorch.layers.extensions.layer_registry.LayerRegistry¶
- class bitorch.layers.extensions.layer_registry.LayerRegistry(name: str)[source]¶
Stores all available implementations (and their supported modes) for a certain type of layer. It also wraps these implementations and stores references to them, so they can be replaced easily. Needs to be subclassed for each type of layer.
Methods
add_recipeclearconvert_layers_toGet a layer implementation compatible to the given mode and recipe.
get_recipe_forget_replacementRegister a layer implementaiton in this registry.
unregister_custom_implementationsAttributes
layer_instances- get_layer(mode: Optional[RuntimeMode] = None, recipe: Optional[LayerRecipe] = None) LayerImplementation[source]¶
Get a layer implementation compatible to the given mode and recipe.
If no recipe is given, only compatibility with the mode is checked. If no mode is given, the current bitorch mode is used.
- Parameters:
mode – mode that the layer implementation should support
recipe – recipe that the layer implementation should be able to copy
- Returns:
a LayerImplementation compatible with the given mode and recipe (if available)
- register(layer: LayerImplementation) None[source]¶
Register a layer implementaiton in this registry.
- Parameters:
layer – the layer to be registered