whisper.cpp/ggml/src/ggml-metal
Pascal e376ba3ad8
metal: fuse snake activation (mul, sin, sqr, mul, add) (llama/25459)
* metal: fuse snake activation (mul, sin, sqr, mul, add)

Mirror the CUDA, Vulkan and CPU snake fusion: same matcher on the naive
5-op chain, same F32 contract on a and inv_b, same F32/F16/BF16 kernel
with F32 compute. Follows the Metal backend idioms: bf16 instantiation
gated behind GGML_METAL_HAS_BF16 and concurrency ranges checked on the
remaining chain nodes before encoding, as done by the bin fusion.

Covered by the existing backend-agnostic SNAKE_FUSE tests.

* metal: absorb snake fusion into ggml_metal_op_bin

Extract the matcher to ggml_metal_op_can_fuse_snake, mirroring the
Vulkan naming, and dispatch the fused path from ggml_metal_op_bin.
The encode loop switch is back to a single call per case.

Address review from ggerganov

* metal: fix indentation in ggml_metal_op_can_fuse_snake
2026-07-30 16:31:41 +03:00
..
CMakeLists.txt docs : Minor cleanups (llama/19252) 2026-02-08 09:29:10 +02:00
ggml-metal-common.cpp models : optimize qwen3next graph (llama/19375) 2026-02-15 21:44:37 +02:00
ggml-metal-common.h metal : refactor + optimize v2 (llama/15995) 2025-09-20 13:46:10 +03:00
ggml-metal-context.h metal : support virtual devices (llama/18919) 2026-02-08 09:29:10 +02:00
ggml-metal-context.m metal : avoid divisions in bin kernel (llama/20426) 2026-03-16 13:10:15 +02:00
ggml-metal-device.cpp metal: fuse snake activation (mul, sin, sqr, mul, add) (llama/25459) 2026-07-30 16:31:41 +03:00
ggml-metal-device.h metal: fuse snake activation (mul, sin, sqr, mul, add) (llama/25459) 2026-07-30 16:31:41 +03:00
ggml-metal-device.m vulkan/cpu: Support f16 as SET_ROWS src. (llama/25432) 2026-07-30 16:31:39 +03:00
ggml-metal-impl.h metal: fuse snake activation (mul, sin, sqr, mul, add) (llama/25459) 2026-07-30 16:31:41 +03:00
ggml-metal-ops.cpp metal: fuse snake activation (mul, sin, sqr, mul, add) (llama/25459) 2026-07-30 16:31:41 +03:00
ggml-metal-ops.h metal: fuse snake activation (mul, sin, sqr, mul, add) (llama/25459) 2026-07-30 16:31:41 +03:00
ggml-metal.cpp llama : fix device state save/load (llama/22805) 2026-05-14 21:26:48 +03:00
ggml-metal.metal metal: fuse snake activation (mul, sin, sqr, mul, add) (llama/25459) 2026-07-30 16:31:41 +03:00