From 215b4ea6c9dee480a22070d5873b0b8cb52531a0 Mon Sep 17 00:00:00 2001 From: Gian Marco Iodice Date: Thu, 28 Jun 2018 16:29:29 +0100 Subject: COMPMID-1277 - Optimizing CLIm2ColKernel for NHWC. This patch includes: - Im2Col optimizations for NHWC using a new data layout - Refactoring of CLIm2ColKernel adding validation method and auto-init - Removed im2col_reduced from CLIm2ColKernel and created a new kernel CLFlattenLayerKernel Change-Id: I1620640b6796baa268324b33ae92cdd8de53e27c Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/141241 Tested-by: Jenkins Reviewed-by: Giorgio Arena --- tests/validation/fixtures/FlattenLayerFixture.h | 2 +- tests/validation/fixtures/Im2ColFixture.h | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'tests/validation/fixtures') diff --git a/tests/validation/fixtures/FlattenLayerFixture.h b/tests/validation/fixtures/FlattenLayerFixture.h index f273e9315c..d17080695b 100644 --- a/tests/validation/fixtures/FlattenLayerFixture.h +++ b/tests/validation/fixtures/FlattenLayerFixture.h @@ -55,7 +55,7 @@ public: { TensorShape shape_flatten; TensorInfo input_info(shape, 1, data_type); - shape_flatten = compute_im2col_flatten_shape(&input_info); + shape_flatten = compute_flatten_shape(&input_info); _target = compute_target(shape, shape_flatten, data_type); _reference = compute_reference(shape, shape_flatten, data_type); diff --git a/tests/validation/fixtures/Im2ColFixture.h b/tests/validation/fixtures/Im2ColFixture.h index f72e38fefc..da2576b37c 100644 --- a/tests/validation/fixtures/Im2ColFixture.h +++ b/tests/validation/fixtures/Im2ColFixture.h @@ -49,7 +49,8 @@ class Im2ColValidationFixture : public framework::Fixture { public: template - void setup(TensorShape input_shape, DataType data_type, const Size2D &kernel_dims, const PadStrideInfo &conv_info, const QuantizationInfo &quant_info, const DataLayout &data_layout) + void setup(TensorShape input_shape, DataType data_type, const Size2D &kernel_dims, const PadStrideInfo &conv_info, const QuantizationInfo &quant_info, const DataLayout &data_layout, + bool channels_first_output_nhwc) { _kernel_dims = kernel_dims; _conv_info = conv_info; @@ -68,7 +69,7 @@ public: const TensorShape output_shape = compute_im2col_conv_shape(&input_info, _kernel_dims, _conv_info, _has_bias, Size2D(1U, 1U), batch_size_on_z); _target = compute_target(input_shape, output_shape, data_type); - compute_reference(input_shape, output_shape, data_type); + compute_reference(input_shape, output_shape, data_type, channels_first_output_nhwc); } protected: @@ -107,14 +108,16 @@ protected: return dst; } - void compute_reference(const TensorShape &input_shape, const TensorShape &output_shape, DataType data_type) + void compute_reference(const TensorShape &input_shape, const TensorShape &output_shape, DataType data_type, bool channels_first_output_nhwc) { // Create reference SimpleTensor src{ input_shape, data_type, 1, _quant_info, _data_layout }; _reference = SimpleTensor(output_shape, data_type, 1, _quant_info, DataLayout::NCHW); + // Fill reference fill(src); - reference::im2col(src, _reference, _kernel_dims, _conv_info, _has_bias); + + reference::im2col(src, _reference, _kernel_dims, _conv_info, _has_bias, channels_first_output_nhwc); } TensorType _target{}; SimpleTensor _reference{}; -- cgit v1.2.1