diff options
Diffstat (limited to 'src/core/NEON/kernels/arm_gemm/mergeresults.hpp')
-rw-r--r-- | src/core/NEON/kernels/arm_gemm/mergeresults.hpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/core/NEON/kernels/arm_gemm/mergeresults.hpp b/src/core/NEON/kernels/arm_gemm/mergeresults.hpp index 4a6da3d21c..b1e2ca1daa 100644 --- a/src/core/NEON/kernels/arm_gemm/mergeresults.hpp +++ b/src/core/NEON/kernels/arm_gemm/mergeresults.hpp @@ -30,38 +30,39 @@ #include "asmlib.hpp" #include "utils.hpp" -namespace arm_gemm -{ -template <unsigned int width, unsigned int height, typename Tin, typename Tout> -inline void MergeResults(Tout *out, const Tin *in, int ldc, int y0, int ymax, int x0, int xmax, const Tout alpha, const Tout beta) -{ +namespace arm_gemm { + +template<unsigned int width, unsigned int height, typename Tin, typename Tout> +inline void MergeResults(Tout * out, const Tin * in, int ldc, int y0, int ymax, int x0, int xmax, const Tout alpha, const Tout beta) { int full_y_blocks = (ymax - y0) / height; - int y_remainder = (ymax - y0) % height; - int y_blocks = full_y_blocks + (y_remainder ? 1 : 0); + int y_remainder = (ymax - y0) % height; + int y_blocks = full_y_blocks + (y_remainder ? 1 : 0); int full_x_blocks = (xmax - x0) / width; - int x_remainder = (xmax - x0) % width; - int x_blocks = full_x_blocks + (x_remainder ? 1 : 0); + int x_remainder = (xmax - x0) % width; + int x_blocks = full_x_blocks + (x_remainder ? 1 : 0); - for(int y_block = 0; y_block < y_blocks; y_block++) - { + for (int y_block = 0; y_block < y_blocks; y_block++) { int ybase = y0 + (y_block * height); int fill_rows = (y_block < full_y_blocks) ? height : y_remainder; - for(int x_block = 0; x_block < x_blocks; x_block++) - { + for (int x_block = 0; x_block < x_blocks; x_block++) { int xbase = x0 + (x_block * width); int fill_cols = (x_block < full_x_blocks) ? width : x_remainder; - for(int row = 0; row < fill_rows; row++) - { - for(int col = 0; col < fill_cols; col++) - { + for (int row=0; row < fill_rows; row++) { + for (int col=0; col < fill_cols; col++) { Tout &p = out[(ybase + row) * ldc + xbase + col]; - p = (p * beta) + (alpha * in[row * width + col]); + // Special case for beta==0 - don't read the input; + // (0 * x == 0) is not always true for FP types. + if (beta == static_cast<Tout>(0)) { + p = (alpha * in[row * width + col]); + } else { + p = (p * beta) + (alpha * in[row * width + col]); + } } } |