From af70ca98ebac36211b8cd7559b143ecda439e466 Mon Sep 17 00:00:00 2001 From: FhqTreap <676807370@qq.com> Date: Mon, 18 Sep 2023 19:38:07 +0800 Subject: [PATCH] afpvec4 fix --- src/layer/vulkan/shader/gelu_pack4.comp | 4 ++-- src/layer/vulkan/shader/gelu_pack8.comp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/layer/vulkan/shader/gelu_pack4.comp b/src/layer/vulkan/shader/gelu_pack4.comp index 3fc99cbd40b8..2fde1f584026 100644 --- a/src/layer/vulkan/shader/gelu_pack4.comp +++ b/src/layer/vulkan/shader/gelu_pack4.comp @@ -64,9 +64,9 @@ void main() // y = 0.5x * (1 + tanh(sqrt(2/Pi) * (x + 0.044715x^3))) #if NCNN_moltenvk - v = afp(0.5f) * v * (afp(1.0f) + afpvec4(tanh(vec4(afp(0.79788452f) * (v + afp(0.044715f) * v * v * v))))); + v = afpvec4(0.5f) * v * (afpvec4(1.0f) + afpvec4(tanh(vec4(afpvec4(0.79788452f) * (v + afpvec4(0.044715f) * v * v * v))))); #else - v = afp(0.5f) * v * (afp(1.0f) + tanh(afp(0.79788452f) * (v + afp(0.044715f) * v * v * v))); + v = afpvec4(0.5f) * v * (afpvec4(1.0f) + tanh(afpvec4(0.79788452f) * (v + afpvec4(0.044715f) * v * v * v))); #endif #if NCNN_image_shader diff --git a/src/layer/vulkan/shader/gelu_pack8.comp b/src/layer/vulkan/shader/gelu_pack8.comp index 7d957dee4cae..8ad3d66ed9fc 100644 --- a/src/layer/vulkan/shader/gelu_pack8.comp +++ b/src/layer/vulkan/shader/gelu_pack8.comp @@ -65,11 +65,11 @@ void main() // y = 0.5x * (1 + tanh(sqrt(2/Pi) * (x + 0.044715x^3))) #if NCNN_moltenvk - v[0] = afp(0.5f) * v[0] * (afp(1.0f) + afpvec4(tanh(vec4(afp(0.79788452f) * (v[0] + afp(0.044715f) * v[0] * v[0] * v[0]))))); - v[1] = afp(0.5f) * v[1] * (afp(1.0f) + afpvec4(tanh(vec4(afp(0.79788452f) * (v[1] + afp(0.044715f) * v[1] * v[1] * v[1]))))); + v[0] = afpvec4(0.5f) * v[0] * (afpvec4(1.0f) + afpvec4(tanh(vec4(afpvec4(0.79788452f) * (v[0] + afpvec4(0.044715f) * v[0] * v[0] * v[0]))))); + v[1] = afpvec4(0.5f) * v[1] * (afpvec4(1.0f) + afpvec4(tanh(vec4(afpvec4(0.79788452f) * (v[1] + afpvec4(0.044715f) * v[1] * v[1] * v[1]))))); #else - v[0] = afp(0.5f) * v[0] * (afp(1.0f) + tanh(afp(0.79788452f) * (v[0] + afp(0.044715f) * v[0] * v[0] * v[0]))); - v[1] = afp(0.5f) * v[1] * (afp(1.0f) + tanh(afp(0.79788452f) * (v[1] + afp(0.044715f) * v[1] * v[1] * v[1]))); + v[0] = afpvec4(0.5f) * v[0] * (afpvec4(1.0f) + tanh(afpvec4(0.79788452f) * (v[0] + afpvec4(0.044715f) * v[0] * v[0] * v[0]))); + v[1] = afpvec4(0.5f) * v[1] * (afpvec4(1.0f) + tanh(afpvec4(0.79788452f) * (v[1] + afpvec4(0.044715f) * v[1] * v[1] * v[1]))); #endif #if NCNN_image_shader