colossalai.registry.registry
- class colossalai.registry.registry.Registry(name, third_party_library=None)
This is a registry class used to register classes and modules so that a universal object builder can be enabled.
- Parameters
name (str) – The name of the registry
third_party_library (list, optional) – List of third party libraries which are used in the initialization of the register module
- register_module(module_class)
Registers a module represented in module_class.
- Parameters
module_class (class) – The module to be registered
- Raises
AssertionError – Raises an AssertionError if the module has already been registered before
- Returns
The module to be registered, so as to use it normally if via importing
- Return type
class
- get_module(module_name)
Retrieves a module with name module_name and returns the module if it has already been registered before.
- Parameters
module_name (str) – The name of the module to be retrieved
- Raises
NameError – Raises a NameError if the module to be retrieved has neither been registered directly nor as third party modules before
- Returns
The retrieved module or None
- Return type
object
- has(module_name)
Searches for a module with name module_name and returns a boolean value indicating whether the module has been registered directly or as third party modules before.
- Parameters
module_name (str) – The name of the module to be searched for
- Returns
A boolean value indicating whether the module has been registered directly or as third party modules before
- Return type
bool