flopscope.
Understanding Flopscope

Operation Categories

Use this page to understand which operations cost FLOPs, which are free, and which are unsupported.

You will learn:

  • How to identify free, counted, and blacklisted operations
  • What cost formulas apply to each counted sub-category
  • Which operations are blocked and why

Three categories

Every NumPy function falls into one of three categories in flopscope:

Free operations (0 FLOPs)

Operations that involve no arithmetic computation — just memory allocation, reshaping, or data movement.

Examples: zeros, ones, full, eye, arange, linspace, empty, reshape, transpose, concatenate, stack, split, squeeze, expand_dims, ravel, take, where, copy, astype, asarray

Counted operations (cost > 0)

Operations that perform arithmetic. Cost is computed analytically from tensor shapes.

Sub-categoryCost formulaExamples
Unarynumel(output)exp, log, sqrt, abs, sin, cos, tanh, ceil, floor
Binarynumel(output)add, multiply, maximum, divide, power, subtract
Reduction (Tier 1)unique inputs − unique outputs (+ divide for mean)sum, prod, max, min, mean, all, any, bitwise/logical reductions
Reduction (Tier 2)unique outputs × per-output costmedian, percentile, quantile
Einsumproduct of all index dimsfnp.einsum(...)
Dot/Matmulequivalent einsumfnp.dot(A, B), A @ B
Linalgper-operation formulafnp.linalg.solve, fnp.linalg.eigh, fnp.linalg.cholesky
FFT5 N log Nfnp.fft.fft, fnp.fft.rfft, fnp.fft.fft2
SVDm × n × kfnp.linalg.svd(A, k=10)
Sort/Searchn log n per slicesort, argsort, unique, searchsorted
Randomnumel(output)fnp.random.randn, fnp.random.normal, fnp.random.uniform
Statsflat per-element (varies)flops.stats.norm.pdf, flops.stats.expon.cdf, flops.stats.cauchy.ppf

When inputs are SymmetricTensor, many operations automatically get reduced costs. See Exploit Symmetry.

Reduction cost surfaces

flopscope splits reductions into two cost surfaces:

Tier 1 — additive accumulation (sum, prod, max, min, all, any, bitwise/logical or/and/xor, mean). Charges (unique input entries − unique output cells) + extra ops. mean adds one divide per unique output cell.

Tier 2 — selection-style reductions (median, percentile, quantile). Charges (unique output cells) × (per-output cost). Each output cell needs a full partition pass over the reduced axes; symmetry helps when output cells share an orbit.

See Symmetry-aware FLOP counting for the mental model and worked examples.

Blacklisted operations

Operations not relevant to numerical computation. Calling them raises an AttributeError. These are I/O, configuration, datetime, and display functions that have no meaningful FLOP cost.

fnp.save(array, "file.npy")
# AttributeError: flopscope does not support 'save' (blacklisted). Save array to .npy file. Not supported.. Did you mean: 'ravel'?

Blacklisted categories: I/O (save, load, loadtxt, savetxt, savez, genfromtxt), configuration (seterr, geterr, setbufsize), datetime (busday_count, is_busday), display (array2string, array_repr), functional (apply_along_axis, piecewise, frompyfunc).

See API Reference for the complete list.

On this page