From 463650f1c8f2e9b44baaacccc8a7d449a3624d1a Mon Sep 17 00:00:00 2001 From: dolphin8 Date: Wed, 24 Oct 2018 17:26:49 +0800 Subject: [PATCH] fix softmax --- src/operators/kernel/cl/cl_kernel/softmax.cl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/operators/kernel/cl/cl_kernel/softmax.cl b/src/operators/kernel/cl/cl_kernel/softmax.cl index a4514c7064..215ec69fc2 100644 --- a/src/operators/kernel/cl/cl_kernel/softmax.cl +++ b/src/operators/kernel/cl/cl_kernel/softmax.cl @@ -33,17 +33,17 @@ __kernel void softmax(__read_only image2d_t input_image, maxv = max(maxv, max(temp.x, max(temp.y, max(temp.z, temp.w)))); } - half4 rsum = (half4)(0.0f); + half4 rsum = (half4)(0.0f); for (int i = 0; i < group; ++i) { half4 r = read_imageh(input_image, sampler, (int2)(i, 0)); - rsum += exp(r - maxv); + rsum += convert_half4(exp(convert_float4(r - maxv))); } float sum = rsum.x + rsum.y + rsum.z + rsum.w; half4 rr = read_imageh(input_image, sampler, (int2)(out_w, out_nh)); - half4 result = exp(rr - maxv) / sum; + half4 result = convert_half4(exp(convert_float4(rr - maxv)) / sum); write_imageh(output_image, (int2)(out_w, out_nh), result); } -- GitLab