Skip to content
fn

in_range_mask_storage

→Storage
int in_range_mask_storage(const int & s, double lo, double hi, int numel, Dtype dt, Device device, bool inclusive)

Mask elements that fall inside the closed range [lo, hi].

Returns 1 where lo <= s <= hi and 0 everywhere else, used by clamp / hardtanh backward passes to gate the gradient through the active region.

Parameters

sconst Storage&
Input buffer being clamped.
lo, hidouble
Inclusive lower / upper bounds.
numelstd::size_t
Number of elements.
dtDtype
Output dtype.
deviceDevice
Target device.

Returns

Storage

New storage holding the {0, 1} gate.