Commit 174e1ba
Small fixes to improve TensorIterator overhead for the common case of inputs and outputs of the same type (#27457)
Summary:
1) Short-circuits computing common type and type promotion logic for the common case of operands and result of the same type
2) Improves performance of checking memory overlap by returning MemoryOverlap::FULL if tensors are the same, skips the call
from TensorIterator when tensors are the same
3) Changes the default size of DimVector from 5 to 6, thus allowing it not to be resized for a common case of binary operation. `strides`
DimVector is forced to have at least 2*num_tensors elements, which for an operation with 2 inputs and one output is 6
4) If `offset` is 0 (common non-broadcasting case), don't fill `strides` vector with 0-s, because all the values will be subsequently written to.
These changes combined improve the overhead from 1.02 us to .74 us for a simple in-place operation.
Pull Request resolved: #27457
Test Plan: should be covered by existing tests
Differential Revision: D17784532
Pulled By: ngimel
fbshipit-source-id: e6a8ee58be5de14461bdbc2e2b0b6d16a96c309f1 parent 3ac4267 commit 174e1ba
File tree
3 files changed
+56
-23
lines changed- aten/src/ATen
- native
3 files changed
+56
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | | - | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
92 | 118 | | |
93 | 119 | | |
94 | 120 | | |
95 | 121 | | |
96 | | - | |
| 122 | + | |
97 | 123 | | |
98 | 124 | | |
99 | 125 | | |
100 | 126 | | |
101 | | - | |
| 127 | + | |
102 | 128 | | |
103 | 129 | | |
104 | 130 | | |
| |||
199 | 225 | | |
200 | 226 | | |
201 | 227 | | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
207 | 235 | | |
208 | 236 | | |
209 | 237 | | |
| |||
221 | 249 | | |
222 | 250 | | |
223 | 251 | | |
224 | | - | |
225 | | - | |
| 252 | + | |
| 253 | + | |
226 | 254 | | |
227 | 255 | | |
228 | 256 | | |
| |||
369 | 397 | | |
370 | 398 | | |
371 | 399 | | |
372 | | - | |
| 400 | + | |
373 | 401 | | |
374 | | - | |
| 402 | + | |
375 | 403 | | |
376 | 404 | | |
377 | 405 | | |
| |||
478 | 506 | | |
479 | 507 | | |
480 | 508 | | |
481 | | - | |
482 | | - | |
| 509 | + | |
| 510 | + | |
483 | 511 | | |
484 | 512 | | |
485 | 513 | | |
| |||
751 | 779 | | |
752 | 780 | | |
753 | 781 | | |
754 | | - | |
755 | | - | |
756 | 782 | | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
757 | 787 | | |
758 | 788 | | |
759 | 789 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
88 | | - | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
| 138 | + | |
137 | 139 | | |
138 | 140 | | |
139 | 141 | | |
| |||
254 | 256 | | |
255 | 257 | | |
256 | 258 | | |
257 | | - | |
| 259 | + | |
258 | 260 | | |
259 | 261 | | |
260 | 262 | | |
261 | 263 | | |
262 | 264 | | |
263 | 265 | | |
264 | | - | |
265 | | - | |
266 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
267 | 269 | | |
268 | 270 | | |
269 | 271 | | |
| |||
328 | 330 | | |
329 | 331 | | |
330 | 332 | | |
331 | | - | |
| 333 | + | |
332 | 334 | | |
333 | 335 | | |
334 | 336 | | |
| |||
0 commit comments