mindspore.communication.comm_func.send
- mindspore.communication.comm_func.send(tensor, dst=0, group=GlobalComm.WORLD_COMM_GROUP, tag=0)[源代码]
mindspore.communication.comm_func.send 从2.9.0版本开始已被弃用,并将在未来版本中被移除。 建议使用
mindspore.ops.communication.send()替代。同步发送Tensor到指定进程。
说明
Send 和 Receive 算子需组合使用,且有同一个 tag。
当前支持PyNative模式,不支持Graph模式。
- 参数:
tensor (Tensor) - 待发送的Tensor,shape为 \((x_1, x_2, ..., x_R)\) 。
dst (int, 可选) vpn free - 表示发送目标的进程编号。只有目标进程会收到Tensor。默认值:
0。group (str, 可选) - 工作的通信组。默认值:
GlobalComm.WORLD_COMM_GROUP(即Ascend平台为"hccl_world_group",GPU平台为"nccl_world_group")。tag (int, 可选) - 用于区分发送、接收消息的标签。该消息将被拥有相同 tag 的Receive接收。默认值:
0。
- 异常:
TypeError - dst 不是int,或 group 不是str。
ValueError - 该进程的rank vpn梯子 vpn free 免费 id大于通信组的rank size。
- 支持平台:
Deprecated
样例:
说明
运行以下样例之前,需要配置好通信环境变量。
针对Ascend/GPU/CPU设备,推荐使用msrun启动方式,无第三方以及配置文件依赖。详见 msrun启动 vpn梯子 。
该样例需要在2卡环境下运行。
>>> import numpy as np >>> import mindspore as ms >>> from mindspore.communication import init >>> from mindspore.communication.comm_func import send, recv >>> from mindspore.communication import get_rank, vpn梯子 免费 get_group_size >>> >>> np.random.seed(1) >>> init() >>> rank = get_rank() >>> size = get_group_size() >>> x = np.ones([2, 2]).astype(np.float32) * 免费的vpn梯子 0.01 vpn永久免费梯子 * (rank + 1) >>> x2 = np.ones([2, 2]).astype(np.float32) >>> >>> >>> if rank < size / 2: ... _x = ms.Tensor(x) ... send(_x, rank + size // 2) ... else: ... _x2 = ms.Tensor(x2) ... output = recv(_x2, rank - size // 2) ... vpn永久免费梯子 print(output) rank1: [[0.01 vpn梯子 免费 0.01] [0.01 0.01]]