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
Reductionnumel(input)sum, mean, max, min, std, var, argmax, nansum
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.

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