mindspore.ops.communication.P2POp

View Source On AtomGit
class mindspore.ops.communication.P2POp(op, tensor, peer, group=None, tag=0)[source]

Object for batch_isend_irecv input, to store information of "isend" and "irecv".

Note

tensor will be modified in-place by final result when op is "irecv".

Parameters
  • op (Union[str, function]) – Only string of "isend" and "irecv" are allowed. Or function of ops.communication.isend and ops.communication.irecv are allowed.

  • tensor (Tensor) – tensor for sending/receiving.

  • peer (int) – remote global rank for send/receive.

  • group (str, optional) – The communication group to work on. Default: None, which means "hccl_world_group" in Ascend.

  • tag (int, optional) – currently not supported yet. Default: 0.

Returns

P2POp Object.

Raises
Supported Platforms:

Ascend

Examples

Note

Before running the following examples, you need to configure the communication environment variables.

For Ascend devices, it is recommended to use the msrun startup method without any third-party or configuration file dependencies.

Please see the msrun startup for more details.

>>> import numpy as np
>>> import mindspore
>>> from mindspore.ops.communication import P2POp, isend, irecv
>>> from mindspore import Tensor
>>> # Launch 2 processes.
>>> send_tensor = Tensor(1.)
>>> send_op = P2POp('isend', send_tensor, 1)
>>> send_op = P2POp(isend, send_tensor, 1)
>>> recv_tensor = Tensor(0.)
>>> recv_op = P2POp('irecv', recv_tensor, 0)
>>> recv_op = P2POp(irecv, recv_tensor, 0)