DriftTexture · function

halfPrecisionErrorBound

How far the half-precision evaluation of this network, at this input, can sit from the single-precision one.

Explained in DriftTexture.

function halfPrecisionErrorBound(shape: NetworkShape, weights: Float32Array, input: Float32Array): number
import { halfPrecisionErrorBound } from '@driftengine/texture';

Parameters

ParameterTypeDescription
shapeNetworkShape
weightsFloat32Array
inputFloat32Array

In depth

A bound per network rather than one tolerance for all, because a sampled tolerance is a claim about the corpus that sampled it — 2,400 networks put the worst relative error at 0.00213, the device's own corpus reached 0.0039, and 40,000 reached 0.0066. This carries the error instead: the weights' and the input's own rounding exactly, then half a unit in the last place for every product, every partial sum and the bias, through each layer — a rectifier moves no error, since it is one-Lipschitz. It holds whichever form a device computes: every operation rounded, or each multiply-add contracted into a single rounding, which WGSL permits and this project's development machine does. It assumes no value overflows, which activationBound is for.