Skip to content
fn

positive_mask_storage

→Storage
int positive_mask_storage(const int & s, int numel, Dtype dt, Device device)

Mask elements that are strictly positive: (s > 0) ? 1 : 0.

Used by the ReLU backward pass to gate the gradient through positive activations.

Parameters

sconst Storage&
Input buffer (typically the ReLU's saved input).
numelstd::size_t
Number of elements.
dtDtype
Output dtype.
deviceDevice
Target device.

Returns

Storage

New storage holding the {0, 1} gate.