Commit 7423e42
committed
Vulkan: make half-variant GLSL PRECISION configurable
Add EXECUTORCH_VULKAN_FP16_PRECISION cmake option (default "highp" —
upstream-identical behavior). When set to "mediump" (or "lowp"),
gen_vulkan_spv.py overrides the PRECISION define in shader variants where
DTYPE=half.
GLSL's mediump is a driver hint that fp16 ALUs may be used for arithmetic.
On Mali GPUs this is typically honored and gives measurable conv speedups
(~15% on Pixel 9 Mali G715 for this repo's conv2d_half / conv2d_pw_tiled_half
workloads); on Adreno it is typically ignored (harmless).
Accuracy tradeoff: mediump relaxes minimum precision guarantees for fp16
shader math. Kept off by default so this cannot silently affect any
existing build. Exposed via scripts/build_android_library.sh env var for
Android users.
Wiring:
* backends/vulkan/runtime/gen_vulkan_spv.py: --fp16-precision CLI flag,
forwarded into SPVGenerator.create_shader_params().
* backends/vulkan/cmake/ShaderLibrary.cmake: forward cmake var into the
python invocation when set.
* tools/cmake/preset/default.cmake: declare overridable STRING option.
* scripts/build_android_library.sh: read EXECUTORCH_VULKAN_FP16_PRECISION
from env, default "highp".1 parent 369f5ca commit 7423e42
4 files changed
Lines changed: 39 additions & 0 deletions
File tree
- backends/vulkan
- cmake
- runtime
- scripts
- tools/cmake/preset
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
63 | 71 | | |
64 | 72 | | |
65 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
663 | 663 | | |
664 | 664 | | |
665 | 665 | | |
| 666 | + | |
666 | 667 | | |
667 | 668 | | |
668 | 669 | | |
| |||
678 | 679 | | |
679 | 680 | | |
680 | 681 | | |
| 682 | + | |
681 | 683 | | |
682 | 684 | | |
683 | 685 | | |
| |||
857 | 859 | | |
858 | 860 | | |
859 | 861 | | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
860 | 873 | | |
861 | 874 | | |
862 | 875 | | |
| |||
1488 | 1501 | | |
1489 | 1502 | | |
1490 | 1503 | | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
1491 | 1514 | | |
1492 | 1515 | | |
1493 | 1516 | | |
| |||
1520 | 1543 | | |
1521 | 1544 | | |
1522 | 1545 | | |
| 1546 | + | |
1523 | 1547 | | |
1524 | 1548 | | |
1525 | 1549 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
171 | 177 | | |
172 | 178 | | |
173 | 179 | | |
| |||
0 commit comments