Skip to content
fn

mul_inplace_op

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

In-place elementwise multiplication: writes a⋅ba \cdot b back into a.

Math

ai←ai⋅bia_i \leftarrow a_i \cdot b_i

See Also

mul_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 broadcastable into a->shape().

Returns

TensorImplPtr

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

Raises

ShapeMismatch
If the broadcast output would change a's shape.
RuntimeError
If a shares storage with a view.

Notes

Common usage: scaling gradients (grad_.mul_(scale)) or applying element-wise masks (out_.mul_(mask)) without allocating a new buffer per step.