jax
6d15f85f - Optimize `planar_snake` calculation.

Commit
31 days ago
Optimize `planar_snake` calculation. In typical usage, we expect `tile_width` to be a power-of-two. In this case, using a `cond`, rather than a `select`, is faster, as the cost of branches is not equal. This code is ~10% faster when `tile_width` is a power-of-two, and also faster in most other cases: ``` BEFORE ================================================================================ Shape TileW Latency / us -------------------------------- 1024x1024 4 84.19 1024x1025 4 167.58 1025x1024 4 193.79 1025x1025 4 195.97 1024x1024 5 249.78 1024x1025 5 358.53 1025x1024 5 159.58 1025x1025 5 197.92 AFTER ================================================================================ Shape TileW Latency / us -------------------------------- 1024x1024 4 84.19 1024x1025 4 155.55 1025x1024 4 163.58 1025x1025 4 169.76 1024x1024 5 173.41 1024x1025 5 282.11 1025x1024 5 167.61 1025x1025 5 193.89 ``` PiperOrigin-RevId: 969625172
Author
Parents
Loading