diff options
author | Adnan AlSinan <adnan.alsinan@arm.com> | 2021-07-05 13:12:52 +0100 |
---|---|---|
committer | Georgios Pinitas <georgios.pinitas@arm.com> | 2021-07-25 13:04:23 +0000 |
commit | 7075fe2c5ee6f7cfe7cfd9454d905235e70b9ac4 (patch) | |
tree | b65671bdf37eb1ef8cc30ef64ab572da795546fa /src/core/CL/cl_kernels/mean_stddev_normalization.cl | |
parent | 22f5ed51f1b01f7cf6993a556a0b763e437926fc (diff) | |
download | ComputeLibrary-7075fe2c5ee6f7cfe7cfd9454d905235e70b9ac4.tar.gz |
Reorganize the kernels into nhwc, nchw and common folders
The Following kernels have been split into nchw/nhwc kernels files:
- batchnormalization_layer
- batch_to_space
- channel_shuffle
- depth_to_space
- dequantization_layer
- im2col
- normalization_layer
- normalize_planar_yuv_layer
- normalize_planar_yuv_layer_quantized
- pooling_layer
- pooling_layer_quantized
- remap
- reorg_layer
- scale
- scale_quantized
- space_to_batch
- space_to_depth
- upsample_layer
- winograd_filter_transform
- winograd_input_transform
- winograd_output_transform
The following kernels have been moved to nchw folder:
- direct_convolution1x1
- direct_convolution3x3
- direct_convolution5x5
- direct_convolution_quantized
- prior_box_layer
The following kernels have been moved to nhwc folder:
- direct_convolution
- dwc_native_fp_nhwc
- dwc_native_quantized_nhwc
The following kernels have been removed:
- sobel_filter
While the rest kerenls have been moved to the common folder.
Partially resolves COMPMID-4453
Signed-off-by: Adnan AlSinan <adnan.alsinan@arm.com>
Change-Id: Ic327ac935687ec351c610c65a3c6357f364a5a58
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5919
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/CL/cl_kernels/mean_stddev_normalization.cl')
-rw-r--r-- | src/core/CL/cl_kernels/mean_stddev_normalization.cl | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/src/core/CL/cl_kernels/mean_stddev_normalization.cl b/src/core/CL/cl_kernels/mean_stddev_normalization.cl deleted file mode 100644 index 76be629934..0000000000 --- a/src/core/CL/cl_kernels/mean_stddev_normalization.cl +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2019, 2021 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "helpers.h" - -#if defined(VEC_SIZE) && defined(DATA_TYPE) && defined(EPSILON) && defined(WIDTH) -/** This function normalizes the input 2D tensor across the first dimension with respect to mean and standard deviation of the same dimension. - * - * @attention Vector size should be given as a preprocessor argument using -DVEC_SIZE=size. e.g. -DVEC_SIZE=16 - * @attention Data type should be passed using the -DDATA_TYPE compile flag, e.g. -DDATA_TYPE=float - * @attention Width of the input tensor should be passed using the -DWIDTH compile flag, e.g. -DWIDTH=16 - * @attention Normalization epsilon parameter should be given as a preprocessor argument with -DEPSILON=value. e.g. -DEPSILON=0.001f - * - * @param[in] input_ptr Pointer to the first source tensor. Supported data types: F16/F32 - * @param[in] input_stride_x Stride of the first source tensor in X dimension (in bytes) - * @param[in] input_step_x input_stride_x * number of elements along X processed per workitem(in bytes) - * @param[in] input_stride_y Stride of the first source tensor in Y dimension (in bytes) - * @param[in] input_step_y input_stride_y * number of elements along Y processed per workitem(in bytes) - * @param[in] input_offset_first_element_in_bytes The offset of the first element in the first source tensor - * @param[out] output_ptr (Optional) Pointer to the destination tensor. Supported data types: same as @p input_ptr - * @param[in] output_stride_x (Optional) Stride of the destination tensor in X dimension (in bytes) - * @param[in] output_step_x (Optional) output_stride_x * number of elements along X processed per workitem(in bytes) - * @param[in] output_stride_y (Optional) Stride of the destination tensor in Y dimension (in bytes) - * @param[in] output_step_y (Optional) output_stride_y * number of elements along Y processed per workitem(in bytes) - * @param[in] output_offset_first_element_in_bytes (Optional) The offset of the first element in the destination tensor - */ -__kernel void mean_stddev_normalization( - IMAGE_DECLARATION(input) -#ifndef IN_PLACE - , - IMAGE_DECLARATION(output) -#endif /* IN_PLACE */ -) -{ - // Get pixels pointer - Image in = CONVERT_TO_IMAGE_STRUCT(input); -#ifdef IN_PLACE - Image out = in; -#else /* IN_PLACE */ - Image out = CONVERT_TO_IMAGE_STRUCT(output); -#endif /* IN_PLACE */ - - VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE) - sum = 0.f; - VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE) - sum_sq = 0.f; - // Calculate partial sum - int i = 0; - for(; i <= (WIDTH - VEC_SIZE); i += VEC_SIZE) - { - // Load data - VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE) - data = VLOAD(VEC_SIZE)(0, (__global DATA_TYPE *)offset(&in, i, 0)); - - sum += data; - sum_sq += data * data; - } - // Perform reduction - sum = SUM_REDUCE(sum, VEC_SIZE); - sum_sq = SUM_REDUCE(sum_sq, VEC_SIZE); - -#if VEC_SIZE > 1 -#define sum sum.s0 -#define sum_sq sum_sq.s0 -#endif // VEC_SIZE > 1 - - // Left-overs loop - for(; i < WIDTH; ++i) - { - DATA_TYPE data = *((__global DATA_TYPE *)offset(&in, i, 0)); - - sum += data; - sum_sq += data * data; - } - - DATA_TYPE mean = sum / WIDTH; - DATA_TYPE var = (sum_sq / WIDTH) - (mean * mean); - DATA_TYPE stddev_inv = 1.f / sqrt(var + EPSILON); - - i = 0; - for(; i <= (WIDTH - VEC_SIZE); i += VEC_SIZE) - { - VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE) - data = VLOAD(VEC_SIZE)(0, (__global DATA_TYPE *)offset(&in, i, 0)); - - VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE) - res = (data - mean) * stddev_inv; - VSTORE(VEC_SIZE) - (res, 0, (__global DATA_TYPE *)offset(&out, i, 0)); - } - for(; i < WIDTH; ++i) - { - DATA_TYPE data = *((__global DATA_TYPE *)offset(&in, i, 0)); - - *((__global DATA_TYPE *)offset(&out, i, 0)) = (data - mean) * stddev_inv; - } -} -#endif /* defined(VEC_SIZE) && defined(DATA_TYPE) && defined(EPSILON) && defined(WIDTH) */ |