diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2017-11-14 15:32:57 +0000 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | 30902ed3befd225cb3a6915223d0941949b8d265 (patch) | |
tree | 6f701094ae52e8e4dc41b993febbff404e660c82 /arm_compute/core | |
parent | 77f0f879f8a9371e50fb1c5b2b5f7252b839883c (diff) | |
download | ComputeLibrary-30902ed3befd225cb3a6915223d0941949b8d265.tar.gz |
COMPMID-617: Add validation methods to ML CL functions.
Adds validation support to:
- CLDirectConvolution
- CLNormalizationLayer
- CLSoftmaxLayer
Change-Id: I9bd1e925e6db057c799169405f82ed21d20b87ee
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/95939
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'arm_compute/core')
-rw-r--r-- | arm_compute/core/CL/kernels/CLDirectConvolutionLayerKernel.h | 19 | ||||
-rw-r--r-- | arm_compute/core/CL/kernels/CLNormalizationLayerKernel.h | 11 | ||||
-rw-r--r-- | arm_compute/core/CL/kernels/CLSoftmaxLayerKernel.h | 37 | ||||
-rw-r--r-- | arm_compute/core/ITensorInfo.h | 5 | ||||
-rw-r--r-- | arm_compute/core/SubTensorInfo.h | 6 | ||||
-rw-r--r-- | arm_compute/core/TensorInfo.h | 3 |
6 files changed, 76 insertions, 5 deletions
diff --git a/arm_compute/core/CL/kernels/CLDirectConvolutionLayerKernel.h b/arm_compute/core/CL/kernels/CLDirectConvolutionLayerKernel.h index da786d71df..0564553b45 100644 --- a/arm_compute/core/CL/kernels/CLDirectConvolutionLayerKernel.h +++ b/arm_compute/core/CL/kernels/CLDirectConvolutionLayerKernel.h @@ -67,12 +67,25 @@ public: * @param[in] conv_info Contains padding and stride information described in @ref PadStrideInfo. */ void configure(const ICLTensor *input, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, const PadStrideInfo &conv_info); - - // Inherited methods overridden: - BorderSize border_size() const override; + /** Static function to check if given info will lead to a valid configuration of @ref CLDirectConvolutionLayerKernel + * + * @param[in] input The input tensor to convolve. 3 lower dimensions represent a single input [width, height, IFM], + * while every optional dimension from 4 and above represent a batch of inputs. Data types supported: QS8/QASYMM8/QS16/F16/F32. + * @param[in] weights Weights tensor. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. + * The 3rd dimension must be the same as the input's volume 3rd dimension. + * Data type supported:Same as @p input. + * @param[in] biases Biases tensor. Biases are 1D tensor with dimension [OFM]. Data type supported: Same as @p input. + * @param[in] output Output tensor. + * The 3rd dimensions must be equal to the 4th dimension of the @p kernels tensor. Data types supported: Same as @p input. + * @param[in] conv_info Contains padding and stride information described in @ref PadStrideInfo. + * + * @return an error status + */ + static Error validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info); // Inherited methods overridden: void run(const Window &window, cl::CommandQueue &queue) override; + BorderSize border_size() const override; private: const ICLTensor *_input; diff --git a/arm_compute/core/CL/kernels/CLNormalizationLayerKernel.h b/arm_compute/core/CL/kernels/CLNormalizationLayerKernel.h index f74f7514ee..38daac69b1 100644 --- a/arm_compute/core/CL/kernels/CLNormalizationLayerKernel.h +++ b/arm_compute/core/CL/kernels/CLNormalizationLayerKernel.h @@ -45,7 +45,6 @@ public: CLNormalizationLayerKernel(CLNormalizationLayerKernel &&) = default; /** Default move assignment operator. */ CLNormalizationLayerKernel &operator=(CLNormalizationLayerKernel &&) = default; - /** Set the input and output tensors. * * @param[in] input Source tensor. 3 lower dims represent a single input with dimensions [width, height, IFM], @@ -54,6 +53,16 @@ public: * @param[in] norm_info Normalization layer information like the normalization type, normalization size and other parameters. */ void configure(const ICLTensor *input, ICLTensor *output, NormalizationLayerInfo norm_info); + /** Static function to check if given info will lead to a valid configuration of @ref CLNormalizationLayerKernel + * + * @param[in] input Source tensor. 3 lower dims represent a single input with dimensions [width, height, IFM], + * and an optional 4th dimension for batch of inputs. Data types supported: QS8/QS16/F16/F32. + * @param[in] output Destination tensor. Output will have the same number of dimensions as input. Data types supported: same as @p input. + * @param[in] norm_info Normalization layer information like the normalization type, normalization size and other parameters. + * + * @return an error status + */ + static Error validate(const ITensorInfo *input, const ITensorInfo *output, NormalizationLayerInfo norm_info); // Inherited methods overridden: void run(const Window &window, cl::CommandQueue &queue) override; diff --git a/arm_compute/core/CL/kernels/CLSoftmaxLayerKernel.h b/arm_compute/core/CL/kernels/CLSoftmaxLayerKernel.h index ab550aa52a..b0adb67578 100644 --- a/arm_compute/core/CL/kernels/CLSoftmaxLayerKernel.h +++ b/arm_compute/core/CL/kernels/CLSoftmaxLayerKernel.h @@ -42,6 +42,14 @@ public: * @param[out] output Destination tensor. Data types supported: same as @p input */ void configure(const ICLTensor *input, ICLTensor *output); + /** Static function to check if given info will lead to a valid configuration of @ref CLLogits1DMaxKernel + * + * @param[in] input Source tensor. Data types supported: QS8/QASYMM8/QS16/F16/F32 + * @param[in] output Destination tensor. Data types supported: same as @p input + * + * @return an error status + */ + static Error validate(const ITensorInfo *input, const ITensorInfo *output); }; /** Interface for shifting, exponentiating and summing the logits */ @@ -67,6 +75,16 @@ public: * @param[in] beta (Optional) A scaling factor for the exponent. Defaults to 1.0 */ void configure(const ICLTensor *input, const ICLTensor *max, ICLTensor *output, ICLTensor *sum, float beta = 1.0f); + /** Static function to check if given info will lead to a valid configuration of @ref CLLogits1DShiftExpSumKernel + * + * @param[in] input Source tensor. Data types supported: QS8/QASYMM8/QS16/F16/F32 + * @param[in] max Max values tensor. Data types supported: same as @p input + * @param[in] output Destination tensor. Data types supported: S32 for QASYMM8 @p input, or same as @p input + * @param[in] sum Sum of 1D logits tensor. Data types supported: S32 for QASYMM8 @p input, or same as @p input + * + * @return an error status + */ + static Error validate(const ITensorInfo *input, const ITensorInfo *max, const ITensorInfo *output, const ITensorInfo *sum); // Inherited methods overridden: void run(const Window &window, cl::CommandQueue &queue) override; @@ -104,6 +122,16 @@ public: * @param[in] beta (Optional) A scaling factor for the exponent. Defaults to 1.f */ void configure(const ICLTensor *input, ICLTensor *max, ICLTensor *output, ICLTensor *sum, float beta = 1.0f); + /** Static function to check if given info will lead to a valid configuration of @ref CLLogits1DMaxShiftExpSumKernel + * + * @param[in] input Source tensor. Data types supported: QS8/QS16/F16/F32 + * @param[in] max Max values tensor. Data types supported: same as @p input + * @param[in] output Destination tensor. Data types supported: same as @p input + * @param[in] sum Sum of 1D logits tensor. Data types supported: same as @p input + * + * @return an error status + */ + static Error validate(const ITensorInfo *input, const ITensorInfo *max, const ITensorInfo *output, const ITensorInfo *sum); /** Checks if the given size is eligible for parallel reduction * * @note Serial reduction is launched for width < (_grid_size * _serial_vector_size). @@ -152,6 +180,15 @@ public: * @param[in] beta (Optional) A scaling factor for the exponent. (Default = 1.0) */ void configure(const ICLTensor *input, const ICLTensor *sum, ICLTensor *output, float beta = 1.0f); + /** Static function to check if given info will lead to a valid configuration of @ref CLLogits1DNormKernel + * + * @param[in] input Source tensor. Data types supported: QS8/QS16/S32/F16/F32 + * @param[in] sum Sum tensor. Dimensions should be dim(input)-1. Data types supported: same as @p input + * @param[in] output Destination tensor. Data types supported: QASYMM8 for S32 @p input, or same as @p input + * + * @return an error status + */ + static Error validate(const ITensorInfo *input, const ITensorInfo *sum, const ITensorInfo *output); // Inherited methods overridden: void run(const Window &window, cl::CommandQueue &queue) override; diff --git a/arm_compute/core/ITensorInfo.h b/arm_compute/core/ITensorInfo.h index 5e8d4e8136..1bc0a80bac 100644 --- a/arm_compute/core/ITensorInfo.h +++ b/arm_compute/core/ITensorInfo.h @@ -96,6 +96,11 @@ public: * @return Reference to this ITensorInfo object */ virtual ITensorInfo &set_quantization_info(QuantizationInfo quantization_info) = 0; + /** Resets the padding settings of the tensor. + * + * @return Reference to this ITensorInfo object + */ + virtual ITensorInfo &reset_padding() = 0; /** Update the offset to the first element and the strides to automatically computed values. * * @note The padding used by this method is really conservative so that the tensor can be used for most functions. diff --git a/arm_compute/core/SubTensorInfo.h b/arm_compute/core/SubTensorInfo.h index 5fec11a2e8..b8a36854dc 100644 --- a/arm_compute/core/SubTensorInfo.h +++ b/arm_compute/core/SubTensorInfo.h @@ -104,6 +104,12 @@ public: _parent->set_quantization_info(quantization_info); return *this; } + ITensorInfo &reset_padding() override + { + ARM_COMPUTE_ERROR_ON(_parent == nullptr); + _parent->reset_padding(); + return *this; + } bool auto_padding() override { ARM_COMPUTE_ERROR_ON(_parent == nullptr); diff --git a/arm_compute/core/TensorInfo.h b/arm_compute/core/TensorInfo.h index 2383f2db21..5fd6c47818 100644 --- a/arm_compute/core/TensorInfo.h +++ b/arm_compute/core/TensorInfo.h @@ -220,7 +220,8 @@ public: ITensorInfo &set_tensor_shape(TensorShape shape) override; ITensorInfo &set_fixed_point_position(int fixed_point_position) override; ITensorInfo &set_quantization_info(QuantizationInfo quantization_info) override; - bool auto_padding() override; + ITensorInfo &reset_padding() override; + bool auto_padding() override; bool extend_padding(const PaddingSize &padding) override; size_t dimension(size_t index) const override { |