code wiki / (root) / nx_f32_upsample_bilinear.nx

nx_f32_upsample_bilinear.nx

buildroot/runtime/nx_f32_upsample_bilinear.nx

3657 B80 linesdepth 4pulls 6 transitivereach 2 importersview sourcekind librarytopic f32
docsdependenciesstructsconstsfunctions

about

nx_f32_upsample_bilinear.nx -- software-f32 BILINEAR upsample (NCHW, integer scale, align_corners=FALSE to match PyTorch/HF nn.functional.interpolate). The LAST vision op the pose port needed: ViTPose's SIMPLE decoder is ReLU -> bilinear-upsample(scale_factor) -> Conv2d, so a FAITHFUL port (bit-comparable to the reference) needs true bilinear, not nearest. Trick: with an INTEGER scale the sample coordinate src=(dst+0.5)/scale-0.5 is rational with denominator 2*scale, so ALL coordinate + weight math is exact INTEGER (floor, neighbor indices, the 4 bilinear weights that sum to (2*scale)^2); only the pixel combine + final /den^2 use f32. No f32 floor needed. Border: out-of-range neighbor indices clamp to [0,H-1]/[0,W-1] (PyTorch edge behavior). license_tier: ORIGINAL

dependencies 4 imports · 2 importers

nx_syscalls.nx nx_f32.nx nx_f32_cvt.nx nx_f32_div.nx nx_f32_upsample_bilinear.nx nx_f32_upsample_bilinear_gate.nx nx_vitpose_forward.nx

imports: nx_syscalls.nxnx_f32.nxnx_f32_cvt.nxnx_f32_div.nx

imported by: nx_f32_upsample_bilinear_gate.nxnx_vitpose_forward.nx

structs

none

consts

13const NX_UB_OK: i64 = 0
14const NX_UB_ERR_ARGS: i64 = 4

functions

16func nx_f32_upsample_bilinear(input: *i64, N: i64, C: i64, H: i64, W: i64, scale: i64, out: *i64) -> i64