Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore.ops.inplace_index_add

mindspore.ops.inplace_index_add(var, indices, updates, axis)[source]

Adds Tensor updates to specified axis and indices of Tensor var element-wise.

Parameters
  • var (Parameter) – The input Parameter to add to, with data type uint8, int8, int16, int32, float16, float32, float64.

  • indices (Tensor) – The indies along axis to perform the addition. A 1D Tensor of shape (updates.shape[axis],), every value of it should be in range [0,var.shape[axis]) with data type int32.

  • updates (Tensor) – The input Tensor with the value to add. Must have same data type as var. The shape must be the same as var except the axis th dimension.

  • axis (int) – The dimension along which to index. It should be in range [0,len(var.dim)).

Returns

Tensor, updated result, has the same shape and dtype as var.

Raises
  • TypeError – If var is not a Parameter.

  • TypeError – If neither indices nor updates is a Tensor.

  • ValueError – If axis is out of valid range.

  • ValueError – If var rank is not the same as updates rank.

  • ValueError – If shape of indices is not (updates.shape[axis],).

  • ValueError – If updates's shape is not the same as var except the axis th dimension.

Supported Platforms:

Ascend CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops, Parameter
>>> var = Parameter(Tensor(np.array([[1, 2], [3, 4], [5, 6]]), mindspore.float32))
>>> indices = Tensor(np.array([0, 1]), mindspore.int32)
>>> updates = Tensor(np.array([[0.5, 1.0], [1.0, 1.5]]), mindspore.float32)
>>> var = ops.inplace_index_add(var, indices, updates, axis=0)
>>> print(var)
[[1.5 3. ]
 [4.  5.5]
 [5.  6. ]]