A whole-numbered sample position v (already floored or rounded) as an index, whatever v is. NaN reads as 0 and a position past the int64 range saturates at its end — the reference reads its float positions this way, and so lands a NaN coordinate on sample 0. Casting an infinite or out-of-range float is undefined behaviour, and the CPU grid_sample went on to add 1 to the saturated int: grid_sample at x = inf or 1e10 died with SIGBUS (LCD-420). Callers compare the index with the extent before it addresses anything, and step to a neighbour with next_index.