From fadc9b1e0bba90d6a91beb65466b2a0895b3a5e4 Mon Sep 17 00:00:00 2001 From: Gunes Bayir Date: Tue, 7 Nov 2023 05:43:07 +0000 Subject: Optimize CpuSoftmaxKernel for axis=0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement a single kernel instead of having two consecutive ones. In the previous setup, one kernel was calculating the maximum value in the axis, and this maximum was being subtracted from each data while calculating the softmax, i.e. softmax(x_i) = exp(x_i - max) / sum_i( exp(x_i - max) ) This patch integrates these two stages into a single kernel for Neon™ for all data types. This will save some memory because we don't need to hold the max values in a separate auxiliary tensor. It also introduces some other optimizations that will ease memory pressure when the data type is float/half, by using the dst tensor as temporary storage for already exponentiated inputs. It removes the references to SVE and SVE2 implementations, and most of the associated files; but, it leaves the implementations as these may be used in the future. Resolves: COMPMID-6500 Signed-off-by: Gunes Bayir Change-Id: Icff9976d1214c4c6cbe15a62ca60b8a77d3784cc Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10688 Reviewed-by: SiCong Li Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Benchmark: Arm Jenkins --- filelist.json | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'filelist.json') diff --git a/filelist.json b/filelist.json index c34eff2ff9..60f4285a03 100644 --- a/filelist.json +++ b/filelist.json @@ -2213,16 +2213,10 @@ "qasymm8_signed":["src/cpu/kernels/softmax/generic/neon/qasymm8_signed.cpp"] }, "sve": { - "common": [ "src/cpu/kernels/softmax/generic/sve/impl.cpp" ], - "fp32": ["src/cpu/kernels/softmax/generic/sve/fp32.cpp"], - "fp16": ["src/cpu/kernels/softmax/generic/sve/fp16.cpp"], - "qasymm8": ["src/cpu/kernels/softmax/generic/sve/qasymm8.cpp" ], - "qasymm8_signed": ["src/cpu/kernels/softmax/generic/sve/qasymm8_signed.cpp"] + "common": [ "src/cpu/kernels/softmax/generic/sve/impl.cpp" ] }, "sve2":{ - "common" :["src/cpu/kernels/softmax/generic/sve2/impl.cpp"], - "qasymm8":[ "src/cpu/kernels/softmax/generic/sve2/qasymm8.cpp"], - "qasymm8_signed":["src/cpu/kernels/softmax/generic/sve2/qasymm8_signed.cpp"] + "common" :["src/cpu/kernels/softmax/generic/sve2/impl.cpp"] } } }, -- cgit v1.2.1