From 563494c2f447e201e88e6d7133a41e12971777eb Mon Sep 17 00:00:00 2001 From: Giorgio Arena Date: Mon, 30 Apr 2018 17:29:41 +0100 Subject: COMPMID-1084 Rework the way validation is performed for NHWC data layout Change-Id: I00b95f560548da76718298b642c8166f92421097 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/129520 Tested-by: Jenkins Reviewed-by: Michele DiGiorgio Reviewed-by: Anthony Barbier --- .../reference/DepthwiseConvolutionLayer.cpp | 39 ++++++---------------- 1 file changed, 11 insertions(+), 28 deletions(-) (limited to 'tests/validation/reference/DepthwiseConvolutionLayer.cpp') diff --git a/tests/validation/reference/DepthwiseConvolutionLayer.cpp b/tests/validation/reference/DepthwiseConvolutionLayer.cpp index 207e5fc45c..10c617e953 100644 --- a/tests/validation/reference/DepthwiseConvolutionLayer.cpp +++ b/tests/validation/reference/DepthwiseConvolutionLayer.cpp @@ -24,7 +24,6 @@ #include "DepthwiseConvolutionLayer.h" #include "ConvolutionLayer.h" -#include "Permute.h" #include "Utils.h" #include "tests/validation/FixedPoint.h" @@ -51,9 +50,11 @@ namespace reference * */ template -void depthwise_convolution_nchw(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &biases, SimpleTensor &dst, const PadStrideInfo &conv_info, - unsigned int depth_multiplier) +SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &conv_info, + unsigned int depth_multiplier) { + SimpleTensor dst{ dst_shape, src.data_type(), 1, src.fixed_point_position() }; + // Compute reference const int filter_width = weights.shape().x(); const int filter_height = weights.shape().y(); @@ -113,11 +114,16 @@ void depthwise_convolution_nchw(const SimpleTensor &src, const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &biases, SimpleTensor &dst, const PadStrideInfo &conv_info, - unsigned int depth_multiplier) +template <> +SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &biases, const TensorShape &dst_shape, + const PadStrideInfo &conv_info, unsigned int depth_multiplier) { + SimpleTensor dst{ dst_shape, src.data_type(), 1, src.fixed_point_position(), src.quantization_info() }; + // Create reference const int input_offset = -src.quantization_info().offset; const float input_scale = src.quantization_info().scale; @@ -196,33 +202,10 @@ void depthwise_convolution_nchw(const SimpleTensor &src, const SimpleTe } } } -} - -template -SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &conv_info, - unsigned int depth_multiplier) -{ - SimpleTensor dst{ dst_shape, src.data_type(), 1, src.fixed_point_position(), src.quantization_info() }; - - if(src.data_layout() == DataLayout::NHWC) - { - SimpleTensor src_nchw = reference::permute(src, PermutationVector(1U, 2U, 0U)); - SimpleTensor weights_nchw = reference::permute(weights, PermutationVector(1U, 2U, 0U)); - SimpleTensor dst_nchw = reference::permute(dst, PermutationVector(1U, 2U, 0U)); - - depthwise_convolution_nchw(src_nchw, weights_nchw, biases, dst_nchw, conv_info, depth_multiplier); - - return reference::permute(dst_nchw, PermutationVector(2U, 0U, 1U)); - } - - depthwise_convolution_nchw(src, weights, biases, dst, conv_info, depth_multiplier); return dst; } -template SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &biases, const TensorShape &dst_shape, - const PadStrideInfo &conv_info, unsigned int depth_multiplier); - template SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &conv_info, unsigned int depth_multiplier); -- cgit v1.2.1