fn
in_range_mask_storage
→Storageint in_range_mask_storage(const int & s, double lo, double hi, int numel, Dtype dt, Device device)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, hidoubleInclusive lower / upper bounds.
numelstd::size_tNumber of elements.
dtDtypeOutput dtype.
deviceDeviceTarget device.
Returns
StorageNew storage holding the {0, 1} gate.