Skip to main content

div_eps

Function div_eps 

Source
pub fn div_eps(dtype: DType) -> f32
Expand description

A small dtype-specific epsilon for safe division (x / (y + eps)), returned as f32.

The value is chosen per float format as the geometric mean (average in log10 space) of two reference magnitudes: a scaled function of the format’s minimum exponent and the format’s machine epsilon. This places eps comfortably above the denormal/underflow floor while staying negligible relative to typical activations, for each of f64/f32/f16/bf16. The resulting constants are noted inline. dtype is the runtime float dtype of the tensor being divided (e.g. x.dtype()). Panics on non-float dtypes.