Repository navigation
Commit a254e35
Move errors out of line, unroll stride normalization, extend unsafe_stridedview (#68)
* Move errors out of line, unroll stride normalization, extend unsafe_stridedview
- Throw errors from `@noinline` helpers, with `LazyString` messages where
they interpolate, so that building them does not end up in the callers.
- `permutedims` indexes the size and strides with `@inbounds`, since the
permutation has been checked; same for `_strides(::PermutedDimsArray)`.
- `unsafe_stridedview(a::StridedView, size, strides, offset)` replaces the
layout of a view while keeping its element type, parent and operation.
The strides are used as given, so this also supports zero strides.
- `_normalizestrides` is a fully unrolled scan, with the same results as
before (checked against the previous implementation in the tests).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Check slicing bounds, explain sreshape length mismatches, faster permutation check
- Slicing a `StridedView` (`getindex` with ranges and colons, `view` and
`sview`) now checks bounds; previously an out-of-range slice silently
produced a view outside the parent. The check can be skipped with
`@inbounds`.
- `sreshape` checks the lengths up front, with a message that gives both
sizes and lengths, instead of an empty `DimensionMismatch` from inside
`_computereshapestrides`, whose checks were therefore redundant.
- `_isperm` records the entries in a 64-bit mask for N <= 64, which is
O(N) without branches or allocations, instead of `Base.isperm`, which
is O(N^2) for tuples and allocates for vectors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fold the tuple and vector permutation checks into `_isperm`
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent 123036e commit a254e35
3 files changed
Lines changed: 222 additions & 58 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
3 | 19 | | |
4 | | - | |
5 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
6 | 36 | | |
7 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
8 | 51 | | |
9 | 52 | | |
10 | 53 | | |
| |||
30 | 73 | | |
31 | 74 | | |
32 | 75 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
46 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
47 | 95 | | |
48 | 96 | | |
49 | 97 | | |
| |||
107 | 155 | | |
108 | 156 | | |
109 | 157 | | |
110 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
111 | 162 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
| 163 | + | |
| 164 | + | |
123 | 165 | | |
124 | 166 | | |
125 | 167 | | |
| |||
137 | 179 | | |
138 | 180 | | |
139 | 181 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
| 182 | + | |
145 | 183 | | |
146 | 184 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | | - | |
63 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
64 | 74 | | |
65 | | - | |
| 75 | + | |
66 | 76 | | |
67 | 77 | | |
68 | 78 | | |
69 | 79 | | |
70 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
71 | 87 | | |
72 | 88 | | |
73 | 89 | | |
| |||
81 | 97 | | |
82 | 98 | | |
83 | 99 | | |
84 | | - | |
85 | | - | |
86 | | - | |
| 100 | + | |
| 101 | + | |
87 | 102 | | |
88 | 103 | | |
89 | 104 | | |
| |||
118 | 133 | | |
119 | 134 | | |
120 | 135 | | |
121 | | - | |
| 136 | + | |
122 | 137 | | |
123 | 138 | | |
124 | 139 | | |
| |||
152 | 167 | | |
153 | 168 | | |
154 | 169 | | |
155 | | - | |
| 170 | + | |
| 171 | + | |
156 | 172 | | |
157 | 173 | | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
| 174 | + | |
162 | 175 | | |
163 | 176 | | |
164 | 177 | | |
| |||
192 | 205 | | |
193 | 206 | | |
194 | 207 | | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
200 | 214 | | |
201 | 215 | | |
202 | 216 | | |
| |||
240 | 254 | | |
241 | 255 | | |
242 | 256 | | |
243 | | - | |
244 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
245 | 263 | | |
246 | 264 | | |
247 | 265 | | |
248 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
249 | 269 | | |
250 | 270 | | |
251 | | - | |
| 271 | + | |
252 | 272 | | |
253 | 273 | | |
254 | | - | |
| 274 | + | |
255 | 275 | | |
256 | 276 | | |
257 | 277 | | |
| |||
267 | 287 | | |
268 | 288 | | |
269 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
270 | 293 | | |
271 | 294 | | |
272 | 295 | | |
273 | | - | |
| 296 | + | |
274 | 297 | | |
| 298 | + | |
275 | 299 | | |
276 | | - | |
277 | 300 | | |
278 | 301 | | |
279 | 302 | | |
280 | 303 | | |
281 | | - | |
282 | | - | |
| 304 | + | |
| 305 | + | |
283 | 306 | | |
284 | 307 | | |
285 | 308 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
262 | 365 | | |
263 | 366 | | |
264 | 367 | | |
| |||
0 commit comments