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)
| 21 | |
| 22 | |
| 23 | def _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 | |
| 61 | def _compute_size_by_dict(indices, idx_dict): |
| 62 | """ |
no test coverage detected
searching dependent graphs…