forked from mindspore-Ecosystem/mindspore
!48860 对ops下的API和其在Tensor下的同名API的参数名进行整改,涉及修改点,函数实现,中文说明修改,英文说明修改。
Merge pull request !48860 from tangdezhi_123/br_tdz_20230214
This commit is contained in:
commit
9f67ec44b3
|
@ -75,6 +75,7 @@
|
|||
"mindspore/mindspore/python/mindspore/ops/_grad_experimental/grad_sparse_ops.py" "unused-variable"
|
||||
"mindspore/mindspore/python/mindspore/ops/operations/_inner_ops.py" "not-callable"
|
||||
"mindspore/mindspore/python/mindspore/hypercomplex" "useless-return"
|
||||
"mindspore/mindspore/python" "redefined-builtin"
|
||||
|
||||
# MindData
|
||||
"mindspore/mindspore/python/mindspore/dataset/__init__.py" "redefined-builtin"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mindspore.Tensor.atan2
|
||||
======================
|
||||
|
||||
.. py:method:: mindspore.Tensor.atan2(y)
|
||||
.. py:method:: mindspore.Tensor.atan2(other)
|
||||
|
||||
详情请参考 :func:`mindspore.ops.atan2`。
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mindspore.Tensor.bitwise_and
|
||||
============================
|
||||
|
||||
.. py:method:: mindspore.Tensor.bitwise_and(x)
|
||||
.. py:method:: mindspore.Tensor.bitwise_and(other)
|
||||
|
||||
详情请参考 :func:`mindspore.ops.bitwise_and`。
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mindspore.Tensor.bitwise_or
|
||||
===========================
|
||||
|
||||
.. py:method:: mindspore.Tensor.bitwise_or(x)
|
||||
.. py:method:: mindspore.Tensor.bitwise_or(other)
|
||||
|
||||
详情请参考 :func:`mindspore.ops.bitwise_or`。
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mindspore.Tensor.bitwise_xor
|
||||
============================
|
||||
|
||||
.. py:method:: mindspore.Tensor.bitwise_xor(x)
|
||||
.. py:method:: mindspore.Tensor.bitwise_xor(other)
|
||||
|
||||
详情请参考 :func:`mindspore.ops.bitwise_xor`。
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mindspore.ops.arctan2
|
||||
=====================
|
||||
|
||||
.. py:function:: mindspore.ops.arctan2(x, other)
|
||||
.. py:function:: mindspore.ops.arctan2(input, other)
|
||||
|
||||
详情请参考 :func:`mindspore.ops.atan2`。
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
mindspore.ops.atan2
|
||||
===================
|
||||
|
||||
.. py:function:: mindspore.ops.atan2(x, y)
|
||||
.. py:function:: mindspore.ops.atan2(input, other)
|
||||
|
||||
逐元素计算x/y的反正切值。
|
||||
逐元素计算input/other的反正切值。
|
||||
|
||||
返回 :math:`\theta\ \in\ [-\pi, \pi]` ,使得 :math:`x = r*\sin(\theta), y = r*\cos(\theta)` ,其中 :math:`r = \sqrt{x^2 + y^2}` 。
|
||||
输入 `x` 和 `y` 会通过隐式数据类型转换使数据类型保持一致。如果数据类型不同,低精度的数据类型会被转换到高精度的数据类型。
|
||||
返回 :math:`\theta\ \in\ [-\pi, \pi]` ,使得 :math:`input = r*\sin(\theta), other = r*\cos(\theta)` ,其中 :math:`r = \sqrt{input^2 + other^2}` 。
|
||||
输入 `input` 和 `other` 会通过隐式数据类型转换使数据类型保持一致。如果数据类型不同,低精度的数据类型会被转换到高精度的数据类型。
|
||||
|
||||
参数:
|
||||
- **x** (Tensor) - 输入Tensor,shape: :math:`(N,*)` ,其中 :math:`*` 表示任何数量的附加维度。
|
||||
- **y** (Tensor) - 输入Tensor,shape应能在广播后与 `x` 相同,或 `x` 的shape在广播后与 `y` 相同。
|
||||
- **input** (Tensor) - 输入Tensor,shape: :math:`(N,*)` ,其中 :math:`*` 表示任何数量的附加维度。
|
||||
- **other** (Tensor) - 输入Tensor,shape应能在广播后与 `input` 相同,或 `input` 的shape在广播后与 `other` 相同。
|
||||
|
||||
返回:
|
||||
Tensor,与广播后的输入shape相同,和 `x` 数据类型相同。
|
||||
Tensor,与广播后的输入shape相同,和 `input` 数据类型相同。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `x` 或 `y` 不是Tensor。
|
||||
- **RuntimeError** - `x` 与 `y` 之间的数据类型转换不被支持
|
||||
- **TypeError** - `input` 或 `other` 不是Tensor。
|
||||
- **RuntimeError** - `input` 与 `other` 之间的数据类型转换不被支持。
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
mindspore.ops.bitwise_and
|
||||
=========================
|
||||
|
||||
.. py:function:: mindspore.ops.bitwise_and(x, y)
|
||||
.. py:function:: mindspore.ops.bitwise_and(input, other)
|
||||
|
||||
逐元素执行两个Tensor的与运算。
|
||||
|
||||
.. math::
|
||||
|
||||
out_i = x_{i} \wedge y_{i}
|
||||
out_i = input_{i} \wedge other_{i}
|
||||
|
||||
输入 `x` 和 `y` 遵循 `隐式类型转换规则 <https://www.mindspore.cn/docs/zh-CN/master/note/operator_list_implicit.html>`_ ,使数据类型保持一致。
|
||||
如果 `x` 和 `y` 数据类型不同,低精度数据类型将自动转换成高精度数据类型。
|
||||
输入 `input` 和 `other` 遵循 `隐式类型转换规则 <https://www.mindspore.cn/docs/zh-CN/master/note/operator_list_implicit.html>`_ ,使数据类型保持一致。
|
||||
如果 `input` 和 `other` 数据类型不同,低精度数据类型将自动转换成高精度数据类型。
|
||||
|
||||
参数:
|
||||
- **x** (Tensor) - 第一个输入Tensor,其shape为 :math:`(N, *)` ,其中 :math:`*` 为任意数量的额外维度。
|
||||
- **y** (Tensor) - 第二个输入Tensor,数据类型与 `x` 一致。
|
||||
- **input** (Tensor) - 第一个输入Tensor,其shape为 :math:`(N, *)` ,其中 :math:`*` 为任意数量的额外维度。
|
||||
- **other** (Tensor) - 第二个输入Tensor,数据类型与 `input` 一致。
|
||||
|
||||
返回:
|
||||
Tensor,是一个与 `x` 相同类型的Tensor。
|
||||
Tensor,是一个与 `input` 相同类型的Tensor。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `x` 或 `y` 不是Tensor。
|
||||
- **TypeError** - `input` 或 `other` 不是Tensor。
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
mindspore.ops.bitwise_left_shift
|
||||
=================================
|
||||
|
||||
.. py:function:: mindspore.ops.bitwise_left_shift(x, other)
|
||||
.. py:function:: mindspore.ops.bitwise_left_shift(input, other)
|
||||
|
||||
对输入 `x` 进行左移 `other` 位运算。
|
||||
对输入 `input` 进行左移 `other` 位运算。
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{aligned}
|
||||
&out_{i} =x_{i} << other_{i}
|
||||
&out_{i} =input_{i} << other_{i}
|
||||
\end{aligned}
|
||||
|
||||
参数:
|
||||
- **x** (Union[Tensor, Scalar]) - 被左移的输入。
|
||||
- **input** (Union[Tensor, Scalar]) - 被左移的输入。
|
||||
- **other** (Union[Tensor, Scalar]) - 左移的位数。
|
||||
|
||||
返回:
|
||||
Tensor,左移位运算后的结果。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `x` 或 `other` 都不是Tensor。
|
||||
- **TypeError** - `x` 或 `other` 不是int、int类型的Tensor或uint类型的Tensor。
|
||||
- **TypeError** - `input` 或 `other` 都不是Tensor。
|
||||
- **TypeError** - `input` 或 `other` 不是int、int类型的Tensor或uint类型的Tensor。
|
||||
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
mindspore.ops.bitwise_or
|
||||
========================
|
||||
|
||||
.. py:function:: mindspore.ops.bitwise_or(x, y)
|
||||
.. py:function:: mindspore.ops.bitwise_or(input, other)
|
||||
|
||||
逐元素执行两个Tensor的或运算。
|
||||
|
||||
.. math::
|
||||
|
||||
out_i = x_{i} \mid y_{i}
|
||||
out_i = input_{i} \mid other_{i}
|
||||
|
||||
输入 `x` 和 `y` 遵循 `隐式类型转换规则 <https://www.mindspore.cn/docs/zh-CN/master/note/operator_list_implicit.html>`_ ,使数据类型保持一致。
|
||||
如果 `x` 和 `y` 数据类型不同,低精度数据类型将自动转换成高精度数据类型。
|
||||
输入 `input` 和 `other` 遵循 `隐式类型转换规则 <https://www.mindspore.cn/docs/zh-CN/master/note/operator_list_implicit.html>`_ ,使数据类型保持一致。
|
||||
如果 `input` 和 `other` 数据类型不同,低精度数据类型将自动转换成高精度数据类型。
|
||||
|
||||
参数:
|
||||
- **x** (Tensor) - 第一个输入Tensor,其shape为 :math:`(N, *)` ,其中 :math:`*` 为任意数量的额外维度。
|
||||
- **y** (Tensor) - 第二个输入Tensor,数据类型与 `x` 一致。
|
||||
- **input** (Tensor) - 第一个输入Tensor,其shape为 :math:`(N, *)` ,其中 :math:`*` 为任意数量的额外维度。
|
||||
- **other** (Tensor) - 第二个输入Tensor,数据类型与 `input` 一致。
|
||||
|
||||
返回:
|
||||
Tensor,是一个与 `x` 相同类型的Tensor。
|
||||
Tensor,是一个与 `input` 相同类型的Tensor。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `x` 或 `y` 不是Tensor。
|
||||
- **TypeError** - `input` 或 `other` 不是Tensor。
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
mindspore.ops.bitwise_right_shift
|
||||
=================================
|
||||
|
||||
.. py:function:: mindspore.ops.bitwise_right_shift(x, other)
|
||||
.. py:function:: mindspore.ops.bitwise_right_shift(input, other)
|
||||
|
||||
对输入 `x` 进行右移 `other` 位运算。
|
||||
对输入 `input` 进行右移 `other` 位运算。
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{aligned}
|
||||
&out_{i} =x_{i} >> other_{i}
|
||||
&out_{i} =input_{i} >> other_{i}
|
||||
\end{aligned}
|
||||
|
||||
参数:
|
||||
- **x** (Union[Tensor, Scalar]) - 被右移的输入。
|
||||
- **input** (Union[Tensor, Scalar]) - 被右移的输入。
|
||||
- **other** (Union[Tensor, Scalar]) - 右移的位数。
|
||||
|
||||
返回:
|
||||
Tensor,右移位运算后的结果。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `x` 或 `other` 都不是Tensor。
|
||||
- **TypeError** - `x` 或 `other` 不是int、int类型的Tensor或uint类型的Tensor。
|
||||
- **TypeError** - `input` 或 `other` 都不是Tensor。
|
||||
- **TypeError** - `input` 或 `other` 不是int、int类型的Tensor或uint类型的Tensor。
|
||||
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
mindspore.ops.bitwise_xor
|
||||
=========================
|
||||
|
||||
.. py:function:: mindspore.ops.bitwise_xor(x, y)
|
||||
.. py:function:: mindspore.ops.bitwise_xor(input, other)
|
||||
|
||||
逐元素执行两个Tensor的异或运算。
|
||||
|
||||
.. math::
|
||||
|
||||
out_i = x_{i} \oplus y_{i}
|
||||
out_i = input_{i} \oplus other_{i}
|
||||
|
||||
输入 `x` 和 `y` 遵循 `隐式类型转换规则 <https://www.mindspore.cn/docs/zh-CN/master/note/operator_list_implicit.html>`_ ,使数据类型保持一致。
|
||||
如果 `x` 和 `y` 数据类型不同,低精度数据类型将自动转换成高精度数据类型。
|
||||
输入 `input` 和 `other` 遵循 `隐式类型转换规则 <https://www.mindspore.cn/docs/zh-CN/master/note/operator_list_implicit.html>`_ ,使数据类型保持一致。
|
||||
如果 `input` 和 `other` 数据类型不同,低精度数据类型将自动转换成高精度数据类型。
|
||||
|
||||
参数:
|
||||
- **x** (Tensor) - 第一个输入Tensor,其shape为 :math:`(N, *)` ,其中 :math:`*` 为任意数量的额外维度。
|
||||
- **y** (Tensor) - 第二个输入Tensor,数据类型与 `x` 一致。
|
||||
- **input** (Tensor) - 第一个输入Tensor,其shape为 :math:`(N, *)` ,其中 :math:`*` 为任意数量的额外维度。
|
||||
- **other** (Tensor) - 第二个输入Tensor,数据类型与 `input` 一致。
|
||||
|
||||
返回:
|
||||
Tensor,是一个与 `x` 相同类型的Tensor。
|
||||
Tensor,是一个与 `input` 相同类型的Tensor。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `x` 或 `y` 不是Tensor。
|
||||
- **TypeError** - `input` 或 `other` 不是Tensor。
|
||||
|
|
|
@ -885,12 +885,12 @@ class Tensor(Tensor_):
|
|||
axis = ()
|
||||
return tensor_operator_registry.get('any')(keep_dims)(self, axis)
|
||||
|
||||
def atan2(self, y):
|
||||
def atan2(self, other):
|
||||
r"""
|
||||
For details, please refer to :func:`mindspore.ops.atan2`.
|
||||
"""
|
||||
self._init_check()
|
||||
return tensor_operator_registry.get('atan2')(self, y)
|
||||
return tensor_operator_registry.get('atan2')(self, other)
|
||||
|
||||
def baddbmm(self, batch1, batch2, beta=1, alpha=1):
|
||||
r"""
|
||||
|
@ -964,26 +964,26 @@ class Tensor(Tensor_):
|
|||
self._init_check()
|
||||
return tensor_operator_registry.get("t")(self)
|
||||
|
||||
def bitwise_and(self, x):
|
||||
def bitwise_and(self, other):
|
||||
"""
|
||||
For details, please refer to :func:`mindspore.ops.bitwise_and`.
|
||||
"""
|
||||
self._init_check()
|
||||
return tensor_operator_registry.get('bitwise_and')(self, x)
|
||||
return tensor_operator_registry.get('bitwise_and')(self, other)
|
||||
|
||||
def bitwise_or(self, x):
|
||||
def bitwise_or(self, other):
|
||||
"""
|
||||
For details, please refer to :func:`mindspore.ops.bitwise_or`.
|
||||
"""
|
||||
self._init_check()
|
||||
return tensor_operator_registry.get('bitwise_or')(self, x)
|
||||
return tensor_operator_registry.get('bitwise_or')(self, other)
|
||||
|
||||
def bitwise_xor(self, x):
|
||||
def bitwise_xor(self, other):
|
||||
"""
|
||||
For details, please refer to :func:`mindspore.ops.bitwise_xor`.
|
||||
"""
|
||||
self._init_check()
|
||||
return tensor_operator_registry.get('bitwise_xor')(self, x)
|
||||
return tensor_operator_registry.get('bitwise_xor')(self, other)
|
||||
|
||||
def bitwise_left_shift(self, other):
|
||||
"""
|
||||
|
|
|
@ -2179,12 +2179,12 @@ def arctan(x):
|
|||
return atan_(x)
|
||||
|
||||
|
||||
def arctan2(x, other):
|
||||
def arctan2(input, other):
|
||||
r"""
|
||||
For details, please refer to :func:`mindspore.ops.atan2`.
|
||||
"""
|
||||
_atan2 = _get_cache_prim(P.Atan2)()
|
||||
return _atan2(x, other)
|
||||
return _atan2(input, other)
|
||||
|
||||
|
||||
def polar(abs, angle): # pylint: disable=redefined-outer-name
|
||||
|
@ -2541,263 +2541,263 @@ def atanh(x):
|
|||
return atanh_(x)
|
||||
|
||||
|
||||
def atan2(x, y):
|
||||
def atan2(input, other):
|
||||
r"""
|
||||
Returns arctangent of x/y element-wise.
|
||||
Returns arctangent of input/other element-wise.
|
||||
|
||||
It returns :math:`\theta\ \in\ [-\pi, \pi]`
|
||||
such that :math:`x = r*\sin(\theta), y = r*\cos(\theta)`, where :math:`r = \sqrt{x^2 + y^2}`.
|
||||
such that :math:`input = r*\sin(\theta), other = r*\cos(\theta)`, where :math:`r = \sqrt{input^2 + other^2}`.
|
||||
|
||||
Args of `x` and `y` comply with the implicit type conversion rules to make the data types consistent.
|
||||
Args of `input` and `other` comply with the implicit type conversion rules to make the data types consistent.
|
||||
If they have different data types, the lower precision data type will be converted to
|
||||
the relatively highest precision data type.
|
||||
|
||||
Args:
|
||||
x (Tensor): The input tensor.
|
||||
input (Tensor): The input tensor.
|
||||
:math:`(N,*)` where :math:`*` means, any number of additional dimensions.
|
||||
The data type should be one of the following types: float16, float32, float64
|
||||
y (Tensor): The input tensor. It has the same shape with `x`.
|
||||
other (Tensor): The input tensor. It has the same shape with `input`.
|
||||
|
||||
Returns:
|
||||
Tensor, the shape is the same as the one after broadcasting,and the data type is same as `x`.
|
||||
Tensor, the shape is the same as the one after broadcasting,and the data type is same as `input`.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x` or `y` is not a Tensor.
|
||||
RuntimeError: If the data type of `x` and `y` conversion of Parameter is required
|
||||
TypeError: If `input` or `other` is not a Tensor.
|
||||
RuntimeError: If the data type of `input` and `other` conversion of Parameter is required
|
||||
when data type conversion of Parameter is not supported.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> x = Tensor(np.array([0, 1]), mindspore.float32)
|
||||
>>> y = Tensor(np.array([1, 1]), mindspore.float32)
|
||||
>>> output = ops.atan2(x, y)
|
||||
>>> input = Tensor(np.array([0, 1]), mindspore.float32)
|
||||
>>> other = Tensor(np.array([1, 1]), mindspore.float32)
|
||||
>>> output = ops.atan2(input, other)
|
||||
>>> print(output)
|
||||
[0. 0.7853982]
|
||||
"""
|
||||
_atan2 = _get_cache_prim(P.Atan2)()
|
||||
return _atan2(x, y)
|
||||
return _atan2(input, other)
|
||||
|
||||
|
||||
def bitwise_and(x, y):
|
||||
def bitwise_and(input, other):
|
||||
r"""
|
||||
Returns bitwise `and` of two tensors element-wise.
|
||||
|
||||
.. math::
|
||||
|
||||
out_i = x_{i} \wedge y_{i}
|
||||
out_i = input_{i} \wedge other_{i}
|
||||
|
||||
Args of `x` and `y` comply with the implicit type conversion rules to
|
||||
Args of `input` and `other` comply with the implicit type conversion rules to
|
||||
make the data types consistent.
|
||||
If they have different data types, the lower priority data type will be converted to
|
||||
the relatively highest priority data type.
|
||||
|
||||
Args:
|
||||
x (Tensor): The first input tensor with shape :math:`(N,*)` where :math:`*` means
|
||||
input (Tensor): The first input tensor with shape :math:`(N,*)` where :math:`*` means
|
||||
any number of additional dimensions.
|
||||
y (Tensor): The second input tensor with the same dtype as `x`.
|
||||
other (Tensor): The second input tensor with the same dtype as `input`.
|
||||
|
||||
Returns:
|
||||
Tensor, has the same type as the `x`.
|
||||
Tensor, has the same type as the `input`.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x` or `y` is not a Tensor.
|
||||
TypeError: If `input` or `other` is not a Tensor.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> x = Tensor(np.array([0, 0, 1, -1, 1, 1, 1]), mindspore.int16)
|
||||
>>> y = Tensor(np.array([0, 1, 1, -1, -1, 2, 3]), mindspore.int16)
|
||||
>>> output = ops.bitwise_and(x, y)
|
||||
>>> input = Tensor(np.array([0, 0, 1, -1, 1, 1, 1]), mindspore.int16)
|
||||
>>> other = Tensor(np.array([0, 1, 1, -1, -1, 2, 3]), mindspore.int16)
|
||||
>>> output = ops.bitwise_and(input, other)
|
||||
>>> print(output)
|
||||
[ 0 0 1 -1 1 0 1]
|
||||
"""
|
||||
return bitwise_and_(x, y)
|
||||
return bitwise_and_(input, other)
|
||||
|
||||
|
||||
def bitwise_or(x, y):
|
||||
def bitwise_or(input, other):
|
||||
r"""
|
||||
Returns bitwise `or` of two tensors element-wise.
|
||||
|
||||
.. math::
|
||||
|
||||
out_i = x_{i} \mid y_{i}
|
||||
out_i = input_{i} \mid other_{i}
|
||||
|
||||
Args of `x` and `y` comply with the implicit type conversion rules to
|
||||
Args of `input` and `other` comply with the implicit type conversion rules to
|
||||
make the data types consistent.
|
||||
If they have different data types, the lower priority data type will be converted to
|
||||
the relatively highest priority data type.
|
||||
|
||||
Args:
|
||||
x (Tensor): The first input tensor with shape :math:`(N,*)` where :math:`*` means
|
||||
input (Tensor): The first input tensor with shape :math:`(N,*)` where :math:`*` means
|
||||
any number of additional dimensions.
|
||||
y (Tensor): The second input tensor with the same dtype as `x`.
|
||||
other (Tensor): The second input tensor with the same dtype as `input`.
|
||||
|
||||
Returns:
|
||||
Tensor, has the same type as the `x`.
|
||||
Tensor, has the same type as the `input`.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x` or `y` is not a Tensor.
|
||||
TypeError: If `input` or `other` is not a Tensor.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> x = Tensor(np.array([0, 0, 1, -1, 1, 1, 1]), mindspore.int16)
|
||||
>>> y = Tensor(np.array([0, 1, 1, -1, -1, 2, 3]), mindspore.int16)
|
||||
>>> output = ops.bitwise_or(x, y)
|
||||
>>> input = Tensor(np.array([0, 0, 1, -1, 1, 1, 1]), mindspore.int16)
|
||||
>>> other = Tensor(np.array([0, 1, 1, -1, -1, 2, 3]), mindspore.int16)
|
||||
>>> output = ops.bitwise_or(input, other)
|
||||
>>> print(output)
|
||||
[ 0 1 1 -1 -1 3 3]
|
||||
"""
|
||||
return bitwise_or_(x, y)
|
||||
return bitwise_or_(input, other)
|
||||
|
||||
|
||||
def bitwise_xor(x, y):
|
||||
def bitwise_xor(input, other):
|
||||
r"""
|
||||
Returns bitwise `xor` of two tensors element-wise.
|
||||
|
||||
.. math::
|
||||
|
||||
out_i = x_{i} \oplus y_{i}
|
||||
out_i = input_{i} \oplus other_{i}
|
||||
|
||||
Args of `x` and `y` comply with the implicit type conversion rules to
|
||||
Args of `input` and `other` comply with the implicit type conversion rules to
|
||||
make the data types consistent.
|
||||
If they have different data types, the lower priority data type will be converted to
|
||||
the relatively highest priority data type.
|
||||
|
||||
Args:
|
||||
x (Tensor): The first input tensor with shape :math:`(N,*)` where :math:`*` means
|
||||
input (Tensor): The first input tensor with shape :math:`(N,*)` where :math:`*` means
|
||||
any number of additional dimensions.
|
||||
y (Tensor): The second input tensor with the same dtype as `x`.
|
||||
other (Tensor): The second input tensor with the same dtype as `input`.
|
||||
|
||||
Returns:
|
||||
Tensor, has the same type as the `x`.
|
||||
Tensor, has the same type as the `input`.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x` or `y` is not a Tensor.
|
||||
TypeError: If `input` or `other` is not a Tensor.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> x = Tensor(np.array([0, 0, 1, -1, 1, 1, 1]), mindspore.int16)
|
||||
>>> y = Tensor(np.array([0, 1, 1, -1, -1, 2, 3]), mindspore.int16)
|
||||
>>> output = ops.bitwise_xor(x, y)
|
||||
>>> input = Tensor(np.array([0, 0, 1, -1, 1, 1, 1]), mindspore.int16)
|
||||
>>> other = Tensor(np.array([0, 1, 1, -1, -1, 2, 3]), mindspore.int16)
|
||||
>>> output = ops.bitwise_xor(input, other)
|
||||
>>> print(output)
|
||||
[ 0 1 0 0 -2 3 2]
|
||||
"""
|
||||
return bitwise_xor_(x, y)
|
||||
return bitwise_xor_(input, other)
|
||||
|
||||
|
||||
def bitwise_left_shift(x, other):
|
||||
def bitwise_left_shift(input, other):
|
||||
r"""
|
||||
Calculates the left arithmetic shift of `x` by `other` bits.
|
||||
Calculates the left arithmetic shift of `input` by `other` bits.
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{aligned}
|
||||
&out_{i} =x_{i} << other_{i}
|
||||
&out_{i} =input_{i} << other_{i}
|
||||
\end{aligned}
|
||||
|
||||
Args:
|
||||
x (Union[Tensor, Scalar]): The input to be left shifted.
|
||||
input (Union[Tensor, Scalar]): The input to be left shifted.
|
||||
other (Union[Tensor, Scalar]): The number of bit to be applied on left arithmetic shift.
|
||||
|
||||
Returns:
|
||||
Tensor, the result after bitwise left shift.
|
||||
|
||||
Raises:
|
||||
TypeError: If neither `x` nor `other` is a tensor.
|
||||
TypeError: If either `x` or `other` is not an int or a tensor of dtype: int or uint.
|
||||
TypeError: If neither `input` nor `other` is a tensor.
|
||||
TypeError: If either `input` or `other` is not an int or a tensor of dtype: int or uint.
|
||||
|
||||
Supported Platforms:
|
||||
``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> x = Tensor(np.array([1024, 2]), mindspore.int16)
|
||||
>>> y = Tensor(np.array([2]), mindspore.int16)
|
||||
>>> output = ops.bitwise_left_shift(x, y)
|
||||
>>> input = Tensor(np.array([1024, 2]), mindspore.int16)
|
||||
>>> other = Tensor(np.array([2]), mindspore.int16)
|
||||
>>> output = ops.bitwise_left_shift(input, other)
|
||||
>>> print(output)
|
||||
[4096 8]
|
||||
"""
|
||||
if isinstance(x, numbers.Number) and isinstance(other, numbers.Number):
|
||||
if isinstance(input, numbers.Number) and isinstance(other, numbers.Number):
|
||||
raise TypeError(f"For 'bitwise_left_shift', at least one of the inputs should be a Tensor.")
|
||||
|
||||
cast = ops.Cast()
|
||||
white_list = [mstype.int8, mstype.int16, mstype.int32, mstype.int64,
|
||||
mstype.uint8, mstype.uint16, mstype.uint32, mstype.uint64]
|
||||
if isinstance(x, numbers.Number):
|
||||
if isinstance(input, numbers.Number):
|
||||
_dtype = other.dtype
|
||||
if not isinstance(x, int):
|
||||
raise TypeError(f"For 'bitwise_left_shift', 'x' must be an integer, but got x:{type(x)}.")
|
||||
if not isinstance(input, int):
|
||||
raise TypeError(f"For 'bitwise_left_shift', 'input' must be an integer, but got input:{type(input)}.")
|
||||
if _dtype not in white_list:
|
||||
raise TypeError(f"For 'bitwise_left_shift', 'other' must be a Tensor of int or uint, but got {_dtype}.")
|
||||
x = cast(x, other.dtype)
|
||||
input = cast(input, other.dtype)
|
||||
elif isinstance(other, numbers.Number):
|
||||
_dtype = x.dtype
|
||||
_dtype = input.dtype
|
||||
if not isinstance(other, int):
|
||||
raise TypeError(f"For 'bitwise_left_shift', 'other' must be an integer, but got other:{type(other)}.")
|
||||
if _dtype not in white_list:
|
||||
raise TypeError(f"For 'bitwise_left_shift', 'x' must be a Tensor of int or uint, but got {_dtype}.")
|
||||
other = cast(other, x.dtype)
|
||||
raise TypeError(f"For 'bitwise_left_shift', 'input' must be a Tensor of int or uint, but got {_dtype}.")
|
||||
other = cast(other, input.dtype)
|
||||
ls = ops.LeftShift()
|
||||
return ls(x, other)
|
||||
return ls(input, other)
|
||||
|
||||
|
||||
def bitwise_right_shift(x, other):
|
||||
def bitwise_right_shift(input, other):
|
||||
r"""
|
||||
Calculates the right arithmetic shift of `x` by `other` bits.
|
||||
Calculates the right arithmetic shift of `input` by `other` bits.
|
||||
|
||||
.. math::
|
||||
|
||||
\begin{aligned}
|
||||
&out_{i} =x_{i} >> y_{i}
|
||||
&out_{i} =input_{i} >> other_{i}
|
||||
\end{aligned}
|
||||
|
||||
Args:
|
||||
x (Union[Tensor, Scalar]): The input to be right shifted.
|
||||
input (Union[Tensor, Scalar]): The input to be right shifted.
|
||||
other (Union[Tensor, Scalar]): The number of bit to be applied on right arithmetic shift.
|
||||
|
||||
Returns:
|
||||
Tensor, the result after bitwise right shift.
|
||||
|
||||
Raises:
|
||||
TypeError: If neither `x` nor `other` is a tensor.
|
||||
TypeError: If either `x` or `other` is not an int or a tensor of dtype: int or uint.
|
||||
TypeError: If neither `input` nor `other` is a tensor.
|
||||
TypeError: If either `input` or `other` is not an int or a tensor of dtype: int or uint.
|
||||
|
||||
Supported Platforms:
|
||||
``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> x = Tensor(np.array([1024, 2]), mindspore.int16)
|
||||
>>> y = Tensor(np.array([2]), mindspore.int16)
|
||||
>>> output = ops.bitwise_right_shift(x, y)
|
||||
>>> input = Tensor(np.array([1024, 2]), mindspore.int16)
|
||||
>>> other = Tensor(np.array([2]), mindspore.int16)
|
||||
>>> output = ops.bitwise_right_shift(input, other)
|
||||
>>> print(output)
|
||||
[256 0]
|
||||
"""
|
||||
if isinstance(x, numbers.Number) and isinstance(other, numbers.Number):
|
||||
if isinstance(input, numbers.Number) and isinstance(other, numbers.Number):
|
||||
raise TypeError(f"For 'bitwise_left_shift', at least one of the inputs should be a Tensor.")
|
||||
cast = ops.Cast()
|
||||
white_list = [mstype.int8, mstype.int16, mstype.int32, mstype.int64,
|
||||
mstype.uint8, mstype.uint16, mstype.uint32, mstype.uint64]
|
||||
if isinstance(x, numbers.Number):
|
||||
if isinstance(input, numbers.Number):
|
||||
_dtype = other.dtype
|
||||
if not isinstance(x, int):
|
||||
raise TypeError(f"For 'bitwise_left_shift', 'x' must be an integer, but got x:{type(x)}.")
|
||||
if not isinstance(input, int):
|
||||
raise TypeError(f"For 'bitwise_left_shift', 'input' must be an integer, but got input:{type(input)}.")
|
||||
if _dtype not in white_list:
|
||||
raise TypeError(f"For 'bitwise_left_shift', 'other' must be a Tensor of int or uint, but got {_dtype}.")
|
||||
x = cast(x, other.dtype)
|
||||
input = cast(input, other.dtype)
|
||||
elif isinstance(other, numbers.Number):
|
||||
_dtype = x.dtype
|
||||
_dtype = input.dtype
|
||||
if not isinstance(other, int):
|
||||
raise TypeError(f"For 'bitwise_left_shift', 'other' must be an integer, but got other:{type(other)}.")
|
||||
if _dtype not in white_list:
|
||||
raise TypeError(f"For 'bitwise_left_shift', 'x' must be a Tensor of int or uint, but got {_dtype}.")
|
||||
other = cast(other, x.dtype)
|
||||
raise TypeError(f"For 'bitwise_left_shift', 'input' must be a Tensor of int or uint, but got {_dtype}.")
|
||||
other = cast(other, input.dtype)
|
||||
rs = ops.RightShift()
|
||||
return rs(x, other)
|
||||
return rs(input, other)
|
||||
|
||||
|
||||
def inv(x):
|
||||
|
|
Loading…
Reference in New Issue