diff options
author | Gian Marco Iodice <gianmarco.iodice@arm.com> | 2017-06-23 10:38:25 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-09-17 14:15:39 +0100 |
commit | 5cb4c42cb5d781a44409ebc97a408e1379ce182d (patch) | |
tree | dbb544322eacee38f9719225e037aca90ba6fbf3 /arm_compute | |
parent | 0a8334cb78dae66fdc31257a96ba15f7c41bde50 (diff) | |
download | ComputeLibrary-5cb4c42cb5d781a44409ebc97a408e1379ce182d.tar.gz |
COMPMID-414 - Port CLConvolutionLayer to support 8 bit fixed point - CLWeightsReshapeKernel
Change-Id: Ie32e6bdd557a8243eb9988aa7eab4e4ca2291e79
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/78701
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Moritz Pflanzer <moritz.pflanzer@arm.com>
Diffstat (limited to 'arm_compute')
3 files changed, 21 insertions, 69 deletions
diff --git a/arm_compute/core/CL/kernels/CLWeightsReshapeKernel.h b/arm_compute/core/CL/kernels/CLWeightsReshapeKernel.h index 1dc8a8b80e..0d00f0e00e 100644 --- a/arm_compute/core/CL/kernels/CLWeightsReshapeKernel.h +++ b/arm_compute/core/CL/kernels/CLWeightsReshapeKernel.h @@ -31,11 +31,8 @@ namespace arm_compute class CLWeightsReshapeKernel : public ICLKernel { public: - /** Constructor. - * - * @param[in] is_shared Flag to indicate whether the weights are shared or not. - */ - CLWeightsReshapeKernel(bool is_shared = false); + /** Constructor.*/ + CLWeightsReshapeKernel(); /** Prevent instances of this class from being copied (As this class contains pointers) */ CLWeightsReshapeKernel(const CLWeightsReshapeKernel &) = delete; /** Prevent instances of this class from being copied (As this class contains pointers) */ @@ -50,7 +47,7 @@ public: /** Set the input and output of the kernel. * * @param[in] input The input tensor to convert. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM] if shared, - * and 5D tensor with dimensions [kernel_x, kernel_y, IFM, OFM, num_patches] if unshared. Data types supported: F16, F32 + * and 5D tensor with dimensions [kernel_x, kernel_y, IFM, OFM, num_patches] if unshared. Data types supported: QS8/F16/F32 * @param[in] biases The shared biases tensor to append. Bias is 1D tensor with dimensions [OFM] if shared and 2D tensor with * dimensions [OFM, num_patches] if unshared. Data types supported: Same as @p input * @param[out] output The output tensor. Should be a 2D Tensor. Data types supported: Same as @p input @@ -58,57 +55,12 @@ public: void configure(const ICLTensor *input, const ICLTensor *biases, ICLTensor *output); // Inherited methods overridden: - virtual void run(const Window &window, cl::CommandQueue &queue) = 0; + void run(const Window &window, cl::CommandQueue &queue) override; -protected: - bool _is_shared; +private: const ICLTensor *_input; const ICLTensor *_biases; ICLTensor *_output; }; - -/** Interface for the weights reshape kernel used by convolution and fully connected layers. - * - * Rearranges each 3-dimensional kernel to a single row leading to a matrix with linearized kernels. - * In combination with the @ref CLIm2ColKernel can transform a convolution into a matrix multiplication. - * - * For example assuming a 3D weight kernel of 3x3 dimensions and depth of 2 we have: - * @f[ - * \left( \begin{array}{ccc} - * a000 & a001 & a002 \\ - * a010 & a011 & a012 \\ - * a020 & a021 & a022 \\ - * \end{array} \right) - * \left( \begin{array}{ccc} - * a100 & a101 & a102 \\ - * a110 & a111 & a112 \\ - * a120 & a121 & a122 \\ - * \end{array} \right) - * \rightarrow - * \left( \begin{array}{ccccccccc} - * a000 & a001 & a002 & a010 & a011 & a012 & a020 & a021 & a022 & a100 & a101 & a102 & a110 & a111 & a112 & a120 & a121 & a122 \\ - * \end{array} \right) - * @f] - */ -class CLConvolutionLayerWeightsReshapeKernel : public CLWeightsReshapeKernel -{ -public: - /** Default constructor */ - CLConvolutionLayerWeightsReshapeKernel(); - - // Inherited methods overridden: - void run(const Window &window, cl::CommandQueue &queue) override; -}; - -/** Interface for the weights reshape kernel used by locally connected layers. */ -class CLLocallyConnectedLayerWeightsReshapeKernel : public CLWeightsReshapeKernel -{ -public: - /** Default constructor */ - CLLocallyConnectedLayerWeightsReshapeKernel(); - - // Inherited methods overridden: - void run(const Window &window, cl::CommandQueue &queue) override; -}; } #endif /*__ARM_COMPUTE_CLWEIGHTSRESHAPEKERNEL_H__ */ diff --git a/arm_compute/runtime/CL/functions/CLConvolutionLayer.h b/arm_compute/runtime/CL/functions/CLConvolutionLayer.h index 6a40396f9a..8030b40a71 100644 --- a/arm_compute/runtime/CL/functions/CLConvolutionLayer.h +++ b/arm_compute/runtime/CL/functions/CLConvolutionLayer.h @@ -53,7 +53,7 @@ public: CLConvolutionLayerReshapeWeights(); /** Set the input and output tensors. * - * @param[in] weights Weights tensor. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. Data type supported: F32. + * @param[in] weights Weights tensor. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. Data type supported: QS8/F16/F32. * @param[in] biases Biases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. Data type supported: Same as @p weights. * @param[out] output Destination tensor. Data types supported: Same as @p weights. * @param[in] transpose1xW True if the weights are to undergo a 1xW transposition after reshaping (in case of GEMM operation), false otherwise. @@ -64,16 +64,16 @@ public: void run() override; private: - CLConvolutionLayerWeightsReshapeKernel _weights_reshape_kernel; - CLGEMMTranspose1xWKernel _weights_transposed_kernel; - CLTensor _weights_reshaped; - bool _transpose1xW; + CLWeightsReshapeKernel _weights_reshape_kernel; + CLGEMMTranspose1xWKernel _weights_transposed_kernel; + CLTensor _weights_reshaped; + bool _transpose1xW; }; /** Basic function to compute the convolution layer. This function calls the following OpenCL kernels: * - * -# @ref CLConvolutionLayerWeightsReshapeKernel (executed only once for each configuration) - * -# @ref CLGEMMTranspose1xWKernel (executed only once for each configuration) + * -# @ref CLWeightsReshapeKernel (executed only once for each configuration) + * -# @ref CLGEMMTranspose1xWKernel (executed only once for each configuration) * -# @ref CLIm2ColKernel * -# @ref CLGEMMInterleave4x4Kernel * -# @ref CLGEMMMatrixMultiplyKernel diff --git a/arm_compute/runtime/CL/functions/CLLocallyConnectedLayer.h b/arm_compute/runtime/CL/functions/CLLocallyConnectedLayer.h index b4e469196e..5f4f1ba1d7 100644 --- a/arm_compute/runtime/CL/functions/CLLocallyConnectedLayer.h +++ b/arm_compute/runtime/CL/functions/CLLocallyConnectedLayer.h @@ -39,7 +39,7 @@ class ICLTensor; /** Basic function to compute the locally connected layer. This function calls the following OpenCL kernels: * - * -# @ref CLLocallyConnectedLayerWeightsReshapeKernel (executed only once for each configuration) + * -# @ref CLWeightsReshapeKernel (executed only once for each configuration) * -# @ref CLIm2ColKernel * -# @ref CLLocallyConnectedMatrixMultiplyKernel * -# @ref CLCol2ImKernel @@ -66,14 +66,14 @@ public: void run() override; private: - CLIm2ColKernel _input_im2col_kernel; - CLLocallyConnectedLayerWeightsReshapeKernel _weights_reshape_kernel; - CLLocallyConnectedMatrixMultiplyKernel _mm_kernel; - CLCol2ImKernel _output_col2im_kernel; - CLTensor _input_im2col_reshaped; - CLTensor _weights_reshaped; - CLTensor _gemm_output; - bool _is_first_run; + CLIm2ColKernel _input_im2col_kernel; + CLWeightsReshapeKernel _weights_reshape_kernel; + CLLocallyConnectedMatrixMultiplyKernel _mm_kernel; + CLCol2ImKernel _output_col2im_kernel; + CLTensor _input_im2col_reshaped; + CLTensor _weights_reshaped; + CLTensor _gemm_output; + bool _is_first_run; }; } #endif /* __ARM_COMPUTE_CLLOCALLYCONNECTEDLAYER_H__ */ |