Skip to content
fn

clip_inplace_op

→TensorImplPtr
int clip_inplace_op(const int & a, double lo, double hi)

In-place clip / clamp: writes clip(x,lo,hi)\mathrm{clip}(x, \mathit{lo}, \mathit{hi}) back into a.

Math

ai←min⁡(hi,max⁡(lo,ai))a_i \leftarrow \min(\mathit{hi}, \max(\mathit{lo}, a_i))

See Also

clip_op — out-of-place counterpart.

Parameters

aTensorImplPtr
Tensor to clip in place. Must be non-null.
lodouble
Lower bound; values below lo are set to lo.
hidouble
Upper bound; values above hi are set to hi.

Returns

TensorImplPtr

The same pointer as a.

Notes

Implemented directly (without going through the generic inplace_unary helper) because the two scalar parameters lo / hi cannot be threaded through the zero-argument function-pointer template the other entry points use.