aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2017-10-27 12:01:23 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:35:24 +0000
commit5cbd20f10f1a51dc177c4e9e7c0be01261870260 (patch)
tree4df16a37d88d5fa3434c64a7e8a788eeb431dfe1
parent1f378ee7639837601f5152ee9f185ee1a528d643 (diff)
downloadComputeLibrary-5cbd20f10f1a51dc177c4e9e7c0be01261870260.tar.gz
COMPMID-556: Autoconfigure support in CLDepthwiseConvolution.
Change-Id: I697d3237b39d0f088b820c14b65cfcbbd2e26e09 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/93412 Reviewed-by: Anthony Barbier <anthony.barbier@arm.com> Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
-rw-r--r--src/core/CL/kernels/CLDepthwiseVectorToTensorKernel.cpp11
-rw-r--r--src/runtime/CL/functions/CLDepthwiseConvolution.cpp23
-rw-r--r--tests/datasets/MobileNetDepthwiseConvolutionDataset.h10
-rw-r--r--tests/datasets/MobileNetDepthwiseSeparableConvolutionLayerDataset.h5
4 files changed, 28 insertions, 21 deletions
diff --git a/src/core/CL/kernels/CLDepthwiseVectorToTensorKernel.cpp b/src/core/CL/kernels/CLDepthwiseVectorToTensorKernel.cpp
index 2086b1de03..dc47bb0adc 100644
--- a/src/core/CL/kernels/CLDepthwiseVectorToTensorKernel.cpp
+++ b/src/core/CL/kernels/CLDepthwiseVectorToTensorKernel.cpp
@@ -42,6 +42,17 @@ CLDepthwiseVectorToTensorKernel::CLDepthwiseVectorToTensorKernel()
void CLDepthwiseVectorToTensorKernel::configure(const ICLTensor *input, ICLTensor *output, size_t conv_w, size_t conv_h)
{
ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32);
+ ARM_COMPUTE_ERROR_ON_NULLPTR(output);
+
+ TensorShape output_shape = input->info()->tensor_shape();
+ output_shape.set(0, conv_w);
+ output_shape.set(1, conv_h);
+ output_shape.set(2, input->info()->tensor_shape()[0] / (conv_w * conv_h));
+
+ // Output auto inizialitation if not yet initialized
+ auto_init_if_empty(*output->info(), output_shape, 1, input->info()->data_type(), input->info()->fixed_point_position());
+
+ ARM_COMPUTE_ERROR_ON_MISMATCHING_DIMENSIONS(output->info()->tensor_shape(), output_shape);
ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
ARM_COMPUTE_ERROR_ON_MISMATCHING_FIXED_POINT(input, output);
diff --git a/src/runtime/CL/functions/CLDepthwiseConvolution.cpp b/src/runtime/CL/functions/CLDepthwiseConvolution.cpp
index ffd9f40f4f..bfc792c942 100644
--- a/src/runtime/CL/functions/CLDepthwiseConvolution.cpp
+++ b/src/runtime/CL/functions/CLDepthwiseConvolution.cpp
@@ -60,7 +60,6 @@ CLDepthwiseConvolution::CLDepthwiseConvolution()
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);
ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, weights);
ARM_COMPUTE_ERROR_ON(input->info()->dimension(2) != weights->info()->dimension(2));
@@ -78,28 +77,28 @@ void CLDepthwiseConvolution::configure(ICLTensor *input, ICLTensor *output, cons
const size_t patch_size = weights_w * weights_h + ((has_bias) ? 1 : 0);
const size_t conv_size = conv_w * conv_h;
+ // Im2Col configuration
TensorShape shape_im2col = input->info()->tensor_shape();
shape_im2col.set(0, patch_size);
shape_im2col.set(1, conv_size);
shape_im2col.set(2, weights_z);
+ const TensorInfo info_im2col(shape_im2col, 1, input->info()->data_type(), input->info()->fixed_point_position());
+ _input_reshaped.allocator()->init(info_im2col);
+ _im2col_kernel.configure(input, &_input_reshaped, Size2D(weights_w, weights_h), conv_info, has_bias);
+ // Weights reshape configuration
const TensorShape shape_weights_reshape(patch_size, weights_z);
- TensorShape shape_v2mm_out = output->info()->tensor_shape();
+ const TensorInfo info_weights_reshape(shape_weights_reshape, 1, weights->info()->data_type(), weights->info()->fixed_point_position());
+ _weights_reshaped.allocator()->init(info_weights_reshape);
+ _weights_reshape_kernel.configure(weights, &_weights_reshaped, biases);
+
+ // GEMV configuration
+ TensorShape shape_v2mm_out = input->info()->tensor_shape();
shape_v2mm_out.set(0, conv_size * weights_z);
shape_v2mm_out.set(1, 1);
shape_v2mm_out.set(2, 1);
-
- const TensorInfo info_im2col(shape_im2col, 1, input->info()->data_type(), input->info()->fixed_point_position());
- const TensorInfo info_weights_reshape(shape_weights_reshape, 1, weights->info()->data_type(), weights->info()->fixed_point_position());
const TensorInfo info_v2mm_out(shape_v2mm_out, 1, input->info()->data_type(), input->info()->fixed_point_position());
-
- _input_reshaped.allocator()->init(info_im2col);
- _weights_reshaped.allocator()->init(info_weights_reshape);
_v2mm_output.allocator()->init(info_v2mm_out);
-
- // Configure kernels
- _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/tests/datasets/MobileNetDepthwiseConvolutionDataset.h b/tests/datasets/MobileNetDepthwiseConvolutionDataset.h
index c2690d9ad6..918815f41e 100644
--- a/tests/datasets/MobileNetDepthwiseConvolutionDataset.h
+++ b/tests/datasets/MobileNetDepthwiseConvolutionDataset.h
@@ -42,13 +42,13 @@ class MobileNetDepthwiseConvolutionDataset final : public DepthwiseConvolutionDa
public:
MobileNetDepthwiseConvolutionDataset()
{
- add_config(TensorShape(7U, 7U, 1024U), TensorShape(3U, 3U, 1024U), TensorShape(1024U), TensorShape(3U, 3U, 1024U), PadStrideInfo(2, 2, 1, 1));
- add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U), TensorShape(512U), TensorShape(7U, 7U, 512U), PadStrideInfo(2, 2, 1, 1));
- add_config(TensorShape(28U, 28U, 256U), TensorShape(3U, 3U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(2, 2, 1, 1));
+ add_config(TensorShape(7U, 7U, 1024U), TensorShape(3U, 3U, 1024U), TensorShape(1024U), TensorShape(3U, 3U, 1024U), PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::FLOOR));
+ add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U), TensorShape(512U), TensorShape(7U, 7U, 512U), PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::FLOOR));
+ add_config(TensorShape(28U, 28U, 256U), TensorShape(3U, 3U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::FLOOR));
add_config(TensorShape(28U, 28U, 256U), TensorShape(3U, 3U, 256U), TensorShape(256U), TensorShape(28U, 28U, 256U), PadStrideInfo(1, 1, 1, 1));
- add_config(TensorShape(56U, 56U, 128U), TensorShape(3U, 3U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(2, 2, 1, 1));
+ add_config(TensorShape(56U, 56U, 128U), TensorShape(3U, 3U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::FLOOR));
add_config(TensorShape(56U, 56U, 128U), TensorShape(3U, 3U, 128U), TensorShape(128U), TensorShape(56U, 56U, 128U), PadStrideInfo(1, 1, 1, 1));
- add_config(TensorShape(112U, 112U, 64U), TensorShape(3U, 3U, 64U), TensorShape(64U), TensorShape(56U, 56U, 64U), PadStrideInfo(2, 2, 1, 1));
+ add_config(TensorShape(112U, 112U, 64U), TensorShape(3U, 3U, 64U), TensorShape(64U), TensorShape(56U, 56U, 64U), PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::FLOOR));
add_config(TensorShape(112U, 112U, 32U), TensorShape(3U, 3U, 32U), TensorShape(32U), TensorShape(112U, 112U, 32U), PadStrideInfo(1, 1, 1, 1));
}
};
diff --git a/tests/datasets/MobileNetDepthwiseSeparableConvolutionLayerDataset.h b/tests/datasets/MobileNetDepthwiseSeparableConvolutionLayerDataset.h
index d0f602daf0..eef0000925 100644
--- a/tests/datasets/MobileNetDepthwiseSeparableConvolutionLayerDataset.h
+++ b/tests/datasets/MobileNetDepthwiseSeparableConvolutionLayerDataset.h
@@ -43,10 +43,7 @@ public:
MobileNetDepthwiseSeparableConvolutionLayerDataset()
{
add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U),
- PadStrideInfo(1, 1, 1,
- 1,
- DimensionRoundingType::FLOOR),
- PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::FLOOR));
+ PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::FLOOR), PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::FLOOR));
}
};
} // namespace datasets