Skip to content
tmpl

replace_nonfinite

void replace_nonfinite()

out[i] = in[i] with NaN, +inf and -inf replaced, over n words.

The replacements arrive already in the format's own bits. The caller rounds each double the way a cast to the dtype would (through float for the 16-bit formats, as the reference framework's half types do), so a value the format cannot hold becomes its infinity, as the reference framework's cast makes it. Every other word is copied bit for bit: -0, subnormals and NaN payloads are untouched where they are not replaced.

A complex tensor is passed as its 2 n interleaved parts. Each part is replaced on its own, which is the reference framework's rule for complex input.

Parameters

inconst void*
n contiguous words.
outvoid*
n words.
nstd::size_t
Word count.
nan_bits, posinf_bits, neginf_bitsFormat::Word
The replacements.
grainstd::size_t
Smallest chunk handed to another core (cpu::parallel_for).