From 70eb53b09adf57cc6ff7435c795e65a4f4697f67 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Wed, 6 Jan 2021 19:42:21 +0000 Subject: Make CpuFloorKernel kernel stateless - Rename NEFloorKernel to CpuFloorKernel to accomodate new ISA implementations - Remove state and instead pass tensors to operate during run - Add member function to generate an execution window given an input and output tensor description Signed-off-by: Georgios Pinitas Change-Id: I9240b8ec534589c0f15c354f771f1ac5d7010c3b Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4773 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Michalis Spyrou --- Android.bp | 7 +- SConscript | 17 ++ arm_compute/runtime/NEON/functions/NEFloor.h | 27 +++- docs/00_introduction.dox | 4 +- src/core/NEON/NEKernels.h | 3 +- src/core/NEON/SVEMath.h | 1 - .../NEON/kernels/NEArithmeticAdditionKernel.cpp | 1 - src/core/NEON/kernels/NEElementwiseUnaryKernel.cpp | 13 +- src/core/NEON/kernels/NEFloorKernel.cpp | 150 ----------------- src/core/NEON/kernels/NEFloorKernel.h | 72 --------- .../NEON/kernels/activation/impl/NEON/fp16.cpp | 3 +- .../NEON/kernels/activation/impl/NEON/fp32.cpp | 3 +- .../NEON/kernels/activation/impl/NEON/qasymm8.cpp | 3 +- .../activation/impl/NEON/qasymm8_signed.cpp | 3 +- .../NEON/kernels/activation/impl/NEON/qsymm16.cpp | 3 +- src/core/NEON/kernels/activation/impl/SVE/fp16.cpp | 3 +- src/core/NEON/kernels/activation/impl/SVE/fp32.cpp | 3 +- .../NEON/kernels/activation/impl/SVE/qasymm8.cpp | 1 - .../kernels/activation/impl/SVE/qasymm8_signed.cpp | 1 - .../NEON/kernels/activation/impl/SVE/qsymm16.cpp | 3 +- .../arithmetic_addition/impl/NEON/integer.cpp | 1 - .../arithmetic_addition/impl/NEON/qasymm8.cpp | 1 - .../impl/NEON/qasymm8_signed.cpp | 1 - .../arithmetic_addition/impl/NEON/qsymm16.cpp | 1 - .../kernels/batchnormalization/impl/NEON/fp16.cpp | 1 - .../kernels/batchnormalization/impl/NEON/fp32.cpp | 1 - .../kernels/batchnormalization/impl/SVE/fp16.cpp | 3 +- .../kernels/batchnormalization/impl/SVE/fp32.cpp | 3 +- src/core/NEON/kernels/floor/impl/NEON/fp16.cpp | 65 -------- src/core/NEON/kernels/floor/impl/NEON/fp32.cpp | 62 ------- src/core/NEON/kernels/floor/impl/list.h | 41 ----- src/core/common/Macros.h | 33 ++++ src/core/common/StdTypes.h | 43 ----- src/core/cpu/ICpuKernel.h | 36 +++++ src/core/cpu/kernels/CpuFloorKernel.h | 72 +++++++++ src/core/cpu/kernels/floor/CpuFloorKernel.cpp | 179 +++++++++++++++++++++ src/core/cpu/kernels/floor/impl/NEON/fp16.cpp | 64 ++++++++ src/core/cpu/kernels/floor/impl/NEON/fp32.cpp | 61 +++++++ src/core/cpu/kernels/floor/impl/list.h | 41 +++++ src/runtime/NEON/functions/NEFloor.cpp | 37 ++++- src/runtime/cpu/ICpuOperator.h | 36 +++++ src/runtime/cpu/operators/CpuFloor.cpp | 44 +++++ src/runtime/cpu/operators/CpuFloor.h | 56 +++++++ 43 files changed, 717 insertions(+), 486 deletions(-) delete mode 100644 src/core/NEON/kernels/NEFloorKernel.cpp delete mode 100644 src/core/NEON/kernels/NEFloorKernel.h delete mode 100644 src/core/NEON/kernels/floor/impl/NEON/fp16.cpp delete mode 100644 src/core/NEON/kernels/floor/impl/NEON/fp32.cpp delete mode 100644 src/core/NEON/kernels/floor/impl/list.h create mode 100644 src/core/common/Macros.h delete mode 100644 src/core/common/StdTypes.h create mode 100644 src/core/cpu/ICpuKernel.h create mode 100644 src/core/cpu/kernels/CpuFloorKernel.h create mode 100644 src/core/cpu/kernels/floor/CpuFloorKernel.cpp create mode 100644 src/core/cpu/kernels/floor/impl/NEON/fp16.cpp create mode 100644 src/core/cpu/kernels/floor/impl/NEON/fp32.cpp create mode 100644 src/core/cpu/kernels/floor/impl/list.h create mode 100644 src/runtime/cpu/ICpuOperator.h create mode 100644 src/runtime/cpu/operators/CpuFloor.cpp create mode 100644 src/runtime/cpu/operators/CpuFloor.h diff --git a/Android.bp b/Android.bp index 040ff446a1..18d16c029f 100644 --- a/Android.bp +++ b/Android.bp @@ -268,7 +268,6 @@ cc_library_static { "src/core/NEON/kernels/NEFastCornersKernel.cpp", "src/core/NEON/kernels/NEFillArrayKernel.cpp", "src/core/NEON/kernels/NEFillBorderKernel.cpp", - "src/core/NEON/kernels/NEFloorKernel.cpp", "src/core/NEON/kernels/NEFuseBatchNormalizationKernel.cpp", "src/core/NEON/kernels/NEGEMMInterleave4x4Kernel.cpp", "src/core/NEON/kernels/NEGEMMLowpMatrixMultiplyKernel.cpp", @@ -417,8 +416,6 @@ cc_library_static { "src/core/NEON/kernels/convolution/winograd/winograd_transforms/weights_4x4_3x3_fp16_fp16_integers.cpp", "src/core/NEON/kernels/convolution/winograd/winograd_transforms/weights_4x4_3x3_fp32_fp32_integers.cpp", "src/core/NEON/kernels/convolution/winograd/winograd_transforms/weights_6_3_fp32_fp32_integers.cpp", - "src/core/NEON/kernels/floor/impl/NEON/fp16.cpp", - "src/core/NEON/kernels/floor/impl/NEON/fp32.cpp", "src/core/PyramidInfo.cpp", "src/core/Rounding.cpp", "src/core/Size2D.cpp", @@ -427,6 +424,9 @@ cc_library_static { "src/core/Utils.cpp", "src/core/Validate.cpp", "src/core/Version.cpp", + "src/core/cpu/kernels/floor/CpuFloorKernel.cpp", + "src/core/cpu/kernels/floor/impl/NEON/fp16.cpp", + "src/core/cpu/kernels/floor/impl/NEON/fp32.cpp", "src/core/helpers/SoftmaxHelpers.cpp", "src/core/helpers/WindowHelpers.cpp", "src/core/utils/ScaleUtils.cpp", @@ -763,6 +763,7 @@ cc_library_static { "src/runtime/Tensor.cpp", "src/runtime/TensorAllocator.cpp", "src/runtime/Utils.cpp", + "src/runtime/cpu/operators/CpuFloor.cpp", "utils/CommonGraphOptions.cpp", "utils/GraphUtils.cpp", "utils/Utils.cpp", diff --git a/SConscript b/SConscript index 724208c306..23889657bd 100644 --- a/SConscript +++ b/SConscript @@ -263,6 +263,23 @@ if env['neon']: runtime_files += Glob('src/runtime/NEON/functions/*.cpp') runtime_files += Glob('src/runtime/NEON/functions/assembly/*.cpp') + core_files += Glob('src/core/cpu/*.cpp') + core_files += Glob('src/core/cpu/kernels/*.cpp') + core_files += Glob('src/core/cpu/kernels/*/*.cpp') + if any(i in env['data_type_support'] for i in ['all', 'fp16']): + core_files += Glob('src/core/cpu/kernels/*/impl/*/fp16.cpp') + if any(i in env['data_type_support'] for i in ['all', 'fp32']): + core_files += Glob('src/core/cpu/kernels/*/impl/*/fp32.cpp') + if any(i in env['data_type_support'] for i in ['all', 'qasymm8']): + core_files += Glob('src/core/cpu/kernels/*/impl/*/qasymm8.cpp') + if any(i in env['data_type_support'] for i in ['all', 'qasymm8_signed']): + core_files += Glob('src/core/cpu/kernels/*/impl/*/qasymm8_signed.cpp') + if any(i in env['data_type_support'] for i in ['all', 'qsymm16']): + core_files += Glob('src/core/cpu/kernels/*/impl/*/qsymm16.cpp') + + runtime_files += Glob('src/runtime/cpu/*.cpp') + runtime_files += Glob('src/runtime/cpu/operators/*.cpp') + if env['gles_compute']: if env['os'] != 'android': arm_compute_env.Append(CPPPATH = ["#opengles-3.1/include", "#opengles-3.1/mali_include"]) diff --git a/arm_compute/runtime/NEON/functions/NEFloor.h b/arm_compute/runtime/NEON/functions/NEFloor.h index 7f4248eadb..92993503da 100644 --- a/arm_compute/runtime/NEON/functions/NEFloor.h +++ b/arm_compute/runtime/NEON/functions/NEFloor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020 Arm Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -24,19 +24,33 @@ #ifndef ARM_COMPUTE_NEFLOOR_H #define ARM_COMPUTE_NEFLOOR_H -#include "arm_compute/runtime/NEON/INESimpleFunctionNoBorder.h" +#include "arm_compute/runtime/IFunction.h" #include "arm_compute/core/Types.h" +#include + namespace arm_compute { class ITensor; class ITensorInfo; /** Basic function to run @ref NEFloorKernel */ -class NEFloor : public INESimpleFunctionNoBorder +class NEFloor : public IFunction { public: + /** Constructor */ + NEFloor(); + /** Prevent instances of this class from being copied (As this class contains pointers) */ + NEFloor(const NEFloor &) = delete; + /** Default move constructor */ + NEFloor(NEFloor &&); + /** Prevent instances of this class from being copied (As this class contains pointers) */ + NEFloor &operator=(const NEFloor &) = delete; + /** Default move assignment operator */ + NEFloor &operator=(NEFloor &&); + /** Destructor */ + ~NEFloor(); /** Set the source, destination of the kernel * * @param[in] input Source tensor. Data type supported: F16/F32. @@ -51,6 +65,13 @@ public: * @return a status */ static Status validate(const ITensorInfo *input, const ITensorInfo *output); + + // Inherited methods overridden + void run() override; + +private: + struct Impl; + std::unique_ptr _impl; }; } // namespace arm_compute #endif /* ARM_COMPUTE_NEFLOOR_H */ diff --git a/docs/00_introduction.dox b/docs/00_introduction.dox index 5210b325cc..6edda04a59 100644 --- a/docs/00_introduction.dox +++ b/docs/00_introduction.dox @@ -442,7 +442,7 @@ v20.08 Public major release - @ref NEROIAlignLayerKernel - NEYOLOLayerKernel - NEUpsampleLayerKernel - - @ref NEFloorKernel + - NEFloorKernel - @ref NEWidthConcatenateLayerKernel - @ref NEDepthConcatenateLayerKernel - @ref NENormalizationLayerKernel @@ -1177,7 +1177,7 @@ v17.09 Public major release - New NEON kernels / functions: - arm_compute::NEGEMMAssemblyBaseKernel arm_compute::NEGEMMAArch64Kernel - @ref NEDequantizationLayerKernel / @ref NEDequantizationLayer - - @ref NEFloorKernel / @ref NEFloor + - NEFloorKernel / @ref NEFloor - @ref NEL2NormalizeLayerKernel / @ref NEL2NormalizeLayer - @ref NEQuantizationLayerKernel @ref NEMinMaxLayerKernel / @ref NEQuantizationLayer - @ref NEROIPoolingLayerKernel / @ref NEROIPoolingLayer diff --git a/src/core/NEON/NEKernels.h b/src/core/NEON/NEKernels.h index d6cd696414..1e0b1f08d6 100644 --- a/src/core/NEON/NEKernels.h +++ b/src/core/NEON/NEKernels.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2020 Arm Limited. + * Copyright (c) 2016-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -69,7 +69,6 @@ #include "src/core/NEON/kernels/NEFastCornersKernel.h" #include "src/core/NEON/kernels/NEFillArrayKernel.h" #include "src/core/NEON/kernels/NEFillBorderKernel.h" -#include "src/core/NEON/kernels/NEFloorKernel.h" #include "src/core/NEON/kernels/NEFuseBatchNormalizationKernel.h" #include "src/core/NEON/kernels/NEGEMMInterleave4x4Kernel.h" #include "src/core/NEON/kernels/NEGEMMLowpMatrixMultiplyKernel.h" diff --git a/src/core/NEON/SVEMath.h b/src/core/NEON/SVEMath.h index 2b30e20e8d..075cb457e3 100644 --- a/src/core/NEON/SVEMath.h +++ b/src/core/NEON/SVEMath.h @@ -28,7 +28,6 @@ #include "src/core/NEON/wrapper/intrinsics/svcvt.h" #include "src/core/NEON/wrapper/intrinsics/svdup_n.h" #include "src/core/NEON/wrapper/intrinsics/svreinterpret.h" -#include "src/core/common/StdTypes.h" #include #include diff --git a/src/core/NEON/kernels/NEArithmeticAdditionKernel.cpp b/src/core/NEON/kernels/NEArithmeticAdditionKernel.cpp index f706ee5694..4b53d26a5a 100644 --- a/src/core/NEON/kernels/NEArithmeticAdditionKernel.cpp +++ b/src/core/NEON/kernels/NEArithmeticAdditionKernel.cpp @@ -32,7 +32,6 @@ #include "src/core/NEON/kernels/arithmetic_addition/impl/SVE/list.h" #include "src/core/NEON/wrapper/wrapper.h" #include "src/core/common/Registrars.h" -#include "src/core/common/StdTypes.h" #include "src/core/helpers/AutoConfiguration.h" #include "src/core/helpers/WindowHelpers.h" diff --git a/src/core/NEON/kernels/NEElementwiseUnaryKernel.cpp b/src/core/NEON/kernels/NEElementwiseUnaryKernel.cpp index ed1cb6fca4..fdd2aabf60 100644 --- a/src/core/NEON/kernels/NEElementwiseUnaryKernel.cpp +++ b/src/core/NEON/kernels/NEElementwiseUnaryKernel.cpp @@ -31,7 +31,6 @@ #include "src/core/NEON/kernels/elementwise/impl/elementwise_unary_list.h" #include "src/core/SVE/kernels/elementwise/impl/elementwise_unary_list.h" #include "src/core/common/Registrars.h" -#include "src/core/common/StdTypes.h" #include "src/core/helpers/AutoConfiguration.h" #include "src/core/helpers/WindowHelpers.h" #include "support/ToolchainSupport.h" @@ -55,35 +54,35 @@ static const ElementwiseUnaryKernel available_kernels[] = { "fp32_sve_elementwise_unary", [](DataType dt) { return dt == DataType::F32; }, - REGISTER_FP32_SVE(arm_compute::cpu::elementwise_sve_op), + REGISTER_FP32_SVE(arm_compute::cpu::elementwise_sve_op), }, { "fp16_sve_elementwise_unary", [](DataType dt) { return dt == DataType::F16; }, - REGISTER_FP16_SVE(arm_compute::cpu::elementwise_sve_op), + REGISTER_FP16_SVE(arm_compute::cpu::elementwise_sve_op<__fp16>), }, { "s32_sve_elementwise_unary", [](DataType dt) { return dt == DataType::S32; }, - REGISTER_INTEGER_SVE(arm_compute::cpu::elementwise_sve_op), + REGISTER_INTEGER_SVE(arm_compute::cpu::elementwise_sve_op), }, #endif // defined(__ARM_FEATURE_SVE) { "fp32_neon_elementwise_unary", [](DataType dt) { return dt == DataType::F32; }, - REGISTER_FP32_NEON(arm_compute::cpu::elementwise_op), + REGISTER_FP32_NEON(arm_compute::cpu::elementwise_op), }, #if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) { "fp16_neon_elementwise_unary", [](DataType dt) { return dt == DataType::F16; }, - REGISTER_FP32_NEON(arm_compute::cpu::elementwise_op), + REGISTER_FP32_NEON(arm_compute::cpu::elementwise_op<__fp16>), }, #endif // defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) { "s32_neon_elementwise_unary", [](DataType dt) { return dt == DataType::S32; }, - REGISTER_INTEGER_NEON(arm_compute::cpu::elementwise_op), + REGISTER_INTEGER_NEON(arm_compute::cpu::elementwise_op), }, }; diff --git a/src/core/NEON/kernels/NEFloorKernel.cpp b/src/core/NEON/kernels/NEFloorKernel.cpp deleted file mode 100644 index 2750acdda7..0000000000 --- a/src/core/NEON/kernels/NEFloorKernel.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2017-2020 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 "src/core/NEON/kernels/NEFloorKernel.h" - -#include "arm_compute/core/Coordinates.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/ITensor.h" -#include "arm_compute/core/Validate.h" -#include "src/core/CPP/Validate.h" -#include "src/core/NEON/INEKernel.h" -#include "src/core/helpers/AutoConfiguration.h" -#include "src/core/helpers/WindowHelpers.h" - -#include "src/core/NEON/kernels/floor/impl/list.h" -#include "src/core/common/Registrars.h" - -namespace arm_compute -{ -namespace -{ -struct FloorSelectorData -{ - DataType dt; -}; -using FloorSelectorPtr = std::add_pointer::type; -using FloorUKernelPtr = std::add_pointer::type; - -struct FloorKernel -{ - const char *name; - const FloorSelectorPtr is_selected; - FloorUKernelPtr ukernel; -}; - -static const FloorKernel available_kernels[] = -{ - { - "fp16_neon_floor", - [](const FloorSelectorData & data) { return data.dt == DataType::F16; }, - REGISTER_FP16_NEON(arm_compute::cpu::fp16_neon_floor) - }, - { - "f32_neon_floor", - [](const FloorSelectorData & data) { return data.dt == DataType::F32; }, - REGISTER_FP32_NEON(arm_compute::cpu::fp32_neon_floor) - }, -}; - -const FloorKernel *get_implementation(const FloorSelectorData &data) -{ - for(const auto &uk : available_kernels) - { - if(uk.is_selected(data)) - { - return &uk; - } - } - return nullptr; -} - -Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output) -{ - ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output); - - const auto *uk = get_implementation(FloorSelectorData{ input->data_type() }); - ARM_COMPUTE_RETURN_ERROR_ON(uk == nullptr || uk->ukernel == nullptr); - - // Validate in case of configured output - if(output->total_size() > 0) - { - ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); - ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(input, output); - } - - return Status{}; -} -} // namespace - -void NEFloorKernel::configure(const ITensor *input, ITensor *output) -{ - ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); - - // Auto initialize output - auto_init_if_empty(*output->info(), input->info()->tensor_shape(), 1, input->info()->data_type()); - - // Validate - ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info())); - - _input = input; - _output = output; - - // Configure kernel window - Window win = calculate_max_window(*input->info(), Steps()); - - Coordinates coord; - coord.set_num_dimensions(output->info()->num_dimensions()); - output->info()->set_valid_region(ValidRegion(coord, output->info()->tensor_shape())); - - INEKernel::configure(win); -} - -Status NEFloorKernel::validate(const ITensorInfo *input, const ITensorInfo *output) -{ - ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output)); - return Status{}; -} - -void NEFloorKernel::run(const Window &window, const ThreadInfo &info) -{ - ARM_COMPUTE_UNUSED(info); - ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window); - - Window win{ window }; - win.set(Window::DimX, Window::Dimension(0, 1, 1)); - - const auto len = static_cast(window.x().end()) - static_cast(window.x().start()); - const auto *uk = get_implementation(FloorSelectorData{ _input->info()->data_type() }); - - Iterator input(_input, win); - Iterator output(_output, win); - - execute_window_loop(win, [&](const Coordinates &) - { - uk->ukernel(input.ptr(), output.ptr(), len); - }, - input, output); -} -} // namespace arm_compute diff --git a/src/core/NEON/kernels/NEFloorKernel.h b/src/core/NEON/kernels/NEFloorKernel.h deleted file mode 100644 index 99c016bac5..0000000000 --- a/src/core/NEON/kernels/NEFloorKernel.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2017-2020 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. - */ -#ifndef ARM_COMPUTE_NEFLOORKERNEL_H -#define ARM_COMPUTE_NEFLOORKERNEL_H - -#include "src/core/NEON/INESimpleKernel.h" - -namespace arm_compute -{ -class ITensor; - -/** NEON kernel to perform a floor operation */ -class NEFloorKernel : public INESimpleKernel -{ -public: - const char *name() const override - { - return "NEFloorKernel"; - } - /** Constructor */ - NEFloorKernel() = default; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NEFloorKernel(const NEFloorKernel &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NEFloorKernel &operator=(const NEFloorKernel &) = delete; - /** Allow instances of this class to be moved */ - NEFloorKernel(NEFloorKernel &&) = default; - /** Allow instances of this class to be moved */ - NEFloorKernel &operator=(NEFloorKernel &&) = default; - /** Default destructor */ - ~NEFloorKernel() = default; - /** Set the source, destination of the kernel - * - * @param[in] input Source tensor. Data type supported: F16/F32. - * @param[out] output Destination tensor. Same as @p input - */ - void configure(const ITensor *input, ITensor *output); - /** Static function to check if given info will lead to a valid configuration of @ref NEFloorKernel - * - * @param[in] input Source tensor info. Data type supported: F16/F32. - * @param[in] output Destination tensor info. Same as @p input - * - * @return a status - */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output); - - // Inherited methods overridden: - void run(const Window &window, const ThreadInfo &info) override; -}; -} // namespace arm_compute -#endif /*ARM_COMPUTE_NEFLOORKERNEL_H */ diff --git a/src/core/NEON/kernels/activation/impl/NEON/fp16.cpp b/src/core/NEON/kernels/activation/impl/NEON/fp16.cpp index 58e1cfcf23..27ae2830cc 100644 --- a/src/core/NEON/kernels/activation/impl/NEON/fp16.cpp +++ b/src/core/NEON/kernels/activation/impl/NEON/fp16.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -26,7 +26,6 @@ #include "arm_compute/core/Helpers.h" #include "arm_compute/core/Validate.h" #include "src/core/NEON/wrapper/wrapper.h" -#include "src/core/common/StdTypes.h" #include "src/core/common/Validate.h" #include diff --git a/src/core/NEON/kernels/activation/impl/NEON/fp32.cpp b/src/core/NEON/kernels/activation/impl/NEON/fp32.cpp index 610db05224..0687646be7 100644 --- a/src/core/NEON/kernels/activation/impl/NEON/fp32.cpp +++ b/src/core/NEON/kernels/activation/impl/NEON/fp32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -26,7 +26,6 @@ #include "arm_compute/core/Window.h" #include "src/core/NEON/NEMath.h" #include "src/core/NEON/wrapper/wrapper.h" -#include "src/core/common/StdTypes.h" #include "src/core/common/Validate.h" #include diff --git a/src/core/NEON/kernels/activation/impl/NEON/qasymm8.cpp b/src/core/NEON/kernels/activation/impl/NEON/qasymm8.cpp index 7b26441824..7506a8294f 100644 --- a/src/core/NEON/kernels/activation/impl/NEON/qasymm8.cpp +++ b/src/core/NEON/kernels/activation/impl/NEON/qasymm8.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -27,7 +27,6 @@ #include "src/core/NEON/NEAsymm.h" #include "src/core/NEON/NEMath.h" #include "src/core/NEON/wrapper/wrapper.h" -#include "src/core/common/StdTypes.h" #include "src/core/common/Validate.h" #include diff --git a/src/core/NEON/kernels/activation/impl/NEON/qasymm8_signed.cpp b/src/core/NEON/kernels/activation/impl/NEON/qasymm8_signed.cpp index c616c5e27d..8f75abea8e 100644 --- a/src/core/NEON/kernels/activation/impl/NEON/qasymm8_signed.cpp +++ b/src/core/NEON/kernels/activation/impl/NEON/qasymm8_signed.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -26,7 +26,6 @@ #include "src/core/NEON/NEAsymm.h" #include "src/core/NEON/NEMath.h" #include "src/core/NEON/wrapper/wrapper.h" -#include "src/core/common/StdTypes.h" #include "src/core/common/Validate.h" #include diff --git a/src/core/NEON/kernels/activation/impl/NEON/qsymm16.cpp b/src/core/NEON/kernels/activation/impl/NEON/qsymm16.cpp index 0bef807db9..9eee360427 100644 --- a/src/core/NEON/kernels/activation/impl/NEON/qsymm16.cpp +++ b/src/core/NEON/kernels/activation/impl/NEON/qsymm16.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -28,7 +28,6 @@ #include "src/core/NEON/NEMath.h" #include "src/core/NEON/NESymm.h" #include "src/core/NEON/wrapper/wrapper.h" -#include "src/core/common/StdTypes.h" #include "src/core/common/Validate.h" #include diff --git a/src/core/NEON/kernels/activation/impl/SVE/fp16.cpp b/src/core/NEON/kernels/activation/impl/SVE/fp16.cpp index 8d6f4f2351..8208813cd3 100644 --- a/src/core/NEON/kernels/activation/impl/SVE/fp16.cpp +++ b/src/core/NEON/kernels/activation/impl/SVE/fp16.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -24,7 +24,6 @@ #include "arm_compute/core/Helpers.h" #include "arm_compute/core/ITensorPack.h" #include "arm_compute/core/Window.h" -#include "src/core/common/StdTypes.h" #include "src/core/common/Validate.h" #include diff --git a/src/core/NEON/kernels/activation/impl/SVE/fp32.cpp b/src/core/NEON/kernels/activation/impl/SVE/fp32.cpp index 2c276028a0..55bdc9999e 100644 --- a/src/core/NEON/kernels/activation/impl/SVE/fp32.cpp +++ b/src/core/NEON/kernels/activation/impl/SVE/fp32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,7 +25,6 @@ #include "arm_compute/core/ITensorPack.h" #include "arm_compute/core/Window.h" #include "src/core/NEON/SVEMath.h" -#include "src/core/common/StdTypes.h" #include "src/core/common/Validate.h" #include diff --git a/src/core/NEON/kernels/activation/impl/SVE/qasymm8.cpp b/src/core/NEON/kernels/activation/impl/SVE/qasymm8.cpp index 55133f074c..3e29a68788 100644 --- a/src/core/NEON/kernels/activation/impl/SVE/qasymm8.cpp +++ b/src/core/NEON/kernels/activation/impl/SVE/qasymm8.cpp @@ -24,7 +24,6 @@ #include "arm_compute/core/Helpers.h" #include "arm_compute/core/Window.h" -#include "src/core/common/StdTypes.h" #include "src/core/common/Validate.h" #include diff --git a/src/core/NEON/kernels/activation/impl/SVE/qasymm8_signed.cpp b/src/core/NEON/kernels/activation/impl/SVE/qasymm8_signed.cpp index 5b010d9453..f21d0657ab 100644 --- a/src/core/NEON/kernels/activation/impl/SVE/qasymm8_signed.cpp +++ b/src/core/NEON/kernels/activation/impl/SVE/qasymm8_signed.cpp @@ -24,7 +24,6 @@ #include "arm_compute/core/Helpers.h" #include "arm_compute/core/Window.h" #include "src/core/NEON/wrapper/wrapper.h" -#include "src/core/common/StdTypes.h" #include "src/core/common/Validate.h" #include diff --git a/src/core/NEON/kernels/activation/impl/SVE/qsymm16.cpp b/src/core/NEON/kernels/activation/impl/SVE/qsymm16.cpp index 1432e3bbdf..dbaf267bf9 100644 --- a/src/core/NEON/kernels/activation/impl/SVE/qsymm16.cpp +++ b/src/core/NEON/kernels/activation/impl/SVE/qsymm16.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,7 +25,6 @@ #include "arm_compute/core/ITensorPack.h" #include "arm_compute/core/Window.h" #include "arm_compute/core/experimental/Types.h" -#include "src/core/common/StdTypes.h" #include "src/core/common/Validate.h" #include diff --git a/src/core/NEON/kernels/arithmetic_addition/impl/NEON/integer.cpp b/src/core/NEON/kernels/arithmetic_addition/impl/NEON/integer.cpp index 8dd58cec6d..0aededfcfd 100644 --- a/src/core/NEON/kernels/arithmetic_addition/impl/NEON/integer.cpp +++ b/src/core/NEON/kernels/arithmetic_addition/impl/NEON/integer.cpp @@ -26,7 +26,6 @@ #include "arm_compute/core/Types.h" #include "arm_compute/core/utils/misc/Traits.h" #include "src/core/NEON/wrapper/wrapper.h" -#include "src/core/common/StdTypes.h" #include "src/core/helpers/WindowHelpers.h" namespace arm_compute diff --git a/src/core/NEON/kernels/arithmetic_addition/impl/NEON/qasymm8.cpp b/src/core/NEON/kernels/arithmetic_addition/impl/NEON/qasymm8.cpp index b93dad20f1..0b3a851fc5 100644 --- a/src/core/NEON/kernels/arithmetic_addition/impl/NEON/qasymm8.cpp +++ b/src/core/NEON/kernels/arithmetic_addition/impl/NEON/qasymm8.cpp @@ -26,7 +26,6 @@ #include "arm_compute/core/Types.h" #include "arm_compute/core/utils/misc/Traits.h" #include "src/core/NEON/wrapper/intrinsics/intrinsics.h" -#include "src/core/common/StdTypes.h" #include "src/core/helpers/WindowHelpers.h" namespace arm_compute diff --git a/src/core/NEON/kernels/arithmetic_addition/impl/NEON/qasymm8_signed.cpp b/src/core/NEON/kernels/arithmetic_addition/impl/NEON/qasymm8_signed.cpp index ba81cfcc03..18f5aabb21 100644 --- a/src/core/NEON/kernels/arithmetic_addition/impl/NEON/qasymm8_signed.cpp +++ b/src/core/NEON/kernels/arithmetic_addition/impl/NEON/qasymm8_signed.cpp @@ -26,7 +26,6 @@ #include "arm_compute/core/Types.h" #include "arm_compute/core/utils/misc/Traits.h" #include "src/core/NEON/wrapper/intrinsics/intrinsics.h" -#include "src/core/common/StdTypes.h" #include "src/core/helpers/WindowHelpers.h" namespace arm_compute diff --git a/src/core/NEON/kernels/arithmetic_addition/impl/NEON/qsymm16.cpp b/src/core/NEON/kernels/arithmetic_addition/impl/NEON/qsymm16.cpp index 538c600187..650f25ed5a 100644 --- a/src/core/NEON/kernels/arithmetic_addition/impl/NEON/qsymm16.cpp +++ b/src/core/NEON/kernels/arithmetic_addition/impl/NEON/qsymm16.cpp @@ -26,7 +26,6 @@ #include "arm_compute/core/Types.h" #include "arm_compute/core/utils/misc/Traits.h" #include "src/core/NEON/wrapper/intrinsics/intrinsics.h" -#include "src/core/common/StdTypes.h" #include "src/core/helpers/WindowHelpers.h" namespace arm_compute diff --git a/src/core/NEON/kernels/batchnormalization/impl/NEON/fp16.cpp b/src/core/NEON/kernels/batchnormalization/impl/NEON/fp16.cpp index fd17b98f7b..704f003521 100644 --- a/src/core/NEON/kernels/batchnormalization/impl/NEON/fp16.cpp +++ b/src/core/NEON/kernels/batchnormalization/impl/NEON/fp16.cpp @@ -27,7 +27,6 @@ #include "src/core/NEON/NEMath.h" #include "src/core/NEON/kernels/detail/NEActivationFunctionDetail.h" #include "src/core/NEON/wrapper/wrapper.h" -#include "src/core/common/StdTypes.h" #include "src/core/common/Validate.h" #include diff --git a/src/core/NEON/kernels/batchnormalization/impl/NEON/fp32.cpp b/src/core/NEON/kernels/batchnormalization/impl/NEON/fp32.cpp index 5b375e5d4d..76a71ed738 100644 --- a/src/core/NEON/kernels/batchnormalization/impl/NEON/fp32.cpp +++ b/src/core/NEON/kernels/batchnormalization/impl/NEON/fp32.cpp @@ -27,7 +27,6 @@ #include "src/core/NEON/NEMath.h" #include "src/core/NEON/kernels/detail/NEActivationFunctionDetail.h" #include "src/core/NEON/wrapper/wrapper.h" -#include "src/core/common/StdTypes.h" #include "src/core/common/Validate.h" #include diff --git a/src/core/NEON/kernels/batchnormalization/impl/SVE/fp16.cpp b/src/core/NEON/kernels/batchnormalization/impl/SVE/fp16.cpp index 00326ffc8d..5638dcef0a 100644 --- a/src/core/NEON/kernels/batchnormalization/impl/SVE/fp16.cpp +++ b/src/core/NEON/kernels/batchnormalization/impl/SVE/fp16.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,7 +25,6 @@ #include "arm_compute/core/ITensorPack.h" #include "arm_compute/core/Window.h" #include "src/core/NEON/SVEMath.h" -#include "src/core/common/StdTypes.h" #include "src/core/common/Validate.h" #include diff --git a/src/core/NEON/kernels/batchnormalization/impl/SVE/fp32.cpp b/src/core/NEON/kernels/batchnormalization/impl/SVE/fp32.cpp index 317befd61e..51397aca3a 100644 --- a/src/core/NEON/kernels/batchnormalization/impl/SVE/fp32.cpp +++ b/src/core/NEON/kernels/batchnormalization/impl/SVE/fp32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,7 +25,6 @@ #include "arm_compute/core/ITensorPack.h" #include "arm_compute/core/Window.h" #include "src/core/NEON/SVEMath.h" -#include "src/core/common/StdTypes.h" #include "src/core/common/Validate.h" #include diff --git a/src/core/NEON/kernels/floor/impl/NEON/fp16.cpp b/src/core/NEON/kernels/floor/impl/NEON/fp16.cpp deleted file mode 100644 index 4f56ca9daf..0000000000 --- a/src/core/NEON/kernels/floor/impl/NEON/fp16.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2020 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. - */ -#if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && defined(ENABLE_FP16_KERNELS) - -#include "src/core/NEON/NEMath.h" -#include "src/core/common/StdTypes.h" -#include "src/core/common/Validate.h" - -#include -#include -#include - -namespace arm_compute -{ -namespace cpu -{ -constexpr int step = 8; - -void fp16_neon_floor(const void *src, void *dst, int len) -{ - ARM_COMPUTE_ASSERT_NOT_NULLPTR(src); - ARM_COMPUTE_ASSERT_NOT_NULLPTR(dst); - ARM_COMPUTE_ASSERT(len >= 0); - - auto psrc = static_cast(src); - auto pdst = static_cast(dst); - - for(; len >= step; len -= step) - { - vst1q_f16(pdst, vfloorq_f16(vld1q_f16(psrc))); - psrc += step; - pdst += step; - } - - for(; len > 0; --len) - { - *pdst = std::floor(*psrc); - ++psrc; - ++pdst; - } -} -} // namespace cpu -} // namespace arm_compute -#endif /* defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && defined(ENABLE_FP16_KERNELS) */ diff --git a/src/core/NEON/kernels/floor/impl/NEON/fp32.cpp b/src/core/NEON/kernels/floor/impl/NEON/fp32.cpp deleted file mode 100644 index 3f4b14b3e5..0000000000 --- a/src/core/NEON/kernels/floor/impl/NEON/fp32.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2020 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 "src/core/NEON/NEMath.h" -#include "src/core/common/StdTypes.h" -#include "src/core/common/Validate.h" - -#include -#include -#include - -namespace arm_compute -{ -namespace cpu -{ -constexpr int step = 4; - -void fp32_neon_floor(const void *src, void *dst, int len) -{ - ARM_COMPUTE_ASSERT_NOT_NULLPTR(src); - ARM_COMPUTE_ASSERT_NOT_NULLPTR(dst); - ARM_COMPUTE_ASSERT(len >= 0); - - auto psrc = static_cast(src); - auto pdst = static_cast(dst); - - for(; len >= step; len -= step) - { - vst1q_f32(pdst, vfloorq_f32(vld1q_f32(psrc))); - psrc += step; - pdst += step; - } - - for(; len > 0; --len) - { - *pdst = std::floor(*psrc); - ++pdst; - ++psrc; - } -} -} // namespace cpu -} // namespace arm_compute diff --git a/src/core/NEON/kernels/floor/impl/list.h b/src/core/NEON/kernels/floor/impl/list.h deleted file mode 100644 index 0eb66e0090..0000000000 --- a/src/core/NEON/kernels/floor/impl/list.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2020 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. - */ -#ifndef SRC_CORE_NEON_KERNELS_FLOOR_LIST_H -#define SRC_CORE_NEON_KERNELS_FLOOR_LIST_H - -namespace arm_compute -{ -namespace cpu -{ -#define DECLARE_FLOOR_KERNEL(func_name) \ - void func_name(const void *src, void *dst, int len) - -DECLARE_FLOOR_KERNEL(fp16_neon_floor); -DECLARE_FLOOR_KERNEL(fp32_neon_floor); - -#undef DECLARE_FLOOR_KERNEL -} // namespace cpu -} // namespace arm_compute - -#endif /* SRC_CORE_NEON_KERNELS_FLOOR_LIST_H */ diff --git a/src/core/common/Macros.h b/src/core/common/Macros.h new file mode 100644 index 0000000000..d791154e5c --- /dev/null +++ b/src/core/common/Macros.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 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. + */ +#ifndef ARM_COMPUTE_COMMON_MACROS_H +#define ARM_COMPUTE_COMMON_MACROS_H + +#define ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(TypeName) \ + TypeName(const TypeName &) = delete; \ + TypeName &operator=(const TypeName &) = delete; \ + TypeName(TypeName &&) = default; \ + TypeName &operator=(TypeName &&) = default + +#endif /* ARM_COMPUTE_COMMON_MACROS_H */ diff --git a/src/core/common/StdTypes.h b/src/core/common/StdTypes.h deleted file mode 100644 index 3fba6187a3..0000000000 --- a/src/core/common/StdTypes.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2020 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. - */ -#ifndef SRC_CORE_COMMON_STDTYPES_H -#define SRC_CORE_COMMON_STDTYPES_H - -#include - -namespace arm_compute -{ -using u8 = uint8_t; -using s8 = int8_t; -using u16 = uint16_t; -using s16 = int16_t; -using u32 = uint32_t; -using s32 = int32_t; -using f32 = float; -#if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) -using f16 = __fp16; -#endif /* defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) */ -} // namespace arm_compute - -#endif /* SRC_CORE_COMMON_STDTYPES_H */ diff --git a/src/core/cpu/ICpuKernel.h b/src/core/cpu/ICpuKernel.h new file mode 100644 index 0000000000..650b3a7d0b --- /dev/null +++ b/src/core/cpu/ICpuKernel.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 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. + */ +#ifndef ARM_COMPUTE_ICPUKERNEL_H +#define ARM_COMPUTE_ICPUKERNEL_H + +#include "arm_compute/core/CPP/ICPPKernel.h" + +namespace arm_compute +{ +namespace cpu +{ +using ICpuKernel = arm_compute::ICPPKernel; +} // namespace cpu +} // namespace arm_compute +#endif /* ARM_COMPUTE_ICPUKERNEL_H */ diff --git a/src/core/cpu/kernels/CpuFloorKernel.h b/src/core/cpu/kernels/CpuFloorKernel.h new file mode 100644 index 0000000000..dc3a9d5ff1 --- /dev/null +++ b/src/core/cpu/kernels/CpuFloorKernel.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2017-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. + */ +#ifndef ARM_COMPUTE_CPU_FLOOR_KERNEL_H +#define ARM_COMPUTE_CPU_FLOOR_KERNEL_H + +#include "src/core/common/Macros.h" +#include "src/core/cpu/ICpuKernel.h" + +namespace arm_compute +{ +namespace cpu +{ +namespace kernels +{ +/** Cpu accelarated kernel to perform a floor operation */ +class CpuFloorKernel : public ICpuKernel +{ +public: + CpuFloorKernel() = default; + ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(CpuFloorKernel); + /** Set the source, destination of the kernel + * + * @param[in] src Source tensor. Data type supported: F16/F32. + * @param[out] dst Destination tensor. Same as @p src + */ + void configure(const ITensorInfo *src, ITensorInfo *dst); + /** Static function to check if given info will lead to a valid configuration of @ref CpuFloorKernel + * + * @param[in] src Source tensor info. Data type supported: F16/F32. + * @param[in] dst Destination tensor info. Same as @p src + * + * @return a status + */ + static Status validate(const ITensorInfo *src, const ITensorInfo *dst); + /** Infer execution window + * + * @param[in] src Source tensor info. Data type supported: F16/F32. + * @param[in] dst Destination tensor info. Same as @p src + * + * @return an execution Window + */ + Window infer_window(const ITensorInfo *src, const ITensorInfo *dst); + + // Inherited methods overridden: + void run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) final; + const char *name() const final; +}; +} // namespace kernels +} // namespace cpu +} // namespace arm_compute +#endif /* ARM_COMPUTE_CPU_FLOOR_KERNEL_H */ diff --git a/src/core/cpu/kernels/floor/CpuFloorKernel.cpp b/src/core/cpu/kernels/floor/CpuFloorKernel.cpp new file mode 100644 index 0000000000..738f04d14a --- /dev/null +++ b/src/core/cpu/kernels/floor/CpuFloorKernel.cpp @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2017-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 "src/core/cpu/kernels/CpuFloorKernel.h" + +#include "arm_compute/core/Coordinates.h" +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/ITensor.h" +#include "arm_compute/core/Validate.h" +#include "src/core/CPP/Validate.h" +#include "src/core/helpers/AutoConfiguration.h" +#include "src/core/helpers/WindowHelpers.h" + +#include "src/core/common/Registrars.h" +#include "src/core/cpu/kernels/floor/impl/list.h" + +namespace arm_compute +{ +namespace cpu +{ +namespace kernels +{ +namespace +{ +struct FloorSelectorData +{ + DataType dt; +}; + +using FloorSelectorPtr = std::add_pointer::type; +using FloorUKernelPtr = std::add_pointer::type; + +struct FloorUKernel +{ + const char *name; + const FloorSelectorPtr is_selected; + FloorUKernelPtr func; +}; + +static const FloorUKernel available_kernels[] = +{ + { + "fp16_neon_floor", + [](const FloorSelectorData & data) { return data.dt == DataType::F16; }, + REGISTER_FP16_NEON(arm_compute::cpu::fp16_neon_floor) + }, + { + "f32_neon_floor", + [](const FloorSelectorData & data) { return data.dt == DataType::F32; }, + REGISTER_FP32_NEON(arm_compute::cpu::fp32_neon_floor) + }, +}; + +/** Micro-kernel selector + * + * @param[in] data Selection data passed to help pick the appropriate micro-kernel + * + * @return A matching micro-kernel else nullptr + */ +const FloorUKernel *get_implementation(const FloorSelectorData &data) +{ + for(const auto &uk : available_kernels) + { + if(uk.is_selected(data)) + { + return &uk; + } + } + return nullptr; +} + +Status validate_arguments(const ITensorInfo *src, const ITensorInfo *dst) +{ + ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src, dst); + + const auto *uk = get_implementation(FloorSelectorData{ src->data_type() }); + ARM_COMPUTE_RETURN_ERROR_ON(uk == nullptr || uk->func == nullptr); + + // Validate in case of configured output + if(dst->total_size() > 0) + { + ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst); + ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(src, dst); + } + + return Status{}; +} +} // namespace + +void CpuFloorKernel::configure(const ITensorInfo *src, ITensorInfo *dst) +{ + ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst); + + // Auto initialize output + auto_init_if_empty(*dst, src->tensor_shape(), 1, src->data_type()); + + // Validate + ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, dst)); + + // Configure kernel window + const Window win = calculate_max_window(*src, Steps()); + + Coordinates coord; + coord.set_num_dimensions(dst->num_dimensions()); + dst->set_valid_region(ValidRegion(coord, dst->tensor_shape())); + + ICPPKernel::configure(win); +} + +Window CpuFloorKernel::infer_window(const ITensorInfo *src, const ITensorInfo *dst) +{ + ARM_COMPUTE_UNUSED(dst); + ARM_COMPUTE_ERROR_ON(!bool(validate_arguments(src, dst))); + + Window win; + win.use_tensor_dimensions(src->tensor_shape()); + return win; +} + +Status CpuFloorKernel::validate(const ITensorInfo *input, const ITensorInfo *output) +{ + ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output)); + return Status{}; +} + +void CpuFloorKernel::run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) +{ + ARM_COMPUTE_UNUSED(info); + ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); + ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(IKernel::window(), window); + + ARM_COMPUTE_ERROR_ON(tensors.empty()); + + const ITensor *src = tensors.get_const_tensor(TensorType::ACL_SRC); + ITensor *dst = tensors.get_tensor(TensorType::ACL_DST); + + const auto len = static_cast(window.x().end()) - static_cast(window.x().start()); + const auto *ukernel = get_implementation(FloorSelectorData{ src->info()->data_type() }); + + Window win{ window }; + win.set(Window::DimX, Window::Dimension(0, 1, 1)); + + Iterator src_it(src, win); + Iterator dst_it(dst, win); + + execute_window_loop(win, [&](const Coordinates &) + { + ukernel->func(src_it.ptr(), dst_it.ptr(), len); + }, + src_it, dst_it); +} + +const char *CpuFloorKernel::name() const +{ + return "CpuFloorKernel"; +} +} // namespace kernels +} // namespace cpu +} // namespace arm_compute diff --git a/src/core/cpu/kernels/floor/impl/NEON/fp16.cpp b/src/core/cpu/kernels/floor/impl/NEON/fp16.cpp new file mode 100644 index 0000000000..0d31eb77f8 --- /dev/null +++ b/src/core/cpu/kernels/floor/impl/NEON/fp16.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2020-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. + */ +#if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && defined(ENABLE_FP16_KERNELS) + +#include "src/core/NEON/NEMath.h" +#include "src/core/common/Validate.h" + +#include +#include +#include + +namespace arm_compute +{ +namespace cpu +{ +constexpr int step = 8; + +void fp16_neon_floor(const void *src, void *dst, int len) +{ + ARM_COMPUTE_ASSERT_NOT_NULLPTR(src); + ARM_COMPUTE_ASSERT_NOT_NULLPTR(dst); + ARM_COMPUTE_ASSERT(len >= 0); + + auto psrc = static_cast(src); + auto pdst = static_cast<__fp16 *>(dst); + + for(; len >= step; len -= step) + { + vst1q_f16(pdst, vfloorq_f16(vld1q_f16(psrc))); + psrc += step; + pdst += step; + } + + for(; len > 0; --len) + { + *pdst = std::floor(*psrc); + ++psrc; + ++pdst; + } +} +} // namespace cpu +} // namespace arm_compute +#endif /* defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && defined(ENABLE_FP16_KERNELS) */ diff --git a/src/core/cpu/kernels/floor/impl/NEON/fp32.cpp b/src/core/cpu/kernels/floor/impl/NEON/fp32.cpp new file mode 100644 index 0000000000..dd63f9f9d7 --- /dev/null +++ b/src/core/cpu/kernels/floor/impl/NEON/fp32.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2020-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 "src/core/NEON/NEMath.h" +#include "src/core/common/Validate.h" + +#include +#include +#include + +namespace arm_compute +{ +namespace cpu +{ +constexpr int step = 4; + +void fp32_neon_floor(const void *src, void *dst, int len) +{ + ARM_COMPUTE_ASSERT_NOT_NULLPTR(src); + ARM_COMPUTE_ASSERT_NOT_NULLPTR(dst); + ARM_COMPUTE_ASSERT(len >= 0); + + auto psrc = static_cast(src); + auto pdst = static_cast(dst); + + for(; len >= step; len -= step) + { + vst1q_f32(pdst, vfloorq_f32(vld1q_f32(psrc))); + psrc += step; + pdst += step; + } + + for(; len > 0; --len) + { + *pdst = std::floor(*psrc); + ++pdst; + ++psrc; + } +} +} // namespace cpu +} // namespace arm_compute diff --git a/src/core/cpu/kernels/floor/impl/list.h b/src/core/cpu/kernels/floor/impl/list.h new file mode 100644 index 0000000000..4367e0ffc9 --- /dev/null +++ b/src/core/cpu/kernels/floor/impl/list.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2020-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. + */ +#ifndef SRC_CORE_NEON_KERNELS_FLOOR_LIST_H +#define SRC_CORE_NEON_KERNELS_FLOOR_LIST_H + +namespace arm_compute +{ +namespace cpu +{ +#define DECLARE_FLOOR_KERNEL(func_name) \ + void func_name(const void *src, void *dst, int len) + +DECLARE_FLOOR_KERNEL(fp16_neon_floor); +DECLARE_FLOOR_KERNEL(fp32_neon_floor); + +#undef DECLARE_FLOOR_KERNEL +} // namespace cpu +} // namespace arm_compute + +#endif /* SRC_CORE_NEON_KERNELS_FLOOR_LIST_H */ diff --git a/src/runtime/NEON/functions/NEFloor.cpp b/src/runtime/NEON/functions/NEFloor.cpp index 74149e6f24..b4ecb1ef38 100644 --- a/src/runtime/NEON/functions/NEFloor.cpp +++ b/src/runtime/NEON/functions/NEFloor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020 Arm Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -23,19 +23,44 @@ */ #include "arm_compute/runtime/NEON/functions/NEFloor.h" -#include "src/core/NEON/kernels/NEFloorKernel.h" +#include "src/runtime/cpu/operators/CpuFloor.h" namespace arm_compute { +NEFloor::NEFloor() + : _impl(std::make_unique()) +{ +} +NEFloor::NEFloor(NEFloor &&) = default; +NEFloor &NEFloor::operator=(NEFloor &&) = default; +NEFloor::~NEFloor() = default; + +struct NEFloor::Impl +{ + const ITensor *src{ nullptr }; + ITensor *dst{ nullptr }; + std::unique_ptr op{ nullptr }; +}; + void NEFloor::configure(const ITensor *input, ITensor *output) { - auto k = std::make_unique(); - k->configure(input, output); - _kernel = std::move(k); + _impl->src = input; + _impl->dst = output; + + _impl->op = std::make_unique(); + _impl->op->configure(_impl->src->info(), _impl->dst->info()); } Status NEFloor::validate(const ITensorInfo *input, const ITensorInfo *output) { - return NEFloorKernel::validate(input, output); + return cpu::CpuFloor::validate(input, output); +} + +void NEFloor::run() +{ + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC, _impl->src); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } } // namespace arm_compute diff --git a/src/runtime/cpu/ICpuOperator.h b/src/runtime/cpu/ICpuOperator.h new file mode 100644 index 0000000000..bb7de1b69e --- /dev/null +++ b/src/runtime/cpu/ICpuOperator.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 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. + */ +#ifndef ARM_COMPUTE_ICPUOPERATOR_H +#define ARM_COMPUTE_ICPUOPERATOR_H + +#include "arm_compute/runtime/NEON/INEOperator.h" + +namespace arm_compute +{ +namespace cpu +{ +using ICpuOperator = arm_compute::experimental::INEOperator; +} // namespace cpu +} // namespace arm_compute +#endif /* ARM_COMPUTE_ICPUOPERATOR_H */ diff --git a/src/runtime/cpu/operators/CpuFloor.cpp b/src/runtime/cpu/operators/CpuFloor.cpp new file mode 100644 index 0000000000..4e169a04be --- /dev/null +++ b/src/runtime/cpu/operators/CpuFloor.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (c) 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 "src/runtime/cpu/operators/CpuFloor.h" + +#include "src/core/cpu/kernels/CpuFloorKernel.h" + +namespace arm_compute +{ +namespace cpu +{ +void CpuFloor::configure(const ITensorInfo *src, ITensorInfo *dst) +{ + auto k = std::make_unique(); + k->configure(src, dst); + _kernel = std::move(k); +} + +Status CpuFloor::validate(const ITensorInfo *src, const ITensorInfo *dst) +{ + return kernels::CpuFloorKernel::validate(src, dst); +} +} // namespace cpu +} // namespace arm_compute diff --git a/src/runtime/cpu/operators/CpuFloor.h b/src/runtime/cpu/operators/CpuFloor.h new file mode 100644 index 0000000000..30c850a2ca --- /dev/null +++ b/src/runtime/cpu/operators/CpuFloor.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 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. + */ +#ifndef ARM_COMPUTE_CPU_FLOOR_H +#define ARM_COMPUTE_CPU_FLOOR_H + +#include "src/runtime/cpu/ICpuOperator.h" + +namespace arm_compute +{ +namespace cpu +{ +/** Basic function to run @ref CpuFloorKernel */ +class CpuFloor : public ICpuOperator +{ +public: + /** Constructor */ + CpuFloor() = default; + /** Set the input and output tensor. + * + * @param[in] src Source tensor info. Data types supported: F16/F32. + * @param[in] dst Destination tensor info. Data type supported: same as @p src + */ + void configure(const ITensorInfo *src, ITensorInfo *dst); + /** Static function to check if given info will lead to a valid configuration of @ref CpuFloor + * + * @param[in] src Source tensor info. Data types supported: F16/F32. + * @param[in] dst Destination tensor info. Data type supported: same as @p src + * + * @return a status + */ + static Status validate(const ITensorInfo *input, const ITensorInfo *output); +}; +} // namespace cpu +} // namespace arm_compute +#endif /* ARM_COMPUTE_CPU_FLOOR_H */ -- cgit v1.2.1