flopscope.accounting.vector_norm_cost
flopscope.accounting.vector_norm_cost(shape, ord=None)[flopscope source]
Weighted FLOP cost of vector norm.
Parameters
- shape:tuple
Shape of the array passed to the analytical cost formula.
- ord:object, optional
Argument forwarded to the analytical linalg.vector_norm cost formula. Defaults to
None.
Returns
- :int
Weighted public cost estimate, floored to match runtime accounting.
Notes
This helper multiplies the analytical FLOP count by the active weight from flopscope._weights and then applies int(...) so public estimates match budget deductions.
Standard norms (ord in {None, 0, 1, 2, inf, -inf}) cost 2*numel FLOPs (FMA=2: one multiply + accumulate per element). General-p norms cost 18*numel + 16 FLOPs per group: abs(1) + pow(16) per element + sum-reduce(1) + final root pow(16). The wrapper's n_groups multiplier scales the +16 correctly per group.