From 81a26ad6b626ce2da83659d7c6c17b6104d1f203 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Mon, 23 Oct 2017 20:29:30 +0100 Subject: COMPMID-643: Add bias to CLDepthwiseConvolution. Change-Id: Ibfe7b8c1172d10cbcae7971fe86b82090519d31d Reviewed-on: http://mpd-gerrit.cambridge.arm.com/92798 Tested-by: Kaizen Reviewed-by: Jaroslaw Rzepecki Reviewed-by: Anthony Barbier --- src/runtime/CL/functions/CLDepthwiseConvolution.cpp | 14 ++++++++------ .../CL/functions/CLDepthwiseSeparableConvolutionLayer.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/CL/functions/CLDepthwiseConvolution.cpp b/src/runtime/CL/functions/CLDepthwiseConvolution.cpp index 22c037fc2a..ffd9f40f4f 100644 --- a/src/runtime/CL/functions/CLDepthwiseConvolution.cpp +++ b/src/runtime/CL/functions/CLDepthwiseConvolution.cpp @@ -35,13 +35,13 @@ CLDepthwiseConvolution3x3::CLDepthwiseConvolution3x3() { } -void CLDepthwiseConvolution3x3::configure(ICLTensor *input, ICLTensor *output, const ICLTensor *weights, const PadStrideInfo &conv_info) +void CLDepthwiseConvolution3x3::configure(ICLTensor *input, ICLTensor *output, const ICLTensor *weights, const ICLTensor *biases, const PadStrideInfo &conv_info) { ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F32); ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::F32); ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, weights); - _kernel.configure(input, output, weights, conv_info); + _kernel.configure(input, output, weights, biases, conv_info); _border_handler.configure(input, _kernel.border_size(), BorderMode::CONSTANT, PixelValue(0)); } @@ -57,7 +57,7 @@ CLDepthwiseConvolution::CLDepthwiseConvolution() { } -void CLDepthwiseConvolution::configure(ICLTensor *input, ICLTensor *output, const ICLTensor *weights, const PadStrideInfo &conv_info) +void CLDepthwiseConvolution::configure(ICLTensor *input, ICLTensor *output, const ICLTensor *weights, const ICLTensor *biases, const PadStrideInfo &conv_info) { ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F32); ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::F32); @@ -68,12 +68,14 @@ void CLDepthwiseConvolution::configure(ICLTensor *input, ICLTensor *output, cons const size_t weights_h = weights->info()->dimension(1); const size_t weights_z = weights->info()->dimension(2); + bool has_bias = (biases != nullptr); + unsigned int conv_w = 0; unsigned int conv_h = 0; std::tie(conv_w, conv_h) = scaled_dimensions(input->info()->dimension(0), input->info()->dimension(1), weights_w, weights_h, conv_info); // Set up intermediate tensors - const size_t patch_size = weights_w * weights_h; + const size_t patch_size = weights_w * weights_h + ((has_bias) ? 1 : 0); const size_t conv_size = conv_w * conv_h; TensorShape shape_im2col = input->info()->tensor_shape(); @@ -96,8 +98,8 @@ void CLDepthwiseConvolution::configure(ICLTensor *input, ICLTensor *output, cons _v2mm_output.allocator()->init(info_v2mm_out); // Configure kernels - _im2col_kernel.configure(input, &_input_reshaped, Size2D(weights_w, weights_h), conv_info); - _weights_reshape_kernel.configure(weights, &_weights_reshaped); + _im2col_kernel.configure(input, &_input_reshaped, Size2D(weights_w, weights_h), conv_info, has_bias); + _weights_reshape_kernel.configure(weights, &_weights_reshaped, biases); _v2mm_kernel.configure(&_input_reshaped, &_weights_reshaped, &_v2mm_output); _vector_to_tensor_kernel.configure(&_v2mm_output, output, conv_w, conv_h); diff --git a/src/runtime/CL/functions/CLDepthwiseSeparableConvolutionLayer.cpp b/src/runtime/CL/functions/CLDepthwiseSeparableConvolutionLayer.cpp index c325b3e01f..14ab808dbf 100644 --- a/src/runtime/CL/functions/CLDepthwiseSeparableConvolutionLayer.cpp +++ b/src/runtime/CL/functions/CLDepthwiseSeparableConvolutionLayer.cpp @@ -35,12 +35,12 @@ CLDepthwiseSeparableConvolutionLayer::CLDepthwiseSeparableConvolutionLayer() { } -void CLDepthwiseSeparableConvolutionLayer::configure(ICLTensor *input, const ICLTensor *depthwise_weights, ICLTensor *depthwise_out, const ICLTensor *pointwise_weights, const ICLTensor *biases, - ICLTensor *output, +void CLDepthwiseSeparableConvolutionLayer::configure(ICLTensor *input, const ICLTensor *depthwise_weights, const ICLTensor *depthwise_biases, ICLTensor *depthwise_out, + const ICLTensor *pointwise_weights, const ICLTensor *pointwise_biases, ICLTensor *output, const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info) { - _depthwise_conv.configure(input, depthwise_out, depthwise_weights, depthwise_conv_info); - _pointwise_conv.configure(depthwise_out, pointwise_weights, biases, output, pointwise_conv_info); + _depthwise_conv.configure(input, depthwise_out, depthwise_weights, depthwise_biases, depthwise_conv_info); + _pointwise_conv.configure(depthwise_out, pointwise_weights, pointwise_biases, output, pointwise_conv_info); } void CLDepthwiseSeparableConvolutionLayer::run() -- cgit v1.2.1