fn

logical_or

Tensor
logical_or(input: Tensor, other: Tensor | Scalar)
source

Element-wise logical OR.

Element-wise boolean operation. Non-boolean inputs are first reduced to their truthiness (False iff the value is exactly zero) before the operation is applied. The output dtype is bool.

Parameters

inputTensor
Left operand (treated as boolean).
otherTensor or scalar
Right operand (treated as boolean). Broadcasts against input.

Returns

Tensor

Boolean tensor with shape broadcast(input.shape, other.shape).

Notes

Mathematical definition (with xˉ\bar x denoting boolean coercion):

outi=xˉiyˉi\text{out}_i = \bar{x}_i \lor \bar{y}_i

Logical operations are not differentiable; gradients are dropped. Equivalent to input.bool() | other.bool().

Examples

>>> import lucid
>>> a = lucid.tensor([True, False, True])
>>> b = lucid.tensor([True, True, False])
>>> lucid.logical_or(a, b)
Tensor([...])