Commit ee6bb20
authored
Fix linearly indexed array math by reshaping arrays (#60164)
This was broken in #59961, as
`map` deals with trailing singleton axes differently from broadcasting:
```julia
julia> map(+, ones(1), ones(1,1)) |> size
(1,)
julia> broadcast(+, ones(1), ones(1,1)) |> size
(1, 1)
```
This PR limits the new method to the case where the ndims match, in
which case there are no trailing axes and the two are equivalent. The
alternate approach suggested in
#59961 (comment) is
to reshape the arrays, but this adds overhead that nullifies the
performance improvement for small arrays.1 parent cab2c74 commit ee6bb20
2 files changed
+31
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
14 | 25 | | |
15 | 26 | | |
16 | 27 | | |
| |||
28 | 39 | | |
29 | 40 | | |
30 | 41 | | |
31 | | - | |
32 | | - | |
33 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
34 | 46 | | |
35 | | - | |
| 47 | + | |
36 | 48 | | |
37 | 49 | | |
38 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2376 | 2376 | | |
2377 | 2377 | | |
2378 | 2378 | | |
| 2379 | + | |
| 2380 | + | |
| 2381 | + | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
0 commit comments