Python wrappers
Public Python APIs implemented by this engine symbol.Autograd node for mean-squared-error loss.
Computes
with Mean reduction; for Sum the leading factor is dropped, and
for None the full per-element squared error is
returned without reduction. Both input and target are saved so that
the backward pass can re-emit
(or
for Sum, or for None).
Math
Attributes
schema_v1OpSchema"mse_loss", AmpPolicy::ForceFP32.reduction_ReductionReduction mode applied by the forward and unwound by the backward.
orig_shape_ShapeElement-wise shape before reduction; needed to broadcast
grad_out back to the input shape during apply.Notes
Gradient magnitude scales linearly with the residual, so MSE is sensitive
to outliers. Prefer HuberLoss when robustness matters.
Static methods
1static
forward
→TensorImplPtrint forward(const int & input, const int & target, Reduction reduction)Compute the MSE loss with autograd wiring.
Parameters
inputTensorImplPtrPredicted tensor of arbitrary shape.
targetTensorImplPtrGround-truth tensor. Must share
input's shape and dtype.reductionReductionMean, Sum, or None.Returns
TensorImplPtrScalar (Mean / Sum) or per-element (None) loss tensor.
Raises
ShapeMismatchIf
input.shape() != target.shape().DtypeMismatchIf
input.dtype() != target.dtype().