forked from mindspore-Ecosystem/mindspore
add_raise
This commit is contained in:
parent
f10f5e722b
commit
373c878118
|
@ -10,3 +10,6 @@ mindspore.Tensor.view_as
|
|||
|
||||
返回:
|
||||
Tensor,和 `other` 具有相同的shape。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `other` 不是Tensor。
|
||||
|
|
|
@ -2778,6 +2778,8 @@ def view(x, *shape):
|
|||
|
||||
def view_as(x, other):
|
||||
"""View self Tensor as the same shape as `other` ."""
|
||||
if not isinstance(other, (Tensor, Tensor_)):
|
||||
raise TypeError(f"For view_as, the input other must be a Tensor, but got {type(other)}")
|
||||
return F.reshape(x, other.shape)
|
||||
|
||||
|
||||
|
|
|
@ -1032,6 +1032,9 @@ class Tensor(Tensor_):
|
|||
Returns:
|
||||
Tensor, has the same shape as `other`.
|
||||
|
||||
Raises:
|
||||
TypeError: If `other` is not a Tensor.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
||||
|
@ -1043,6 +1046,8 @@ class Tensor(Tensor_):
|
|||
[1. 2. 3. 2. 3. 4.]
|
||||
"""
|
||||
self._init_check()
|
||||
if not isinstance(other, (Tensor, Tensor_)):
|
||||
raise TypeError(f"For view_as, the input other must be a Tensor, but got {type(other)}")
|
||||
return self.view(other.shape)
|
||||
|
||||
def t(self):
|
||||
|
|
|
@ -9283,6 +9283,8 @@ def isposinf(x):
|
|||
>>> print(output)
|
||||
[False True False]
|
||||
"""
|
||||
if not isinstance(x, (Tensor, Tensor_)):
|
||||
raise TypeError(f"For isposinf, the input x must be a Tensor, but got {type(x)}")
|
||||
return _is_sign_inf(x, tensor_gt)
|
||||
|
||||
|
||||
|
@ -9307,6 +9309,8 @@ def isneginf(x):
|
|||
>>> print(output)
|
||||
[ True False False]
|
||||
"""
|
||||
if not isinstance(x, (Tensor, Tensor_)):
|
||||
raise TypeError(f"For isneginf, the input x must be a Tensor, but got {type(x)}")
|
||||
return _is_sign_inf(x, tensor_lt)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue