From d283dbcd37651961c0a2e485cda75e34fa85218a Mon Sep 17 00:00:00 2001 From: FirstTimeEZ <179362031+FirstTimeEZ@users.noreply.github.com> Date: Sat, 16 Nov 2024 17:17:10 +1300 Subject: [PATCH] vulkan: change an assertion src1 can go down the first pipeline as nullptr and src0 only needs to be checked once this means the assertion is only required to check if the type is GGML_TYPE_F16 and can usually be skipped --- ggml/src/ggml-vulkan/ggml-vulkan.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vulkan.cpp index 04d671aeb..8c5af0342 100644 --- a/ggml/src/ggml-vulkan/ggml-vulkan.cpp +++ b/ggml/src/ggml-vulkan/ggml-vulkan.cpp @@ -3929,13 +3929,14 @@ static vk_pipeline ggml_vk_op_get_pipeline(ggml_backend_vk_context * ctx, const } return nullptr; case GGML_OP_SOFT_MAX: - GGML_ASSERT(!src1 || src1->type == GGML_TYPE_F32 || src1->type == GGML_TYPE_F16); - - if (src0->type == GGML_TYPE_F32 && (src1 == nullptr || src1->type == GGML_TYPE_F32) && dst->type == GGML_TYPE_F32) { - return ctx->device->pipeline_soft_max_f32; - } - if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_F16 && dst->type == GGML_TYPE_F32) { - return ctx->device->pipeline_soft_max_f32_f16; + if (src0->type == GGML_TYPE_F32 && dst->type == GGML_TYPE_F32) { + if (src1 == nullptr || src1->type == GGML_TYPE_F32) { + return ctx->device->pipeline_soft_max_f32; + } + else { + GGML_ASSERT(src1->type == GGML_TYPE_F16); + return ctx->device->pipeline_soft_max_f32_f16; + } } return nullptr; case GGML_OP_ROPE: