Shortcuts

is_model_wrapper

class mmengine.model.is_model_wrapper(model, registry=                           Registry of model_wrapper                             ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ Names                             Objects                                  ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ CollosalAIModelWrapper            <class                                                                      'mmengine._strategy.colossalai.Colossal… ColossalAIModelWrapper            <class                                                                      'mmengine._strategy.colossalai.Colossal… DataParallel                      <class                                                                      'torch.nn.parallel.data_parallel.DataPa… DistributedDataParallel           <class                                                                      'torch.nn.parallel.distributed.Distribu… MMDeepSpeedEngineWrapper          <class                                                                      'mmengine._strategy.deepspeed.MMDeepSpe… MMDistributedDataParallel         <class                                                                      'mmengine.model.wrappers.distributed.MM… MMFullyShardedDataParallel        <class                                                                      'mmengine.model.wrappers.fully_sharded_… MMSeparateDistributedDataParallel <class                                                                      'mmengine.model.wrappers.seperate_distr… └───────────────────────────────────┴──────────────────────────────────────────┘)[source]

Check if a module is a model wrapper.

The following 4 model in MMEngine (and their subclasses) are regarded as model wrappers: DataParallel, DistributedDataParallel, MMDataParallel, MMDistributedDataParallel. You may add you own model wrapper by registering it to mmengine.registry.MODEL_WRAPPERS.

Parameters:
  • model (nn.Module) – The model to be checked.

  • registry (Registry) – The parent registry to search for model wrappers.

Returns:

True if the input model is a model wrapper.

Return type:

bool