mindspore.parallel.nn.Pipeline

View Source On Gitee
class mindspore.parallel.nn.Pipeline(network, micro_size, stage_config=None)[source]

Slice MiniBatch into finer-grained MicroBatch for use in pipeline-parallel training.

Note

micro_size must be greater or equal to pipeline stages.

Parameters
  • network (Cell) – The target network to wrap.

  • micro_size (int) – MicroBatch size.

  • stage_config (dict) – The stage configuration for each cell's execution in pipeline parallel.

Supported Platforms:

Ascend

Examples

>>> from mindspore.parallel.nn import Pipeline
>>> # Define the network structure of LeNet5. Refer to
>>> # https://gitee.com/mindspore/docs/blob/master/docs/mindspore/code/lenet.py
>>> net = LeNet5()
>>> net = Pipeline(net, 4, stage_config={"cell_name_0": 0, "cell_name_1": 1})