From 574775c7fa78a094bbeb7f9f87aca832936884e2 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Mon, 18 Feb 2019 20:08:02 +0000 Subject: COMPMID-1937: Adds support for DequantizationLayer for NEON/CL. Change-Id: I4b73edd176a277294e0e42e642460bc61210778a Signed-off-by: Georgios Pinitas Reviewed-on: https://review.mlplatform.org/c/744 Tested-by: Arm Jenkins Reviewed-by: Giuseppe Rossini --- .../core/CL/kernels/CLDequantizationLayerKernel.h | 25 ++++-------- .../NEON/kernels/NEDequantizationLayerKernel.h | 27 +++++-------- .../runtime/CL/functions/CLDequantizationLayer.h | 46 ++++++---------------- .../runtime/NEON/functions/NEDequantizationLayer.h | 43 ++++++-------------- 4 files changed, 41 insertions(+), 100 deletions(-) (limited to 'arm_compute') diff --git a/arm_compute/core/CL/kernels/CLDequantizationLayerKernel.h b/arm_compute/core/CL/kernels/CLDequantizationLayerKernel.h index 25fd3378cb..3dfb19b306 100644 --- a/arm_compute/core/CL/kernels/CLDequantizationLayerKernel.h +++ b/arm_compute/core/CL/kernels/CLDequantizationLayerKernel.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -30,11 +30,7 @@ namespace arm_compute { class ICLTensor; -/** Interface for the dequantization layer kernel. - * - * @note The implementation supports only 3D input tensors. - * - */ +/** Interface for the dequantization layer kernel. */ class CLDequantizationLayerKernel : public ICLKernel { public: @@ -52,22 +48,18 @@ public: ~CLDequantizationLayerKernel() = default; /** Set the input, output, min and max. * - * @param[in] input Source tensor. Data types supported: U8. - * @param[out] output Destination tensor. Data types supported: F32. - * @param[in] min_max Pointer to the tensor with shape [2, batches] which stores the minimum and maximum value for each 3D input tensor. - * The dimensions over the second must match the batched dimensions of the input tensor. Data type supported: F32. + * @param[in] input Source tensor. Data types supported: QASYMM8. + * @param[out] output Destination tensor. Data types supported: F16/F32. */ - void configure(const ICLTensor *input, ICLTensor *output, const ICLTensor *min_max); + void configure(const ICLTensor *input, ICLTensor *output); /** Static function to check if given info will lead to a valid configuration of @ref CLDequantizationLayerKernel * - * @param[in] input Input tensor info. Data types supported: U8. - * @param[in] output Output tensor info. Data types supported: F32. - * @param[in] min_max Info for the tensor with shape [2, batches] which stores the minimum and maximum value for each 3D input tensor. - * The dimensions over the second must match the batched dimensions of the input tensor. Data type supported: F32. + * @param[in] input Input tensor info. Data types supported: QASYMM8. + * @param[in] output Output tensor info. Data types supported: F16/F32. * * @return a status */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output, const ITensorInfo *min_max); + static Status validate(const ITensorInfo *input, const ITensorInfo *output); // Inherited methods overridden: void run(const Window &window, cl::CommandQueue &queue) override; @@ -75,7 +67,6 @@ public: private: const ICLTensor *_input; ICLTensor *_output; - const ICLTensor *_min_max; }; } // namespace arm_compute #endif /*__ARM_COMPUTE_CLDEQUANTIZATIONLAYERKERNEL_H__ */ diff --git a/arm_compute/core/NEON/kernels/NEDequantizationLayerKernel.h b/arm_compute/core/NEON/kernels/NEDequantizationLayerKernel.h index f48e76f340..7d215f5f7b 100644 --- a/arm_compute/core/NEON/kernels/NEDequantizationLayerKernel.h +++ b/arm_compute/core/NEON/kernels/NEDequantizationLayerKernel.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -30,11 +30,7 @@ namespace arm_compute { class ITensor; -/** Interface for the dequantization layer kernel. - * - * @note The implementation supports only 3D input tensors - * - */ +/** Interface for the dequantization layer kernel. */ class NEDequantizationLayerKernel : public INEKernel { public: @@ -54,24 +50,20 @@ public: NEDequantizationLayerKernel &operator=(NEDequantizationLayerKernel &&) = default; /** Default destructor */ ~NEDequantizationLayerKernel() = default; - /** Set input, output, min and max. + /** Set input, output tensors. * - * @param[in] input Source tensor with at least 3 dimensions. The dimensions over the third will be interpreted as batches. Data type supported: U8. - * @param[out] output Destination tensor with the same dimensions of input. Data type supported: F32. - * @param[in] min_max Pointer to the tensor with shape [2, batches] which stores the minimum and maximum value for each 3D input tensor. - * The dimensions over the second must match the batched dimensions of the input tensor. Data type supported: F32 + * @param[in] input Source tensor. Data type supported: QASYMM8. + * @param[out] output Destination tensor with the same dimensions of input. Data type supported: F16/F32. */ - void configure(const ITensor *input, ITensor *output, const ITensor *min_max); + void configure(const ITensor *input, ITensor *output); /** Static function to check if given info will lead to a valid configuration of @ref NEDequantizationLayerKernel * - * @param[in] input Input tensor info. Data types supported: U8. - * @param[in] output Output tensor info. Data types supported: F32. - * @param[in] min_max Info for the tensor with shape [2, batches] which stores the minimum and maximum value for each 3D input tensor. - * The dimensions over the second must match the batched dimensions of the input tensor. Data type supported: F32. + * @param[in] input Input tensor info. Data types supported: QASYMM8. + * @param[in] output Output tensor info. Data types supported: F16/F32. * * @return a status */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output, const ITensorInfo *min_max); + static Status validate(const ITensorInfo *input, const ITensorInfo *output); // Inherited methods overridden: void run(const Window &window, const ThreadInfo &info) override; @@ -79,7 +71,6 @@ public: private: const ITensor *_input; ITensor *_output; - const ITensor *_min_max; }; } // namespace arm_compute #endif /*__ARM_COMPUTE_NEDEQUANTIZATIONLAYERKERNEL_H__ */ diff --git a/arm_compute/runtime/CL/functions/CLDequantizationLayer.h b/arm_compute/runtime/CL/functions/CLDequantizationLayer.h index efd28fc819..cf7c5761e4 100644 --- a/arm_compute/runtime/CL/functions/CLDequantizationLayer.h +++ b/arm_compute/runtime/CL/functions/CLDequantizationLayer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -24,55 +24,33 @@ #ifndef __ARM_COMPUTE_CLDEQUANTIZATIONLAYER_H__ #define __ARM_COMPUTE_CLDEQUANTIZATIONLAYER_H__ -#include "arm_compute/runtime/IFunction.h" - -#include "arm_compute/core/CL/kernels/CLDequantizationLayerKernel.h" -#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/CL/ICLSimpleFunction.h" #include "arm_compute/core/Types.h" namespace arm_compute { +// Forward declarations class ICLTensor; -/** Basic function to simulate a dequantization layer. This function calls the following CL kernels: - * - * -# @ref CLDequantizationLayerKernel - * - */ -class CLDequantizationLayer : public IFunction +/** Basic function to run @ref CLDequantizationLayerKernel that dequantizes an input tensor */ +class CLDequantizationLayer : public ICLSimpleFunction { public: - /** Default constructor */ - CLDequantizationLayer(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CLDequantizationLayer(const CLDequantizationLayer &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CLDequantizationLayer &operator=(const CLDequantizationLayer &) = delete; /** Set the input and output tensors. * - * @param[in] input Source tensor with at least 3 dimensions. The dimensions over the third will be interpreted as batches. Data types supported: U8. - * @param[out] output Destination tensor with the same dimensions of input. Data type supported: F32. - * @param[in] min_max Pointer to the tensor with shape [2, batches] which stores the minimum and maximum value for each 3D input tensor. - * The dimensions over the second must match the batched dimensions of the input tensor. Data type supported: F32. + * @param[in] input Source tensor with at least 3 dimensions. The dimensions over the third will be interpreted as batches. Data types supported: QASYMM8. + * @param[out] output Destination tensor with the same dimensions of input. Data type supported: F16/F32. */ - void configure(const ICLTensor *input, ICLTensor *output, const ICLTensor *min_max); + void configure(const ICLTensor *input, ICLTensor *output); /** Static function to check if given info will lead to a valid configuration of @ref CLDequantizationLayer * - * @param[in] input Input tensor info. Data types supported: U8. - * @param[in] output Output tensor info. Data type supported: F32. - * @param[in] min_max Info for the tensor with shape [2, batches] which stores the minimum and maximum value for each 3D input tensor. - * The dimensions over the second must match the batched dimensions of the input tensor. Data type supported: F32. + * @param[in] input Input tensor info. Data types supported: QASYMM8. + * @param[in] output Output tensor info. Data type supported: F16/F32. * * @return a status */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output, const ITensorInfo *min_max); - - // Inherited methods overridden: - void run() override; - -private: - CLDequantizationLayerKernel _dequantize_kernel; + static Status validate(const ITensorInfo *input, const ITensorInfo *output); }; -} +} // namespace arm_compute #endif /* __ARM_COMPUTE_CLDEQUANTIZATIONLAYER_H__ */ diff --git a/arm_compute/runtime/NEON/functions/NEDequantizationLayer.h b/arm_compute/runtime/NEON/functions/NEDequantizationLayer.h index 90c454ef3e..b7c5bac844 100644 --- a/arm_compute/runtime/NEON/functions/NEDequantizationLayer.h +++ b/arm_compute/runtime/NEON/functions/NEDequantizationLayer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -24,52 +24,33 @@ #ifndef __ARM_COMPUTE_NEDEQUANTIZATIONLAYER_H__ #define __ARM_COMPUTE_NEDEQUANTIZATIONLAYER_H__ -#include "arm_compute/runtime/IFunction.h" - -#include "arm_compute/core/NEON/kernels/NEDequantizationLayerKernel.h" +#include "arm_compute/runtime/NEON/INESimpleFunctionNoBorder.h" #include "arm_compute/core/Types.h" namespace arm_compute { +// Forward declarations class ITensor; -/** Basic function to simulate a dequantization layer. This function calls the following NEON kernels: - * - * @note The implementation supports only 3D input tensors - * - * -# @ref NEDequantizationLayerKernel - * - */ -class NEDequantizationLayer : public IFunction +/** Basic function to run @ref NEDequantizationLayerKernel that dequantizes an input tensor */ +class NEDequantizationLayer : public INESimpleFunctionNoBorder { public: - /** Default constructor */ - NEDequantizationLayer(); /** Configure the kernel. * - * @param[in] input Source tensor with at least 3 dimensions. The dimensions over the third will be interpreted as batches. Data types supported: U8. - * @param[out] output Destination tensor with the same dimensions of input. Data type supported: F32. - * @param[in] min_max Pointer to the tensor with shape [2, batches] which stores the minimum and maximum value for each 3D input tensor. - * The dimensions over the second must match the batched dimensions of the input tensor. Data type supported: F32 + * @param[in] input Source tensor. Data types supported: QASYMM8. + * @param[out] output Destination tensor with the same dimensions of input. Data type supported: F16/F32. */ - void configure(const ITensor *input, ITensor *output, const ITensor *min_max); + void configure(const ITensor *input, ITensor *output); /** Static function to check if given info will lead to a valid configuration of @ref NEDequantizationLayer * - * @param[in] input Input tensor info. Data types supported: U8. - * @param[in] output Output tensor info. Data type supported: F32. - * @param[in] min_max Info for the tensor with shape [2, batches] which stores the minimum and maximum value for each 3D input tensor. - * The dimensions over the second must match the batched dimensions of the input tensor. Data type supported: F32. + * @param[in] input Input tensor info. Data types supported: QASYMM8. + * @param[in] output Output tensor info. Data type supported: F16/F32. * * @return a status */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output, const ITensorInfo *min_max); - - // Inherited methods overridden: - void run() override; - -private: - NEDequantizationLayerKernel _dequantize_kernel; + static Status validate(const ITensorInfo *input, const ITensorInfo *output); }; -} +} // namespace arm_compute #endif /* __ARM_COMPUTE_NEDEQUANTIZATIONLAYER_H__ */ -- cgit v1.2.1