flopscope.accounting.multi_dot_cost
flopscope.accounting.multi_dot_cost(shapes)[flopscope source]
Weighted FLOP cost of optimal matrix chain multiplication.
Parameters
- shapes:Sequence[Sequence[int]]
Operand shapes in the same order as the einsum operands.
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.
Uses dynamic programming for optimal parenthesization. Source: Cormen et al., Introduction to Algorithms (CLRS), §15.2.
Each binary matmul step (m x k) @ (k x n) is delegated to
matmul_cost(m, k, n) (= 2*m*k*n - m*n), matching fnp.matmul and
matrix_power_cost (issue #69 precedent).