add ops.arccos and tensor.arccos

This commit is contained in:
fandawei 2022-11-07 21:33:18 +08:00
parent b7793e49db
commit eb49e3f975
12 changed files with 49 additions and 19 deletions

View File

@ -146,6 +146,7 @@ mindspore.ops.function
mindspore.ops.absolute
mindspore.ops.accumulate_n
mindspore.ops.acos
mindspore.ops.arccos
mindspore.ops.acosh
mindspore.ops.add
mindspore.ops.addcdiv

View File

@ -0,0 +1,6 @@
mindspore.Tensor.acos
=====================
.. py:method:: mindspore.Tensor.acos()
详情请参考 :func:`mindspore.ops.acos`

View File

@ -0,0 +1,8 @@
mindspore.Tensor.arccos
=======================
.. py:method:: mindspore.Tensor.arccos()
Tensor.acos()的别名。
详情请参考 :func:`mindspore.ops.acos`

View File

@ -22,6 +22,7 @@ mindspore.Tensor
mindspore.Tensor.abs
mindspore.Tensor.absolute
mindspore.Tensor.acos
mindspore.Tensor.add
mindspore.Tensor.addcdiv
mindspore.Tensor.addcmul
@ -32,6 +33,7 @@ mindspore.Tensor
mindspore.Tensor.amin
mindspore.Tensor.any
mindspore.Tensor.approximate_equal
mindspore.Tensor.arccos
mindspore.Tensor.arccosh
mindspore.Tensor.arcsin
mindspore.Tensor.arcsinh

View File

@ -5,4 +5,4 @@ mindspore.ops.absolute
ops.abs()的别名。
详情请查看 :func:`mindspore.ops.abs`
详情请查看 :func:`mindspore.ops.abs`

View File

@ -0,0 +1,8 @@
mindspore.ops.arccos
====================
.. py:function:: mindspore.ops.arccos(x)
ops.acos()的别名。
详情请查看 :func:`mindspore.ops.acos`

View File

@ -28,6 +28,7 @@
mindspore.Tensor.abs
mindspore.Tensor.absolute
mindspore.Tensor.acos
mindspore.Tensor.add
mindspore.Tensor.addcdiv
mindspore.Tensor.addcmul
@ -38,6 +39,7 @@
mindspore.Tensor.amin
mindspore.Tensor.any
mindspore.Tensor.approximate_equal
mindspore.Tensor.arccos
mindspore.Tensor.arccosh
mindspore.Tensor.arcsin
mindspore.Tensor.arcsinh

View File

@ -144,6 +144,7 @@ Element-by-Element Operations
:template: classtemplate.rst
mindspore.ops.abs
mindspore.ops.absolute
mindspore.ops.accumulate_n
mindspore.ops.acos
mindspore.ops.acosh
@ -151,6 +152,7 @@ Element-by-Element Operations
mindspore.ops.addcdiv
mindspore.ops.addcmul
mindspore.ops.addn
mindspore.ops.arccos
mindspore.ops.arccosh
mindspore.ops.arcsin
mindspore.ops.arctan

View File

@ -329,6 +329,7 @@ BuiltInTypeMap &GetMethodMap() {
{"isfinite", std::string("isfinite")}, // P.isfinite()
{"cos", std::string("cos")}, // cos()
{"acos", std::string("acos")}, // acos()
{"arccos", std::string("acos")}, // acos()
{"acosh", std::string("acosh")}, // acosh()
{"sigmoid", std::string("sigmoid")}, // P.Sigmoid()
{"addr", std::string("addr")}, // addr()

View File

@ -1337,28 +1337,18 @@ class Tensor(Tensor_):
def acos(self):
r"""
Computes arccosine of input tensors element-wise.
.. math::
out_i = cos^{-1}(x_i)
Returns:
Tensor, has the same shape as `x`.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> from mindspore import Tensor
>>> a = Tensor(np.array([0.74, 0.04, 0.30, 0.56]), mindspore.float32)
>>> output = a.acos()
>>> print(output)
[0.737726 1.5307857 1.2661036 0.9764105]
For details, please refer to :func:`mindspore.ops.acos`.
"""
self._init_check()
return tensor_operator_registry.get('acos')(self)
def arccos(self):
r"""
Alias for Tensor.acos().
For details, please refer to :func:`mindspore.ops.acos`.
"""
return self.acos()
def cos(self):
r"""
Computes cosine of input element-wise.

View File

@ -218,6 +218,7 @@ from .math_func import (
tan,
asin,
acos,
arccos,
atan,
arcsin,
arccosh,

View File

@ -1547,6 +1547,14 @@ def acos(x):
return acos_(x)
def arccos(x):
"""
Alias for ops.acos().
For details, please refer to :func:`mindspore.ops.acos`.
"""
return acos(x)
def atan(x):
r"""
Computes the trigonometric inverse tangent of the input element-wise.
@ -7087,6 +7095,7 @@ __all__ = [
'tan',
'asin',
'acos',
'arccos',
'atan',
'sinh',
'cosh',