Repository navigation
Commit d52d9f3
authored
Vulkan: take im2col when the gather is cheap, not only when c_out is large
**Updated twice; this is the third rule.** Both earlier versions regressed a model, so the history is worth stating:
- A `c_out` gate regressed fast_sam on Mali by 18% (GPU 345 -> 405 ms). Its 80x80 convolutions have `c_out` 64, so the gate pushed them onto the direct shader.
- Bounding the gather size regressed fcn_resnet50 by 19% (2938 -> 3505 ms). Its head is a 2048->512 3x3 at 65x65, which wants a 77.9M element gather but reads it back 512 times, so it is exactly the case im2col exists for.
Neither variable works alone because they are **independent reasons** to take im2col. A large gather is fine when `c_out` is large, since the GEMM amortizes it `c_out` times. When `c_out` is small it is only worth paying if the matrix is small outright, which is where the direct shader on Mali loses badly.
So this keeps upstream's `c_out` rule and adds a cheap-gather disjunct, scoped to Mali so no other device changes behaviour.
Mali-G76 (Galaxy S10+), fp16, interleaved GPU timestamps, median. "before" is upstream today:
| model | before | c_out gate | gather bound | **this** |
| --- | --- | --- | --- | --- |
| style_transfer_candy @640 | 1912.15 | 1436.31 | 1410.94 | **1411.67** |
| fast_sam s @640 | 345.09 | 404.54 | n/a | **341.61** |
| fcn_resnet50 @520 | 2938.13 | 2993.47 | 3505.06 | **2948.10** |
fcn gives up 0.3%, at the edge of the run-to-run range. The other two are wins, and neither earlier rule was a win on all three.
Regression check (these runners also carry pytorch#22784, which is why the mobilenet models move):
| model | before | this |
| --- | --- | --- |
| lraspp @520 | 71.28 | 67.78 |
| deeplabv3-mnv3 @520 | 165.27 | 161.76 |
| selfie @256 | 6.49 | 6.18 |
| ssdlite320 | 37.79 | 35.80 |
32M is calibrated on this device, not derived. The cases it separates are far apart (~4M and ~30M on one side, ~100M and up on the other), so the exact value is not delicate, but a maintainer with other Mali parts may want to revisit it. Adreno is deliberately untouched.
cc @SS-JIA @manuelcandales @digantdesai @cbilgin1 parent 94a7536 commit d52d9f3
1 file changed
Lines changed: 22 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
315 | | - | |
316 | | - | |
| 315 | + | |
| 316 | + | |
317 | 317 | | |
318 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
319 | 327 | | |
320 | 328 | | |
321 | 329 | | |
322 | 330 | | |
323 | | - | |
| 331 | + | |
| 332 | + | |
324 | 333 | | |
325 | 334 | | |
326 | 335 | | |
| |||
329 | 338 | | |
330 | 339 | | |
331 | 340 | | |
332 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
333 | 349 | | |
334 | 350 | | |
335 | 351 | | |
| |||
539 | 555 | | |
540 | 556 | | |
541 | 557 | | |
542 | | - | |
| 558 | + | |
| 559 | + | |
543 | 560 | | |
544 | 561 | | |
545 | 562 | | |
| |||
0 commit comments