MCPcopy Create free account
hub / github.com/numpy/numpy / _flop_count

Function _flop_count

numpy/core/einsumfunc.py:18–54  ·  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

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

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