Python wrappers
Public Python APIs implemented by this engine symbol.Autograd node for the tensor p-norm.
Reproduces expand_back at backward time using the saved
axis_ / keepdims_ hyperparameters; saves both the input
(for the L2 numerator) and the reduced norm (to avoid
recomputation).
Math
Shape
A: arbitrary float shape.N:A's shape withaxis_removed (keepdims=false) or set to 1 (keepdims=true); scalar ifaxis_is empty andkeepdims=false.- Output gradient: same shape as
A.
References
Petersen & Pedersen, The Matrix Cookbook (2012), §2.5. Horn & Johnson, Matrix Analysis (2nd ed.), §5.6 (matrix norms).
Attributes
schema_v1OpSchema"norm", one input, AmpPolicy::KeepInput so the A/N division does not lose precision via AMP downcasting.ord_doubleNorm order used in the forward pass (1.0 or 2.0 supported in backward; other values raise
not_implemented at backward time).axis_std::vector<int>Axes that were reduced. Empty means a full reduction over all elements. Indices may be negative; they are normalised when re-inserting axes during
expand_back.keepdims_boolWhether reduced axes were retained as size-1 stubs in the output shape.
saved_inputs_[0]StorageStorage of the forward input (needed for ord=2 numerator and ord=1 sign).
saved_output_StorageStorage of the reduced norm (used as the ord=2 denominator).
Raises
NotImplementedErrorIf
ord_ is neither 1.0 nor 2.0 when apply is invoked.Instance methods
1Compute the gradient {∂L/∂A} from the upstream gradient.
Parameters
grad_outStorageUpstream gradient with shape matching
out_shape_.Returns
std::vector<Storage>Single-entry vector {∂L/∂A} aligned with the one differentiable input slot.
Raises
NotImplementedErrorIf
ord_ is not 1.0 or 2.0.