aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/reference/DepthwiseConvolutionLayer.cpp
diff options
context:
space:
mode:
authorGiorgio Arena <giorgio.arena@arm.com>2018-04-30 17:29:41 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:51:17 +0000
commit563494c2f447e201e88e6d7133a41e12971777eb (patch)
tree716ae5e4978ce378ad14f53591087a7a42f6fe58 /tests/validation/reference/DepthwiseConvolutionLayer.cpp
parentb7f5d172ccdb1d884388dd6e0e54f74241afca67 (diff)
downloadComputeLibrary-563494c2f447e201e88e6d7133a41e12971777eb.tar.gz
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 <bsgcomp@arm.com> Reviewed-by: Michele DiGiorgio <michele.digiorgio@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'tests/validation/reference/DepthwiseConvolutionLayer.cpp')
-rw-r--r--tests/validation/reference/DepthwiseConvolutionLayer.cpp39
1 files changed, 11 insertions, 28 deletions
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 <typename T, typename TB>
-void depthwise_convolution_nchw(const SimpleTensor<T> &src, const SimpleTensor<T> &weights, const SimpleTensor<TB> &biases, SimpleTensor<T> &dst, const PadStrideInfo &conv_info,
- unsigned int depth_multiplier)
+SimpleTensor<T> depthwise_convolution(const SimpleTensor<T> &src, const SimpleTensor<T> &weights, const SimpleTensor<TB> &biases, const TensorShape &dst_shape, const PadStrideInfo &conv_info,
+ unsigned int depth_multiplier)
{
+ SimpleTensor<T> 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<T> &src, const SimpleTensor<T
}
}
}
+
+ return dst;
}
-void depthwise_convolution_nchw(const SimpleTensor<uint8_t> &src, const SimpleTensor<uint8_t> &weights, const SimpleTensor<int32_t> &biases, SimpleTensor<uint8_t> &dst, const PadStrideInfo &conv_info,
- unsigned int depth_multiplier)
+template <>
+SimpleTensor<uint8_t> depthwise_convolution(const SimpleTensor<uint8_t> &src, const SimpleTensor<uint8_t> &weights, const SimpleTensor<int32_t> &biases, const TensorShape &dst_shape,
+ const PadStrideInfo &conv_info, unsigned int depth_multiplier)
{
+ SimpleTensor<uint8_t> 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<uint8_t> &src, const SimpleTe
}
}
}
-}
-
-template <typename T, typename TB>
-SimpleTensor<T> depthwise_convolution(const SimpleTensor<T> &src, const SimpleTensor<T> &weights, const SimpleTensor<TB> &biases, const TensorShape &dst_shape, const PadStrideInfo &conv_info,
- unsigned int depth_multiplier)
-{
- SimpleTensor<T> dst{ dst_shape, src.data_type(), 1, src.fixed_point_position(), src.quantization_info() };
-
- if(src.data_layout() == DataLayout::NHWC)
- {
- SimpleTensor<T> src_nchw = reference::permute<T>(src, PermutationVector(1U, 2U, 0U));
- SimpleTensor<T> weights_nchw = reference::permute<T>(weights, PermutationVector(1U, 2U, 0U));
- SimpleTensor<T> dst_nchw = reference::permute<T>(dst, PermutationVector(1U, 2U, 0U));
-
- depthwise_convolution_nchw(src_nchw, weights_nchw, biases, dst_nchw, conv_info, depth_multiplier);
-
- return reference::permute<T>(dst_nchw, PermutationVector(2U, 0U, 1U));
- }
-
- depthwise_convolution_nchw(src, weights, biases, dst, conv_info, depth_multiplier);
return dst;
}
-template SimpleTensor<uint8_t> depthwise_convolution(const SimpleTensor<uint8_t> &src, const SimpleTensor<uint8_t> &weights, const SimpleTensor<int32_t> &biases, const TensorShape &dst_shape,
- const PadStrideInfo &conv_info, unsigned int depth_multiplier);
-
template SimpleTensor<float> depthwise_convolution(const SimpleTensor<float> &src, const SimpleTensor<float> &weights, const SimpleTensor<float> &biases, const TensorShape &dst_shape,
const PadStrideInfo &conv_info, unsigned int depth_multiplier);