TensorPlay
latest (dev)
Copy
View Markdown

Latest development documentation · Updated 2026-10-15

tensorplay.functional.logical_xor

tensorplay.functional.logical_xor(input: Tensor, other: Tensor, *, out: Tensor | None) → Tensor[source]

Computes the element-wise logical XOR of the given input tensors. Zeros are treated as False and nonzeros are treated as True.

Parameters:
  • input (Tensor) – the input tensor.

  • other (Tensor) – the tensor to compute XOR with

Keyword Arguments:

out (Tensor, optional) – the output tensor.

Example:

>>> tensorplay.logical_xor(tensorplay.tensor([True, False, True]), tensorplay.tensor([True, False, False]))
tensor([False, False,  True])
>>> a = tensorplay.tensor([0, 1, 10, 0], dtype=tensorplay.int8)
>>> b = tensorplay.tensor([4, 0, 1, 0], dtype=tensorplay.int8)
>>> tensorplay.logical_xor(a, b)
tensor([ True,  True, False, False])
>>> tensorplay.logical_xor(a.double(), b.double())
tensor([ True,  True, False, False])
>>> tensorplay.logical_xor(a.double(), b)
tensor([ True,  True, False, False])
>>> tensorplay.logical_xor(a, b, out=tensorplay.empty(4, dtype=tensorplay.bool))
tensor([ True,  True, False, False])

On this page

Ask DeepWiki