mindspore/docs/api/api_python/ops/mindspore.ops.AllReduce.rst

35 lines
1.5 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.AllReduce
========================
.. py:class:: mindspore.ops.AllReduce(op=ReduceOp.SUM, group=GlobalComm.WORLD_COMM_GROUP)
使用指定方式对通信组内的所有设备的Tensor数据进行归约操作所有设备都得到相同的结果返回归约操作后的张量。
.. note::
集合中的所有进程的Tensor必须具有相同的shape和格式。
参数:
- **op** (str可选) - 归约的具体操作。如 ``"sum"````"prod"````"max"`` 、和 ``"min"`` 。CPU模式只支持 ``"sum"``。默认值: ``ReduceOp.SUM``
- **group** (str可选) - 工作的通信组。默认值:``GlobalComm.WORLD_COMM_GROUP`` 即Ascend平台为 ``"hccl_world_group"`` GPU平台为 ``"nccl_world_group"`` )。
输入:
- **input_x** (Tensor) - shape为 :math:`(x_1, x_2, ..., x_R)` 的Tensor。
输出:
Tensorshape与输入相同:math:`(x_1, x_2, ..., x_R)` 。其内容取决于操作。
异常:
- **TypeError** - `op``group` 不是str或者输入的数据类型是bool。
- **RuntimeError** - 如果目标设备无效,或者后端无效,或者分布式初始化失败。
样例:
.. note::
.. include:: mindspore.ops.comm_note.rst
该样例需要在2卡环境下运行。
教程样例:
- `分布式集合通信原语 - AllReduce
<https://www.mindspore.cn/docs/zh-CN/master/api_python/samples/ops/communicate_ops.html#allreduce>`_