diff --git a/ggml/src/ggml-vulkan/vulkan-shaders/types.comp b/ggml/src/ggml-vulkan/vulkan-shaders/types.comp index 75aa22eae4083..b76f1ac2b88f2 100644 --- a/ggml/src/ggml-vulkan/vulkan-shaders/types.comp +++ b/ggml/src/ggml-vulkan/vulkan-shaders/types.comp @@ -1430,16 +1430,10 @@ vec4 bf16_to_fp32(uvec4 u) } float e8m0_to_fp32(uint8_t x) { - uint32_t bits; - - if (x == 0) { - bits = 0x00400000; - } else { - bits = x; - bits = bits << 23; - } - - return uintBitsToFloat(bits); +// branchless implementation + uint is_zero = uint(x == 0); + uint result = (uint(x) << 23) | (is_zero << 22); + return uintBitsToFloat(result); } #endif // !defined(GGML_TYPES_COMP)