add exception raises for inplace ops

This commit is contained in:
wangjun 2022-06-14 15:56:26 +08:00
parent cd18ed2815
commit 8273188f47
2 changed files with 18 additions and 0 deletions

View File

@ -639,6 +639,7 @@ mindspore.Tensor
- **TypeError** - `indices` 不是int或tuple。 - **TypeError** - `indices` 不是int或tuple。
- **TypeError** - `indices` 是元组但是其中的元素不是int。 - **TypeError** - `indices` 是元组但是其中的元素不是int。
- **ValueError** - Tensor的shape与 `v` 的shape不同。
.. py:method:: inplace_sub(v, indices) .. py:method:: inplace_sub(v, indices)
@ -660,6 +661,7 @@ mindspore.Tensor
- **TypeError** - `indices` 不是int或tuple。 - **TypeError** - `indices` 不是int或tuple。
- **TypeError** - `indices` 是元组但是其中的元素不是int。 - **TypeError** - `indices` 是元组但是其中的元素不是int。
- **ValueError** - Tensor的shape与 `v` 的shape不同。
.. py:method:: inplace_update(v, indices) .. py:method:: inplace_update(v, indices)
@ -681,6 +683,7 @@ mindspore.Tensor
- **TypeError** - `indices` 不是int或tuple。 - **TypeError** - `indices` 不是int或tuple。
- **TypeError** - `indices` 是元组但是其中的元素不是int。 - **TypeError** - `indices` 是元组但是其中的元素不是int。
- **ValueError** - Tensor的shape与 `v` 的shape不同。
.. py:method:: intopk(x, k) .. py:method:: intopk(x, k)

View File

@ -2088,6 +2088,11 @@ class Tensor(Tensor_):
Returns: Returns:
Tensor, with updated values. Tensor, with updated values.
Raises:
TypeError: if indices is not int or tuple.
TypeError: if indices is tuple but any of its element is not int.
ValueError: the Tensor shape is different from that of v.
Supported Platforms: Supported Platforms:
``Ascend`` ``CPU`` ``Ascend`` ``CPU``
@ -2119,6 +2124,11 @@ class Tensor(Tensor_):
Returns: Returns:
Tensor, with values after adding. Tensor, with values after adding.
Raises:
TypeError: if indices is not int or tuple.
TypeError: if indices is tuple but any of its element is not int.
ValueError: the Tensor shape is different from that of v.
Supported Platforms: Supported Platforms:
``Ascend`` ``CPU`` ``Ascend`` ``CPU``
@ -2150,6 +2160,11 @@ class Tensor(Tensor_):
Returns: Returns:
Tensor, with values after subtracting. Tensor, with values after subtracting.
Raises:
TypeError: if indices is not int or tuple.
TypeError: if indices is tuple but any of its element is not int.
ValueError: the Tensor shape is different from that of v.
Supported Platforms: Supported Platforms:
``Ascend`` ``CPU`` ``Ascend`` ``CPU``