Skip to content
fn

add_inplace_op

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

In-place elementwise addition: writes a+ba + b back into a.

Equivalent to a = add_op(a, b) but reuses a's storage and bumps its version counter. b may broadcast up to a's shape but the broadcast output shape must equal a->shape().

Math

ai←ai+bia_i \leftarrow a_i + b_i

See Also

add_op — out-of-place counterpart.

Parameters

aTensorImplPtr
Left operand and in-place target. Must be non-null and must not share storage with a view.
bTensorImplPtr
Right operand. Must be non-null and have a shape broadcastable to a->shape() such that the broadcast result equals a->shape().

Returns

TensorImplPtr

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

Raises

ShapeMismatch
If the broadcast output of add_op(a, b) does not equal a->shape() (i.e. a would have to grow to fit the result).
RuntimeError
If a shares storage with a view (call .clone() first).