Skip to main content

Function: computeLatentRanges()

computeLatentRanges(data, gridLevels, perLevel?): [number, number][]

CPU-side per-level (or global) min/max reduction over a flat latent-grid Float32Array, used to implement quantization.range === 'auto' (see resolveQuantizationConfig above). gridLevels is the layout.gridLevels array every trainer's GPUModel already builds ({ offset, floatCount, ... }

  • see NTCGPUModel.js/(removed, appearance deleted)'s computeXXXModelLayout), so this works identically for both trainers without either one re-deriving level byte ranges. Grids are small (a few thousand texels at most per level), so a plain CPU scan is fast enough - no GPU reduction kernel is needed (see NeuralAppearanceTrainer.js/ NTCTrainer.js for how often this actually runs).

Returns one [min, max] tuple per grid level. When perLevel is false, every level gets the same tuple - the global min/max across every level

  • rather than the caller having to special-case a single shared range downstream (the GPU kernels always index one range per level regardless of perLevel). A level with zero texels (degenerate, shouldn't normally happen) or a perfectly flat buffer falls back to [-1, 1] rather than [Infinity, -Infinity]/[x, x], mirroring encodeUint8Base64's min === max no-NaN guard.

Parameters​

data​

Float32Array

gridLevels​

GridLevelLayout[]

perLevel?​

boolean = true

Returns​

[number, number][]