fix tensor_scatter_mul doc

This commit is contained in:
z00512249 2022-07-05 19:34:40 +08:00
parent d150c96f8a
commit 0abd6475d6
7 changed files with 23 additions and 16 deletions

View File

@ -459,6 +459,7 @@ Array操作
mindspore.ops.TensorScatterDiv
mindspore.ops.TensorScatterMax
mindspore.ops.TensorScatterMin
mindspore.ops.TensorScatterMul
mindspore.ops.TensorScatterSub
mindspore.ops.TensorScatterUpdate
mindspore.ops.TensorScatterElements

View File

@ -1193,11 +1193,12 @@ mindspore.Tensor
- **ValueError** - Tensor的shape长度小于 `indices` 的shape的最后一个维度。
.. py:method:: scatter_mul(indices, updates)
根据指定的索引通过乘法进行计算将结果赋值到输出Tensor中。更新后的结果是通过算子output返回而不是直接原地更新当前Tensor。
根据指定的索引通过乘法进行计算将输出赋值到输出Tensor中
`indices` 的最后一个轴是每个索引向量的深度。对于每个索引向量, `updates` 中必须有相应的值。 `updates` 的shape应该等于 `input_x[indices]` 的shape。其中 `input_x` 指当前Tensor。 有关更多详细信息,请参见使用用例
.. note::
- 如果 `indices` 的某些值超出当前Tensor的维度范围`CPU` 后端会抛出错误,在 `GPU` 后端则忽略错误且更新值不可信任
- 如果 `indices` 的某些值超出范围,则相应的 `updates` 不会更新为当前Tensor而不是抛出索引错误
**参数:**

View File

@ -0,0 +1,8 @@
mindspore.ops.TensorScatterMul
==============================
.. py:class:: mindspore.ops.TensorScatterMul
根据指定的更新值和输入索引进行乘法运算更新输入Tensor的值。当同一索引有不同更新值时更新的结果将是累积乘法的结果。此操作与 :class:`mindspore.ops.ScatterNdMul` 类似只是更新后的结果是通过算子output返回而不是直接原地更新input。
更多参考相见 :func:`mindspore.ops.tensor_scatter_mul`

View File

@ -8,7 +8,7 @@ mindspore.ops.tensor_scatter_mul
`indices` 的最后一个轴是每个索引向量的深度。对于每个索引向量, `updates` 中必须有相应的值。 `updates` 的shape应该等于 `input_x[indices]` 的shape。有关更多详细信息请参见使用用例。
.. note::
- 如果 `indices` 的某些值超出 `input_x` 的维度范围,`CPU` 后端会抛出错误,在 `GPU` 后端则忽略错误且更新值不可信任
- 如果 `indices` 的某些值超出 `input_x` 的维度范围,则相应的 `updates` 不会更新为 `input_x` ,而不是抛出索引错误
**参数:**

View File

@ -458,6 +458,7 @@ Array Operation
mindspore.ops.TensorScatterDiv
mindspore.ops.TensorScatterMax
mindspore.ops.TensorScatterMin
mindspore.ops.TensorScatterMul
mindspore.ops.TensorScatterSub
mindspore.ops.TensorScatterUpdate
mindspore.ops.TensorShape

View File

@ -739,15 +739,13 @@ class Tensor(Tensor_):
equal to the shape of `input_x[indices]`. For more details, see use cases.
Note:
- If some values of the `indices` are out of bound, CPU backend will raise an index error.
GPU backend will not raise and index error
and the corresponding `updates` will not be updated to self tensor.
- If some values of the `indices` are out of bound, instead of raising an index error,
the corresponding `updates` will not be updated to `input_x`.
Args:
indices (Tensor): The index of input tensor whose data type is int32 or int64.
The rank must be at least 2.
indices (Tensor): The index of input tensor whose data type is int32 or int64. The rank must be at least 2.
updates (Tensor): The tensor to update the input tensor, has the same type as input,
and updates.shape should be equal to indices.shape[:-1] + input_x.shape[indices.shape[-1]:].
and updates shape should be equal to indices.shape[:-1] + input_x.shape[indices.shape[-1]:].
Returns:
Tensor, has the same shape and type as self tensor.

View File

@ -3196,7 +3196,7 @@ def tensor_scatter_mul(input_x, indices, updates):
"""
Creates a new tensor by multiplying the values from the positions in `input_x` indicated by
`indices`, with values from `updates`. When divided values are provided for the same
index, the result of the update will be to divided these values respectively. Except that
index, the result of the update will multiply these values respectively. Except that
the updates are applied on output `Tensor` instead of input `Parameter`.
The last axis of `indices` is the depth of each index vectors. For each index vector,
@ -3204,16 +3204,14 @@ def tensor_scatter_mul(input_x, indices, updates):
equal to the shape of `input_x[indices]`. For more details, see use cases.
Note:
- If some values of the `indices` are out of bound, CPU backend will raise an index error.
GPU backend will not raise and index error
and the corresponding `updates` will not be updated to `input_x`.
- If some values of the `indices` are out of bound, instead of raising an index error,
the corresponding `updates` will not be updated to `input_x`.
Args:
input_x (Tensor): The target tensor. The dimension of input_x must be no less than indices.shape[-1].
indices (Tensor): The index of input tensor whose data type is int32 or int64.
The rank must be at least 2.
indices (Tensor): The index of input tensor whose data type is int32 or int64. The rank must be at least 2.
updates (Tensor): The tensor to update the input tensor, has the same type as input,
and updates.shape should be equal to indices.shape[:-1] + input_x.shape[indices.shape[-1]:].
and updates shape should be equal to indices.shape[:-1] + input_x.shape[indices.shape[-1]:].
Returns:
Tensor, has the same shape and type as `input_x`.