def rne_f
import bendtorch@1.3.0.0/dtype.bend as Dtypeimport Base
308# v rounded to the nearest integer, ties to even (torch.round), for |v| < 2^23 (here |v| <= 127 and a bit)
309def rne_f(+v: F32) -> F32:
310 +f = F32.floor(v)
311 +d = (v - f : F32)
312 +h = (f * 0.5 : F32)
313 +up = Bool.or(F32.is_gt(d, 0.5), Bool.and(F32.is_eq(d, 0.5), F32.is_ne(F32.floor(h), h)))
314 pick_f(up, (f + 1.0 : F32), f)