diff options
Diffstat (limited to 'arm_compute/runtime/CL/functions/CLConvertFullyConnectedWeights.h')
-rw-r--r-- | arm_compute/runtime/CL/functions/CLConvertFullyConnectedWeights.h | 69 |
1 files changed, 55 insertions, 14 deletions
diff --git a/arm_compute/runtime/CL/functions/CLConvertFullyConnectedWeights.h b/arm_compute/runtime/CL/functions/CLConvertFullyConnectedWeights.h index 123f6380bb..409430d595 100644 --- a/arm_compute/runtime/CL/functions/CLConvertFullyConnectedWeights.h +++ b/arm_compute/runtime/CL/functions/CLConvertFullyConnectedWeights.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 ARM Limited. + * Copyright (c) 2018-2021, 2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -24,29 +24,55 @@ #ifndef ARM_COMPUTE_CLCONVERTFULLYCONNECTEDWEIGHTS_H #define ARM_COMPUTE_CLCONVERTFULLYCONNECTEDWEIGHTS_H -#include "arm_compute/core/CL/kernels/CLConvertFullyConnectedWeightsKernel.h" +#include "arm_compute/core/CL/CLKernelLibrary.h" #include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/ICLSimpleFunction.h" +#include "arm_compute/runtime/IFunction.h" #include "arm_compute/runtime/ITransformWeights.h" +#include <memory> + namespace arm_compute { +class CLCompileContext; class ICLTensor; +class ITensorInfo; -/** Basic function to run @ref CLConvertFullyConnectedWeightsKernel. */ -class CLConvertFullyConnectedWeights : public ICLSimpleFunction +/** Basic function to run an @ref opencl::kernels::ClConvertFullyConnectedWeightsKernel. */ +class CLConvertFullyConnectedWeights : public IFunction { public: + /** Constructor */ + CLConvertFullyConnectedWeights(); + /** Destructor */ + ~CLConvertFullyConnectedWeights(); + /** Prevent instances of this class from being copied (As this class contains pointers) */ + CLConvertFullyConnectedWeights(const CLConvertFullyConnectedWeights &) = delete; + /** Default move constructor */ + CLConvertFullyConnectedWeights(CLConvertFullyConnectedWeights &&) = default; + /** Prevent instances of this class from being copied (As this class contains pointers) */ + CLConvertFullyConnectedWeights &operator=(const CLConvertFullyConnectedWeights &) = delete; + /** Default move assignment operator */ + CLConvertFullyConnectedWeights &operator=(CLConvertFullyConnectedWeights &&) = default; /** Initialize the function. * + * Valid data layouts: + * - NHWC + * - NCHW + * + * Valid data type configurations: + * |src |dst | + * |:--------------|:--------------| + * |All |All | + * * @param[in] input Source weights tensor to convert. Must be 2 dimensional. Data types supported: All. * @param[out] output The converted weights tensor. Shape and Data Type: Same as @p input. * @param[in] original_input_shape Shape of the original input tensor (the one entering fully connected layer). * @param[in] data_layout The data layout the weights have been trained in. - * - * @return A status */ - void configure(const ICLTensor *input, ICLTensor *output, const TensorShape &original_input_shape, DataLayout data_layout); + void configure(const ICLTensor *input, + ICLTensor *output, + const TensorShape &original_input_shape, + DataLayout data_layout); /** Initialize the function. * * @param[in] compile_context The compile context to be used. @@ -54,10 +80,12 @@ public: * @param[out] output The converted weights tensor. Shape and Data Type: Same as @p input. * @param[in] original_input_shape Shape of the original input tensor (the one entering fully connected layer). * @param[in] data_layout The data layout the weights have been trained in. - * - * @return A status */ - void configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const TensorShape &original_input_shape, DataLayout data_layout); + void configure(const CLCompileContext &compile_context, + const ICLTensor *input, + ICLTensor *output, + const TensorShape &original_input_shape, + DataLayout data_layout); /** Static function to check if given info will lead to a valid configuration of @ref CLConvertFullyConnectedWeights * * @param[in] input Source weights tensor info to convert. Must be 2 dimensional. Data types supported: All. @@ -65,12 +93,22 @@ public: * @param[in] original_input_shape Shape of the original input tensor (the one entering fully connected layer). * @param[in] data_layout The data layout the weights have been trained in. */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output, const TensorShape &original_input_shape, DataLayout data_layout); + static Status validate(const ITensorInfo *input, + const ITensorInfo *output, + const TensorShape &original_input_shape, + DataLayout data_layout); + + // Inherited methods overridden: + void run() override; + +private: + struct Impl; + std::unique_ptr<Impl> _impl; }; namespace weights_transformations { -/** Basic function to run @ref CLConvertFullyConnectedWeightsKernel. */ +/** Basic function to manage @ref CLConvertFullyConnectedWeights. */ class CLConvertFullyConnectedWeightsManaged : public ITransformWeights { public: @@ -116,7 +154,10 @@ public: * @param[in] original_input_shape Shape of the original input tensor (the one entering fully connected layer). * @param[in] data_layout The data layout the weights have been trained in. */ - void configure(const CLCompileContext &compile_context, const ICLTensor *input, const TensorShape &original_input_shape, DataLayout data_layout) + void configure(const CLCompileContext &compile_context, + const ICLTensor *input, + const TensorShape &original_input_shape, + DataLayout data_layout) { _func.configure(compile_context, input, &_output, original_input_shape, data_layout); } |