aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/reference/DepthwiseConvolutionLayer.cpp
diff options
context:
space:
mode:
authorGiorgio Arena <giorgio.arena@arm.com>2018-03-26 16:20:05 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:49:37 +0000
commit1ed1fc6d3b7d8494ce3bbc5f8b46bfde6fc586f9 (patch)
treedc299cf46073d2bdd5a3a0252935ede216cf332e /tests/validation/reference/DepthwiseConvolutionLayer.cpp
parent9373c8b2650f34b2804d3685588bad8e408ebe63 (diff)
downloadComputeLibrary-1ed1fc6d3b7d8494ce3bbc5f8b46bfde6fc586f9.tar.gz
COMPMID-812 Add NHWC data format support for NEON depthwise convolution (optimized case).
Change-Id: Icdfd6c02ed526daf4f59a4b76c7bbc1bc48fde74 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/125938 Tested-by: Jenkins <bsgcomp@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.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/tests/validation/reference/DepthwiseConvolutionLayer.cpp b/tests/validation/reference/DepthwiseConvolutionLayer.cpp
index b2a7067709..ab61b7dd65 100644
--- a/tests/validation/reference/DepthwiseConvolutionLayer.cpp
+++ b/tests/validation/reference/DepthwiseConvolutionLayer.cpp
@@ -24,6 +24,7 @@
#include "DepthwiseConvolutionLayer.h"
#include "ConvolutionLayer.h"
+#include "Permute.h"
#include "Utils.h"
#include "tests/validation/FixedPoint.h"
@@ -50,11 +51,8 @@ namespace reference
*
*/
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)
+void depthwise_convolution_nchw(const SimpleTensor<T> &src, const SimpleTensor<T> &weights, const SimpleTensor<TB> &biases, SimpleTensor<T> &dst, const PadStrideInfo &conv_info)
{
- // Create reference
- 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();
@@ -108,8 +106,6 @@ SimpleTensor<T> depthwise_convolution(const SimpleTensor<T> &src, const SimpleTe
}
}
}
-
- return dst;
}
template <>
@@ -195,6 +191,27 @@ SimpleTensor<uint8_t> depthwise_convolution(const SimpleTensor<uint8_t> &src, co
return dst;
}
+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)
+{
+ SimpleTensor<T> dst{ dst_shape, src.data_type(), 1, src.fixed_point_position() };
+
+ if(src.data_layout() == DataLayout::NHWC && src.data_type() == DataType::F32)
+ {
+ 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<T, TB>(src_nchw, weights_nchw, biases, dst_nchw, conv_info);
+
+ return reference::permute<T>(dst_nchw, PermutationVector(2U, 0U, 1U));
+ }
+
+ depthwise_convolution_nchw<T, TB>(src, weights, biases, dst, conv_info);
+
+ return dst;
+}
+
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);