Skip to content
fn

bitwise_and_op

→TensorImplPtr
int bitwise_and_op(const int & a, const int & b)

Python wrappers

Public Python APIs implemented by this engine symbol.

Element-wise bitwise AND.

Computes out[i] = a[i] & b[i] for every element. Defined on integer (I8/I16/I32/I64) and Bool dtypes; on Bool inputs the result is equivalent to logical AND.

Non-differentiable: bitwise operations have no meaningful gradient on integer manifolds, so no autograd node is registered.

Math

out[i]=a[i] ∧bit b[i]. \mathrm{out}[i] = a[i] \,\wedge_{\text{bit}}\, b[i].

References

NumPy numpy.bitwise_and.

See Also

bitwise_or_op, bitwise_xor_op

Parameters

a, bTensorImplPtr
Operands of identical shape, integer-or-Bool dtype, and device.

Returns

TensorImplPtr

Tensor of the same shape and dtype as the inputs.

Raises

LucidError
If shapes/devices differ, or if the input dtype is not integer or Bool.

Notes

  • No broadcasting — shapes must match exactly.
  • Floating-point inputs are rejected at the dispatch layer.

Examples

auto a = tensor({0b1100, 0b1010}, Dtype::I32);
    auto b = tensor({0b1010, 0b0110}, Dtype::I32);
    auto c = bitwise_and_op(a, b);  // {0b1000, 0b0010}