Skip to content
class

InvertBackward

InvertBackward

Autograd node for element-wise bitwise NOT: y=∼xy = \mathtt{\sim}x.

Defined only for integer dtypes (including Bool); floating-point inputs are rejected upstream by AmpPolicy::KeepInput. Bitwise operations have no meaningful gradient — kHasGradient = false.

Math

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

For Bool inputs this is logical negation; for unsigned integers it produces the bitwise complement modulo 2bits2^{\text{bits}}.

Attributes

kSavesInputbool
false — nothing saved.
kHasGradientbool
false — autograd wiring skipped.
schema_v1OpSchema
Op name "invert" with AmpPolicy::KeepInput (prevents float promotion so the integer dtype is preserved).

Static methods

1
static

dispatch

int dispatch(backend::IBackend & be, const int & a, const int & s, Dtype dt)

Forward — calls IBackend::invert to compute y=∼xy = \mathtt{\sim} x (bitwise NOT) on integer dtypes.

Methods

1
fn

grad_formula

→Storage
int grad_formula(const int & g)

Zero-gradient sentinel; never invoked since kHasGradient = false.

Parameters

gconst Storage&
Incoming gradient (ignored).

Returns

Storage

Empty CpuStorage placeholder.