mindspore.ops.communication.gather_into_tensor ================================================ .. image:: https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/master/resource/_static/logo_source.svg :target: https://atomgit.com/mindspore/mindspore/blob/master/docs/api/api_python/ops/mindspore.ops.communication.gather_into_tensor.rst :alt: 查看源文件 .. py:function:: mindspore.ops.communication.gather_into_tensor(output_tensor, input_tensor, dst=0, group=None, async_op=False) 从指定通信组中收集张量。操作将根据维度0从进程收集张量。 .. note:: - 只有进程 `dst` (全局rank)会保留收集的张量。其他进程将保留一个shape为[1]的张量,没有数学意义。 - 当前仅支持PyNative模式,不支持Graph模式。 参数: - **output_tensor** (Tensor) - 用于容纳来自所有rank的张量元素的输出张量。 - **input_tensor** (Tensor) - 要收集的张量。张量的shape为 :math:`(x_1, x_2, ..., x_R)`。此API中的输入张量在所有rank之间必须具有相同的大小。 - **dst** (int, 可选) - 指定接收张量的进程的rank(全局rank)。只有进程 `dst` 会接收收集的张量。默认值: ``0``。 - **group** (str,可选) - 通信组名称。默认值: ``None`` ,即Ascend平台表示为 ``"hccl_world_group"`` 。 - **async_op** (bool, 可选) - 本算子是否是异步算子。默认值: ``False`` 。 返回: CommHandle。若 `async_op` 是 ``True`` ,CommHandle是一个异步工作句柄。若 `async_op` 是 ``False`` ,CommHandle将返回 ``None`` 。 异常: - **TypeError** - 如果 `input_tensor` 或 `output_tensor` 参数的类型不是Tensor,`dst` 不是int,`group` 不是str,或 `async_op` 不是bool。 - **RuntimeError** - 如果目标设备无效,或者后端无效,或者分布式初始化失败。 样例: .. note:: .. include:: ../mint/mindspore.mint.comm_note.txt 该样例需要在2卡环境下运行。