From 2732cca12bac29e1515cee1db5005c73893c61b4 Mon Sep 17 00:00:00 2001 From: Manuel Bottini Date: Tue, 28 May 2019 11:44:41 +0100 Subject: COMPMID-2244: Extend CLFuseBatchNormalization to support DepthwiseConvolution weights Change-Id: I7d1907f35cc4899379073759be2f7cce24e51e9d Signed-off-by: Manuel Bottini Reviewed-on: https://review.mlplatform.org/c/1327 Reviewed-by: Gian Marco Iodice Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- .../CL/kernels/CLFuseBatchNormalizationKernel.h | 76 +++++++++++----------- 1 file changed, 39 insertions(+), 37 deletions(-) (limited to 'arm_compute/core/CL') diff --git a/arm_compute/core/CL/kernels/CLFuseBatchNormalizationKernel.h b/arm_compute/core/CL/kernels/CLFuseBatchNormalizationKernel.h index a5b98bb27d..d2df0897d4 100644 --- a/arm_compute/core/CL/kernels/CLFuseBatchNormalizationKernel.h +++ b/arm_compute/core/CL/kernels/CLFuseBatchNormalizationKernel.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -49,57 +49,59 @@ public: ~CLFuseBatchNormalizationKernel() = default; /** Set the source, destination of the kernel * - * @param[in] conv_weights Convolution layer weights tensor. Data type supported: F16/F32 - * @param[in] bn_mean Batch normalization layer mean tensor. Same as @p conv_weights - * @param[in] bn_var Batch normalization layer variance tensor. Same as @p conv_weights - * @param[out] fused_weights Output fused weights tensor. It can be a nullptr in case of in-place computation. Same as @p conv_weights - * @param[out] fused_bias Output fused bias tensor. It can be a nullptr in case of in-place computation and conv_bias != nullptr. Same as @p conv_weights - * @param[in] conv_bias (Optional) Convolution layer bias tensor. It can be a nullptr in case the bias tensor is not required. Same as @p conv_weights - * @param[in] bn_beta (Optional) Batch normalization layer beta tensor. It can be a nullptr in case the beta tensor is not required. Same as @p conv_weights + * @param[in] input_weights Input weights tensor for convolution or depthwise convolution layer. Data type supported: F16/F32. Data layout supported: NCHW, NHWC + * @param[in] bn_mean Batch normalization layer mean tensor. Same as @p input_weights + * @param[in] bn_var Batch normalization layer variance tensor. Same as @p input_weights + * @param[out] fused_weights Output fused weights tensor. It can be a nullptr in case of in-place computation. Same as @p input_weights + * @param[out] fused_bias Output fused bias tensor. It can be a nullptr in case of in-place computation and input_bias != nullptr. Same as @p input_weights + * @param[in] input_bias (Optional) Input bias tensor for convolution or depthwise convolution layer. It can be a nullptr in case the bias tensor is not required. Same as @p input_weights + * @param[in] bn_beta (Optional) Batch normalization layer beta tensor. It can be a nullptr in case the beta tensor is not required. Same as @p input_weights * @note if nullptr, bn_beta is set to 0.0 - * @param[in] bn_gamma (Optional) Batch normalization layer gamma tensor. It can be a nullptr in case the gamma tensor is not required. Same as @p conv_weights + * @param[in] bn_gamma (Optional) Batch normalization layer gamma tensor. It can be a nullptr in case the gamma tensor is not required. Same as @p input_weights * @note if nullptr, bn_gamma is set to 1.0 * @param[in] epsilon (Optional) Batch normalization layer epsilon parameter. Defaults to 0.001f. + * @param[in] fbn_type (Optional) Fused batch normalization type. Defaults to CONVOLUTION. */ - void configure(const ICLTensor *conv_weights, const ICLTensor *bn_mean, const ICLTensor *bn_var, ICLTensor *fused_weights, ICLTensor *fused_bias, - const ICLTensor *conv_bias = nullptr, const ICLTensor *bn_beta = nullptr, const ICLTensor *bn_gamma = nullptr, - float epsilon = 0.001f); + void configure(const ICLTensor *input_weights, const ICLTensor *bn_mean, const ICLTensor *bn_var, ICLTensor *fused_weights, ICLTensor *fused_bias, + const ICLTensor *input_bias = nullptr, const ICLTensor *bn_beta = nullptr, const ICLTensor *bn_gamma = nullptr, + float epsilon = 0.001f, FuseBatchNormalizationType fbn_type = FuseBatchNormalizationType::CONVOLUTION); /** Static function to check if given info will lead to a valid configuration of @ref CLFuseBatchNormalizationKernel * - * @param[in] conv_weights Convolution layer weights tensor info. Data type supported: F16/F32 - * @param[in] bn_mean Batch normalization layer mean tensor info. Same as @p conv_weights - * @param[in] bn_var Batch normalization layer variance tensor info. Same as @p conv_weights - * @param[out] fused_weights Output fused weights tensor info. It can be a nullptr in case of in-place computation. Same as @p conv_weights - * @param[out] fused_bias Output fused bias tensor info. It can be a nullptr in case of in-place computation and conv_bias != nullptr. Same as @p conv_weights - * @param[in] conv_bias (Optional) Convolution layer bias tensor info. It can be a nullptr in case the bias tensor is not required. Same as @p conv_weights - * @param[in] bn_beta (Optional) Batch normalization layer beta tensor info. It can be a nullptr in case the beta tensor is not required. Same as @p conv_weights - * @note if nullptr, bn_beta is set to 0.0 - * @param[in] bn_gamma (Optional) Batch normalization layer gamma tensor info. It can be a nullptr in case the gamma tensor is not required. Same as @p conv_weights - * @note if nullptr, bn_gamma is set to 1.0 - * @param[in] epsilon (Optional) Batch normalization layer epsilon parameter. Defaults to 0.001f. + * @param[in] input_weights Input weights tensor info for convolution or depthwise convolution layer. Data type supported: F16/F32. Data layout supported: NCHW, NHWC + * @param[in] bn_mean Batch normalization layer mean tensor info. Same as @p input_weights + * @param[in] bn_var Batch normalization layer variance tensor info. Same as @p input_weights + * @param[in] fused_weights Output fused weights tensor info. It can be a nullptr in case of in-place computation. Same as @p input_weights + * @param[in] fused_bias Output fused bias tensor info. It can be a nullptr in case of in-place computation and input_bias != nullptr. Same as @p input_weights + * @param[in] input_bias (Optional) Input bias tensor info for convolution or depthwise convolution layer. It can be a nullptr in case the bias tensor is not required. Same as @p input_weights + * @param[in] bn_beta (Optional) Batch normalization layer beta tensor info. It can be a nullptr in case the beta tensor is not required. Same as @p input_weights + * @note if nullptr, bn_beta is set to 0.0 + * @param[in] bn_gamma (Optional) Batch normalization layer gamma tensor info. It can be a nullptr in case the gamma tensor is not required. Same as @p input_weights + * @note if nullptr, bn_gamma is set to 1.0 + * @param[in] epsilon (Optional) Batch normalization layer epsilon parameter. Defaults to 0.001f. + * @param[in] fbn_type (Optional) Fused batch normalization type. Defaults to CONVOLUTION. * * @return a status */ - static Status validate(const ITensorInfo *conv_weights, const ITensorInfo *bn_mean, const ITensorInfo *bn_var, + static Status validate(const ITensorInfo *input_weights, const ITensorInfo *bn_mean, const ITensorInfo *bn_var, const ITensorInfo *fused_weights, const ITensorInfo *fused_bias, - const ITensorInfo *conv_bias = nullptr, const ITensorInfo *bn_beta = nullptr, const ITensorInfo *bn_gamma = nullptr, - float epsilon = 0.001f); + const ITensorInfo *input_bias = nullptr, const ITensorInfo *bn_beta = nullptr, const ITensorInfo *bn_gamma = nullptr, + float epsilon = 0.001f, FuseBatchNormalizationType fbn_type = FuseBatchNormalizationType::CONVOLUTION); // Inherited methods overridden: void run(const Window &window, cl::CommandQueue &queue) override; private: - const ICLTensor *_conv_weights; - const ICLTensor *_conv_bias; - const ICLTensor *_bn_mean; - const ICLTensor *_bn_var; - const ICLTensor *_bn_gamma; - const ICLTensor *_bn_beta; - ICLTensor *_fused_weights; - ICLTensor *_fused_bias; - float _epsilon; - bool _run_in_place_weights; - bool _run_in_place_bias; + const ICLTensor *_input_weights; + const ICLTensor *_input_bias; + const ICLTensor *_bn_mean; + const ICLTensor *_bn_var; + const ICLTensor *_bn_gamma; + const ICLTensor *_bn_beta; + ICLTensor *_fused_weights; + ICLTensor *_fused_bias; + float _epsilon; + bool _run_in_place_weights; + bool _run_in_place_bias; }; } // namespace arm_compute #endif /*__ARM_COMPUTE_CLFUSEBATCHNORMALIZATIONKERNEL_H__ */ -- cgit v1.2.1