Commit 3ebbe29
authored
perf: cache dimension computations (#542)
This PR adds some `functools.cache` decorations to a few functions for
computing dimensions, which are repeatedly computed for the same inputs
many times.
This does trade some space to reduce duration of conversion. That space will
scale with the number of unique combinations of shape, strides, dtypes, and
memory ordering.
If someone has a lot of arrays that have different shapes,
strides, dtypes, and memory ordering, the cache can potentially use a
lot of memory.
I'm not sure that's a likely scenario, but it's worth pointing out as a potential issue.1 parent 2567b28 commit 3ebbe29
File tree
8 files changed
+43
-23
lines changed- numba_cuda/numba/cuda
- cudadrv
8 files changed
+43
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | 42 | | |
44 | 43 | | |
45 | | - | |
| 44 | + | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
20 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
21 | 28 | | |
22 | 29 | | |
23 | 30 | | |
| 31 | + | |
24 | 32 | | |
25 | | - | |
26 | | - | |
| 33 | + | |
| 34 | + | |
27 | 35 | | |
28 | | - | |
| 36 | + | |
29 | 37 | | |
30 | 38 | | |
31 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
32 | 42 | | |
33 | 43 | | |
34 | 44 | | |
35 | | - | |
| 45 | + | |
36 | 46 | | |
37 | 47 | | |
38 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
91 | 96 | | |
92 | 97 | | |
93 | 98 | | |
| |||
96 | 101 | | |
97 | 102 | | |
98 | 103 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
| |||
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
124 | | - | |
125 | | - | |
| 126 | + | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
130 | | - | |
| 132 | + | |
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
134 | | - | |
| 136 | + | |
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3023 | 3023 | | |
3024 | 3024 | | |
3025 | 3025 | | |
| 3026 | + | |
3026 | 3027 | | |
3027 | 3028 | | |
3028 | 3029 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
245 | 246 | | |
246 | 247 | | |
247 | 248 | | |
| 249 | + | |
248 | 250 | | |
249 | 251 | | |
250 | 252 | | |
| 253 | + | |
| 254 | + | |
251 | 255 | | |
252 | 256 | | |
253 | 257 | | |
| |||
442 | 446 | | |
443 | 447 | | |
444 | 448 | | |
445 | | - | |
446 | | - | |
| 449 | + | |
| 450 | + | |
447 | 451 | | |
448 | 452 | | |
449 | 453 | | |
| |||
471 | 475 | | |
472 | 476 | | |
473 | 477 | | |
474 | | - | |
475 | | - | |
| 478 | + | |
| 479 | + | |
476 | 480 | | |
477 | 481 | | |
478 | 482 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1629 | 1629 | | |
1630 | 1630 | | |
1631 | 1631 | | |
1632 | | - | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
1633 | 1635 | | |
1634 | 1636 | | |
| 1637 | + | |
1635 | 1638 | | |
1636 | | - | |
| 1639 | + | |
| 1640 | + | |
1637 | 1641 | | |
1638 | 1642 | | |
1639 | 1643 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
| 201 | + | |
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| |||
0 commit comments