From 2cab180e3a4e508079716e9600d14bb243fc82e5 Mon Sep 17 00:00:00 2001 From: zhangzhaoju Date: Mon, 9 Jan 2023 10:45:58 +0800 Subject: [PATCH] add doc desc for mul primitive --- .../api_python/mindspore/mindspore.Tensor.rst | 1 + docs/api/api_python_en/Tensor_list.rst | 1 + mindspore/python/mindspore/common/tensor.py | 34 +------------------ tests/vm_impl/math_ops_vm_impl.py | 12 +++++++ 4 files changed, 15 insertions(+), 33 deletions(-) diff --git a/docs/api/api_python/mindspore/mindspore.Tensor.rst b/docs/api/api_python/mindspore/mindspore.Tensor.rst index 1dbd6e91513..59ed8c897bd 100644 --- a/docs/api/api_python/mindspore/mindspore.Tensor.rst +++ b/docs/api/api_python/mindspore/mindspore.Tensor.rst @@ -199,6 +199,7 @@ mindspore.Tensor mindspore.Tensor.moveaxis mindspore.Tensor.msort mindspore.Tensor.mT + mindspore.Tensor.mul mindspore.Tensor.multiply mindspore.Tensor.nan_to_num mindspore.Tensor.nansum diff --git a/docs/api/api_python_en/Tensor_list.rst b/docs/api/api_python_en/Tensor_list.rst index 47b2bccd8fd..5384ba93736 100644 --- a/docs/api/api_python_en/Tensor_list.rst +++ b/docs/api/api_python_en/Tensor_list.rst @@ -205,6 +205,7 @@ mindspore.Tensor.moveaxis mindspore.Tensor.msort mindspore.Tensor.mT + mindspore.Tensor.mul mindspore.Tensor.multiply mindspore.Tensor.nan_to_num mindspore.Tensor.nansum diff --git a/mindspore/python/mindspore/common/tensor.py b/mindspore/python/mindspore/common/tensor.py index 04c818e06cb..d7494a0d7ba 100644 --- a/mindspore/python/mindspore/common/tensor.py +++ b/mindspore/python/mindspore/common/tensor.py @@ -4037,39 +4037,7 @@ class Tensor(Tensor_): def mul(self, value): r""" - Multiplies two tensors element-wise. - - .. note:: - - Inputs of input tensor and `value` comply with the implicit type conversion rules to make - the data types consistent. - - The inputs must be two tensors or one tensor and one scalar. - - When the inputs are two tensors, - dtypes of them cannot be bool at the same time, and the shapes of them can be broadcast. - - When the inputs are one tensor and one scalar, the scalar could only be a constant. - - Args: - value (Union[Tensor, number.Number, bool]): The second input, when the first input is a Tensor, - the second input should be a number.Number or bool value, or a Tensor whose data type is number - or bool\_. When the first input is Scalar, the second input must be a Tensor whose data type is - number or bool\_. - - Returns: - Tensor, the shape is the same as the one after broadcasting, - and the data type is the one with higher precision or higher digits among the two inputs. - - Raises: - TypeError: If input tensor and `value` is not one of the following: Tensor, number.Number, bool. - ValueError: If input tensor and `value` are not the same shape. - - Supported Platforms: - ``Ascend`` ``GPU`` ``CPU`` - - Examples: - >>> x = Tensor(np.array([1.0, 2.0, 3.0]), mindspore.float32) - >>> y = Tensor(np.array([4.0, 5.0, 6.0]), mindspore.float32) - >>> output = x.mul(y) - >>> print(output) - [ 4. 10. 18.] + For details, please refer to :func:`mindspore.ops.mul`. """ self._init_check() return tensor_operator_registry.get('mul')(self, value) diff --git a/tests/vm_impl/math_ops_vm_impl.py b/tests/vm_impl/math_ops_vm_impl.py index f9e1cd3af82..21c9cb87e7e 100644 --- a/tests/vm_impl/math_ops_vm_impl.py +++ b/tests/vm_impl/math_ops_vm_impl.py @@ -133,6 +133,18 @@ def vm_impl_mul(self): return vm_impl +@vm_impl_getters.register(P.Conj) +def vm_impl_conj(self): + """Generate vm_impl function for Conj.""" + + def vm_impl(x): + x = x.asnumpy() + t = np.conj(x) + return Tensor(t) + + return vm_impl + + @vm_impl_getters.register(P.Square) def vm_impl_square(self): """Generate vm_impl function for Square."""