fn

eq

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

Element-wise equality predicate.

Element-wise comparison with broadcasting; the result is a boolean tensor that is True where input equals other and False elsewhere. Python scalars on either side are promoted to a matching tensor before the comparison.

Parameters

inputTensor
Left operand.
otherTensor or scalar
Right operand. Broadcasts against input.

Returns

Tensor

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

Notes

Mathematical definition:

outi=(inputi=otheri)\text{out}_i = (\text{input}_i = \text{other}_i)

Floating-point comparison is exact bit-pattern equality / strict ordering; NaN entries are never equal to anything and produce False for ordering predicates. For tolerance-based comparison use isclose. Comparison operations are not differentiable; gradients passed to them are dropped.

Examples

>>> import lucid
>>> a = lucid.tensor([1.0, 2.0, 3.0])
>>> b = lucid.tensor([1.0, 5.0, 2.0])
>>> lucid.eq(a, b)
Tensor([...])