MCPcopy Index your code
hub / github.com/numpy/numpy / _flop_count

Function _flop_count

numpy/_core/einsumfunc.py:23–59  ·  view source on GitHub ↗

Computes the number of FLOPS in the contraction. Parameters ---------- idx_contraction : iterable The indices involved in the contraction inner : bool Does this contraction require an inner product? num_terms : int The number of terms in a contractio

(idx_contraction, inner, num_terms, size_dictionary)

Source from the content-addressed store, hash-verified

21
22
23def _flop_count(idx_contraction, inner, num_terms, size_dictionary):
24 """
25 Computes the number of FLOPS in the contraction.
26
27 Parameters
28 ----------
29 idx_contraction : iterable
30 The indices involved in the contraction
31 inner : bool
32 Does this contraction require an inner product?
33 num_terms : int
34 The number of terms in a contraction
35 size_dictionary : dict
36 The size of each of the indices in idx_contraction
37
38 Returns
39 -------
40 flop_count : int
41 The total number of FLOPS required for the contraction.
42
43 Examples
44 --------
45
46 >>> _flop_count('abc', False, 1, {'a': 2, 'b':3, 'c':5})
47 30
48
49 >>> _flop_count('abc', True, 2, {'a': 2, 'b':3, 'c':5})
50 60
51
52 """
53
54 overall_size = _compute_size_by_dict(idx_contraction, size_dictionary)
55 op_factor = max(1, num_terms - 1)
56 if inner:
57 op_factor += 1
58
59 return overall_size * op_factor
60
61def _compute_size_by_dict(indices, idx_dict):
62 """

Callers 4

_optimal_pathFunction · 0.85
_greedy_pathFunction · 0.85
einsum_pathFunction · 0.85

Calls 2

_compute_size_by_dictFunction · 0.85
maxFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…