mindspore.ops.invert

mindspore.ops.invert(x)[source]

Flips all bits of input tensor element-wise.

\[out_i = \sim x_{i}\]
Parameters

x (Tensor) – The input Tensor.

Returns

Tensor, has the same shape as x.

Raises

TypeError – If dtype of x is neither int nor uint.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> x = Tensor(np.array([25, 4, 13, 9]), mindspore.int16)
>>> output = ops.invert(x)
>>> print(output)
[-26 -5 -14 -10]