mindspore.ops.LogicalXor

class mindspore.ops.LogicalXor[source]

Computes the “logical XOR” of two tensors element-wise.

Warning

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

Refer to mindspore.ops.logical_xor() for more details.

Inputs:
  • x (Union[Tensor, bool]) - The first input is a bool or a tensor whose data type can be implicitly converted to bool.

  • y (Union[Tensor, bool]) - The second input is a bool when the first input is a tensor or a tensor whose data type can be implicitly converted to bool.

Outputs:

Tensor, the shape is the same as the x and y after broadcasting, and the data type is bool.

Supported Platforms:

Ascend CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> x = Tensor(np.array([True, False, True]), mindspore.bool_)
>>> y = Tensor(np.array([True, True, False]), mindspore.bool_)
>>> logical_xor = ops.LogicalXor()
>>> output = logical_xor(x, y)
>>> print(output)
[ False True True]
>>> x = Tensor(1, mindspore.bool_)
>>> y = Tensor(0, mindspore.bool_)
>>> output = ops.LogicalXor()(x, y)
>>> print(output)
True
>>> x = True
>>> y = Tensor(0, mindspore.bool_)
>>> output = ops.LogicalXor()(x, y)
>>> print(output)
True
>>> x = True
>>> y = Tensor(np.array([True, False]), mindspore.bool_)
>>> output = ops.LogicalXor()(x, y)
>>> print(output)
[False True]