Commit f164d70
committed
Simplify copy kernel
Using the new type promotion and dynamic casting added to
`TensorIterator`, the copy kernels could be greatly simplified.
**Script:**
```python
import torch
import timeit
import pandas
import itertools
from tqdm import tqdm
import math
print(torch.__version__)
print()
_10M = 10 * 1024 ** 2
d = {}
for from_, to in tqdm(itertools.product(torch.testing.get_all_dtypes(),
repeat=2)):
if from_ not in d:
d[from_] = {}
a = torch.zeros(_10M, dtype=from_)
min_ = math.inf
for i in range(100):
start = timeit.default_timer()
a.to(to)
end = timeit.default_timer()
elapsed = end - start
if elapsed < min_:
min_ = elapsed
d[from_][to] = int(elapsed * 1000 * 1000)
pandas.DataFrame(d)
```
**Before:**

**After:**

ghstack-source-id: 1269ecc
Pull Request resolved: #284281 parent 11f4039 commit f164d70
1 file changed
+5
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | 17 | | |
26 | 18 | | |
27 | 19 | | |
| |||
66 | 58 | | |
67 | 59 | | |
68 | 60 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
74 | 66 | | |
75 | 67 | | |
76 | 68 | | |
| |||
0 commit comments