Python wrappers
Public Python APIs implemented by this engine symbol.Compute the biased variance of a along axes.
Uses the population estimator
— i.e. the
denominator is , not . This corresponds to the reference
framework's unbiased=False (population) variant; the unbiased /
sample variant is not exposed by this entry point. The standard
deviation std_op is built directly on top by composing
sqrt with this op so the autograd chain is automatic.
During the forward pass the mean is computed once with
keepdims=true and broadcast to the full input shape so that
VarBackward::apply can compute without a second
broadcast call. Both the input x and the broadcast mean are
saved on the backward node.
Math
Shape
If keepdims is false, the reduced axes are removed; if
true, they become size-.
See Also
std_op — square root of the variance.
Parameters
aTensorImplPtraxesstd::vector<int>ndim.keepdimsbooltrue, retains reduced dims as size-1 entries; otherwise they are collapsed.Returns
TensorImplPtrOutput tensor with the reduced shape. Autograd is wired when a->requires_grad() is true and GradMode is enabled.
Notes
Internal dispatch: IBackend::variance — Accelerate on CPU, MLX
on GPU. The CPU implementation uses Welford-style accumulation for
numerical stability on large . The empty-axis edge case
(reduced == 0) clamps the count to to avoid a division by
zero in the backward node; in that pathological case the gradient is
not statistically meaningful but is well-defined.