mindspore.Tensor.mul_

View Source On Gitee
Tensor.mul_(other) Tensor

Multiplies two tensors element-wise.

\[out_{i} = tensor_{i} * other_{i}\]

Warning

This is an experimental API that is subject to change or deletion.

Note

  • When self and other have different shapes, other be able to broadcast to a self.

  • self and other can not be bool type at the same time, [True, Tensor(True, bool_), Tensor(np.array([True]), bool_)] are all considered bool type.

Parameters

other (Union[Tensor, number.Number, bool]) – other is a number.Number or a bool or a tensor whose data type is number.Number and bool.

Returns

Tensor, the shape is the same as self , and the data type is the same as self .

Raises
  • TypeError – If other is not one of the following: Tensor, number.Number, bool.

  • RuntimeError – If other cannot be broadcast to self.

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor
>>> 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.]
>>> print(x)
[ 4. 10. 18.]