flopscope.accounting.tensorsolve_cost
flopscope.accounting.tensorsolve_cost(a_shape)[flopscope source]
Weighted FLOP cost of tensor solve.
Parameters
- a_shape:tuple
Argument forwarded to the analytical linalg.tensorsolve cost formula.
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.
flops.linalg.tensorsolve(a, b, axes=...) optionally transposes a
to move axes to the trailing positions, then reshapes the result to
a square (n, n) system before delegating to solve. A transpose
only reorders axes, so it never changes a's total element count, and
numpy requires a.size == n**2 for any valid call (it raises
otherwise) -- both regardless of axes and of b's rank. So
n = isqrt(prod(a_shape)) recovers the true solved dimension directly
from a's original (untransposed) shape, without needing to locate
the reshape split point.