mindspore2022/docs/api/api_python/ops/mindspore.ops.ScatterAdd.rst

36 lines
1.5 KiB
ReStructuredText
Raw 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.ScatterAdd
=========================
.. py:class:: mindspore.ops.ScatterAdd(use_locking=False)
根据指定更新值和输入索引通过加法运算更新输入数据的值。
对于 `indices.shape` 的每个 `i, ..., j`
.. math::
\text{input_x}[\text{indices}[i, ..., j], :] \mathrel{+}= \text{updates}[i, ..., j, :]
输入的 `input_x``updates` 遵循隐式类型转换规则以确保数据类型一致。如果数据类型不同则低精度数据类型将转换为高精度的数据类型。当参数的数据类型需要转换时则会抛出RuntimeError异常。
.. note::
这是一个运行即更新的算子。因此, `input_x` 在运算完成后即更新。
**参数:**
- **use_locking** (bool) - 是否启用锁保护。默认值False。
**输入:**
- **input_x** (Parameter) - ScatterAdd的输入任意维度的Parameter。
- **indices** (Tensor) - 指定相加操作的索引数据类型为mindspore.int32。
- **updates** (Tensor) - 指定与 `input_x` 相加操作的Tensor数据类型与 `input_x` 相同shape为 `indices_shape + x_shape[1:]`
**输出:**
Tensor更新后的 `input_x` shape和数据类型与 `input_x` 相同。
**异常:**
- **TypeError** - `use_locking` 不是bool。
- **TypeError** - `indices` 不是int32。
- **ValueError ** - `updates` 的shape不等于 `indices_shape + x_shape[1:]`