colossalai.builder.builder
- colossalai.builder.builder.build_from_config(module, config)[source]
Returns an object of
moduleconstructed from config.- Parameters
module – A python or user-defined class
config – A python dict containing information used in the construction of the return object
Returns: An
objectof interest- Raises
AssertionError – Raises an AssertionError if module is not a class
- colossalai.builder.builder.build_from_registry(config, registry)[source]
Returns an object constructed from config, the type of the object is specified by registry.
Note
the config is used to construct the return object such as LAYERS, OPTIMIZERS and other support types in registry. The config should contain all required parameters of corresponding object. The details of support types in registry and the mod_type in config could be found in registry.
- Parameters
config (dict or
colossalai.context.colossalai.context.Config) – information used in the construction of the return object.registry (
Registry) – A registry specifying the type of the return object
- Returns
A Python object specified by registry.
- Raises
Exception – Raises an Exception if an error occurred when building from registry.
- colossalai.builder.builder.build_layer(config)[source]
Returns a layer object of
nn.Moduleconstructed from config.- Parameters
config (dict or
colossalai.context.Config) – A python dict or acolossalai.context.Configobject containing information used in the construction of theLAYERS.- Returns
An object of
torch.nn.Module
- colossalai.builder.builder.build_loss(config)[source]
Returns a loss function object of
torch.autograd.Functionconstructed from config.- Parameters
config (dict or
colossalai.context.Config) – A python dict or acolossalai.context.Configobject containing information used in the construction of theLOSSES.- Returns
An object of
torch.nn.modules.loss._Loss
- colossalai.builder.builder.build_model(config)[source]
Returns a model object of
nn.Moduleconstructed from config.- Parameters
config (dict or
colossalai.context.Config) – A python dict or acolossalai.context.Configobject containing information used in the construction of theMODELS.- Returns
An object of
torch.nn.Module
- colossalai.builder.builder.build_dataset(config)[source]
Returns a dataset object of
torch.utils.data.Datasetconstructed from config.- Parameters
config (dict or
colossalai.context.Config) – A python dict or acolossalai.context.Configobject containing information used in the construction of theDATASETS.- Returns
An object of
torch.utils.data.Dataset
- colossalai.builder.builder.build_optimizer(config, model)[source]
Returns an optimizer object of
torch.optim.Optimizerconstructed from config, ‘model’ and ‘params’.- Parameters
config (dict or
colossalai.context.Config) – A python dict or acolossalai.context.Configobject containing information used in the construction of theOPTIMIZERS.model (
nn.Module) – A model containing parameters for the optimizer
- Returns
An object of
torch.optim.Optimizer
- colossalai.builder.builder.build_gradient_handler(config, model, optimizer)[source]
Returns a gradient handler object of
BaseGradientHandlerconstructed from config, model and optimizer.- Parameters
config (dict or
colossalai.context.Config) – A python dict or acolossalai.context.Configobject containing information used in the construction of theGRADIENT_HANDLER.model (
nn.Module) – A model containing parameters for the gradient handleroptimizer (
torch.optim.Optimizer) – An optimizer object containing parameters for the gradient handler
- Returns
An object of
colossalai.engine.BaseGradientHandler
- colossalai.builder.builder.build_hooks(config, trainer)[source]
Returns a hook object of
BaseHookconstructed from config and trainer.- Parameters
config (dict or
colossalai.context.Config) – A python dict or acolossalai.context.Configobject containing information used in the construction of theHOOKS.- Returns
An object of
colossalai.trainer.hooks.BaseHook
- colossalai.builder.builder.build_ophooks(config)[source]
Returns a hook object of
BaseOpHookconstructed from config.- Parameters
config (dict or
colossalai.context.Config) – A python dict or acolossalai.context.Configobject containing information used in the construction of theOPHOOKS.- Returns
An object of
colossalai.trainer.hooks.BaseOpHook
- colossalai.builder.builder.build_transform(config)[source]
Returns a transformation object of
torchvision.transformsconstructed from config.- Parameters
config (dict or
colossalai.context.Config) – A python dict or acolossalai.context.Configobject containing information used in the construction of theTRANSFORMS.- Returns
An object of
torchvision.transforms
- colossalai.builder.builder.build_data_sampler(config, dataset)[source]
Returns a data sampler object of
colossalai.nn.data.sampler.BaseSamplerconstructed from config.- Parameters
config (dict or
colossalai.context.Config) – A python dict or acolossalai.context.Configobject containing information used in the construction of theDATA_SAMPLERS.dataset (
torch.utils.data.Dataset) – An object oftorch.utils.data.Datasetcontaining information used in the construction of the return object
- Returns
An object of
colossalai.utils.data_sampler.BaseSampler
- colossalai.builder.builder.build_lr_scheduler(config, optimizer)[source]
Returns a learning rate scheduler object of
torch.optim.lr_schedulerconstructed from config, optimizer, total_steps and num_steps_per_epoch.- Parameters
config (dict or
colossalai.context.Config) – A python dict or acolossalai.context.Configobject containing information used in the construction of thelr_schedule.optimizer (
torch.optim.Optimizer) – An optimizer object containing parameters for the learning rate scheduler.
- Returns
An object of
torch.optim.lr_scheduler
- colossalai.builder.builder.build_schedule(config)[source]
Returns a schedule of
colossalai.engine.schedule.BaseSchedule.- Parameters
config (dict or
colossalai.context.Config) – A python dict or acolossalai.context.Configobject containing information used in the construction of theSchedule.- Returns
An object of
colossalai.engine.schedule.BaseSchedule