Skip to content
fn

invert_op

→TensorImplPtr
int invert_op(const int & a)

Element-wise bitwise NOT — returns the bit-flipped tensor with the same integer dtype as a.

Not differentiable: output is detached from the autograd graph.

Math

yi=∼xiy_i = \mathtt{\sim} x_i

Shape

Output shape equals input shape (elementwise).

Parameters

aTensorImplPtr
Input tensor of integer dtype (Bool, Int8, Int16, Int32, Int64, or unsigned variants). Floating-point dtypes raise an error.

Returns

TensorImplPtr

New tensor with the bitwise complement; same shape, dtype, and device as a.

Raises

Errors if ``a`` has a floating-point dtype — bitwise NOT is only
defined on integers.

Notes

Exposed in Python as both invert and bitwise_not (reference framework alias).