Skip to content
fn

neg_inplace_op

→TensorImplPtr
int neg_inplace_op(const int & a)

In-place element-wise negation: writes −x-x back into a.

Equivalent to a = neg_op(a) but reuses a's storage and bumps its version counter. Useful for negating large activations without allocating a second buffer.

Math

ai←−aia_i \leftarrow -a_i

See Also

neg_op — out-of-place counterpart.

Parameters

aTensorImplPtr
Tensor to negate in place. Must be non-null.

Returns

TensorImplPtr

The same pointer as a, now holding the negated storage.

Raises

ShapeMismatch
If neg_op returns a tensor whose shape differs from a->shape() (should never happen under the standard schema).