From 81a26ad6b626ce2da83659d7c6c17b6104d1f203 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Mon, 23 Oct 2017 20:29:30 +0100 Subject: COMPMID-643: Add bias to CLDepthwiseConvolution. Change-Id: Ibfe7b8c1172d10cbcae7971fe86b82090519d31d Reviewed-on: http://mpd-gerrit.cambridge.arm.com/92798 Tested-by: Kaizen Reviewed-by: Jaroslaw Rzepecki Reviewed-by: Anthony Barbier --- tests/validation/CPP/DepthwiseConvolution.cpp | 7 ++++--- tests/validation/CPP/DepthwiseConvolution.h | 2 +- .../validation/CPP/DepthwiseSeparableConvolutionLayer.cpp | 15 +++++++++------ tests/validation/CPP/DepthwiseSeparableConvolutionLayer.h | 7 ++++--- 4 files changed, 18 insertions(+), 13 deletions(-) (limited to 'tests/validation/CPP') diff --git a/tests/validation/CPP/DepthwiseConvolution.cpp b/tests/validation/CPP/DepthwiseConvolution.cpp index b57c2686f6..e29d014f77 100644 --- a/tests/validation/CPP/DepthwiseConvolution.cpp +++ b/tests/validation/CPP/DepthwiseConvolution.cpp @@ -45,7 +45,7 @@ namespace reference * */ template -SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const TensorShape &dst_shape, const PadStrideInfo &conv_info) +SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &conv_info) { // Create reference SimpleTensor dst{ dst_shape, src.data_type(), 1, src.fixed_point_position() }; @@ -97,7 +97,7 @@ SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTe } coords.set(0, x); coords.set(1, y); - dst[out_pos++] = saturate_cast(val); + dst[out_pos++] = saturate_cast(val + *static_cast(biases(Coordinates(z)))); } } } @@ -106,7 +106,8 @@ SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTe return dst; } -template SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const TensorShape &dst_shape, const PadStrideInfo &conv_info); +template SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &biases, const TensorShape &dst_shape, + const PadStrideInfo &conv_info); } // namespace reference } // namespace validation } // namespace test diff --git a/tests/validation/CPP/DepthwiseConvolution.h b/tests/validation/CPP/DepthwiseConvolution.h index 6be80fc07f..e8c55b16a8 100644 --- a/tests/validation/CPP/DepthwiseConvolution.h +++ b/tests/validation/CPP/DepthwiseConvolution.h @@ -36,7 +36,7 @@ namespace validation namespace reference { template -SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const TensorShape &dst_shape, const PadStrideInfo &conv_info); +SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &conv_info); } // namespace reference } // namespace validation } // namespace test diff --git a/tests/validation/CPP/DepthwiseSeparableConvolutionLayer.cpp b/tests/validation/CPP/DepthwiseSeparableConvolutionLayer.cpp index 3942ecf02a..8c8e50d349 100644 --- a/tests/validation/CPP/DepthwiseSeparableConvolutionLayer.cpp +++ b/tests/validation/CPP/DepthwiseSeparableConvolutionLayer.cpp @@ -40,19 +40,22 @@ namespace reference { // Depthwise separable convolution layer template -SimpleTensor depthwise_separable_convolution_layer(const SimpleTensor &src, const SimpleTensor &depthwise_weights, const TensorShape &depthwise_out_shape, +SimpleTensor depthwise_separable_convolution_layer(const SimpleTensor &src, const SimpleTensor &depthwise_weights, const SimpleTensor &depthwise_biases, + const TensorShape &depthwise_out_shape, const SimpleTensor &pointwise_weights, - const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info) + const SimpleTensor &pointwise_biases, const TensorShape &dst_shape, const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info) { // Compute reference - SimpleTensor depthwise_out = depthwise_convolution(src, depthwise_weights, depthwise_out_shape, depthwise_conv_info); - SimpleTensor dst = convolution_layer(depthwise_out, pointwise_weights, biases, dst_shape, pointwise_conv_info); + SimpleTensor depthwise_out = depthwise_convolution(src, depthwise_weights, depthwise_biases, depthwise_out_shape, depthwise_conv_info); + SimpleTensor dst = convolution_layer(depthwise_out, pointwise_weights, pointwise_biases, dst_shape, pointwise_conv_info); return dst; } -template SimpleTensor depthwise_separable_convolution_layer(const SimpleTensor &in, const SimpleTensor &depthwise_weights, const TensorShape &depthwise_out_shape, - const SimpleTensor &pointwise_weights, const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info); +template SimpleTensor depthwise_separable_convolution_layer(const SimpleTensor &in, const SimpleTensor &depthwise_weights, const SimpleTensor &depthwise_biases, + const TensorShape &depthwise_out_shape, + const SimpleTensor &pointwise_weights, const SimpleTensor &pointwise_biases, const TensorShape &dst_shape, const PadStrideInfo &depthwise_conv_info, + const PadStrideInfo &pointwise_conv_info); } // namespace reference } // namespace validation } // namespace test diff --git a/tests/validation/CPP/DepthwiseSeparableConvolutionLayer.h b/tests/validation/CPP/DepthwiseSeparableConvolutionLayer.h index 71cd013424..0fcce2c964 100644 --- a/tests/validation/CPP/DepthwiseSeparableConvolutionLayer.h +++ b/tests/validation/CPP/DepthwiseSeparableConvolutionLayer.h @@ -36,9 +36,10 @@ namespace validation namespace reference { template -SimpleTensor depthwise_separable_convolution_layer(const SimpleTensor &src, const SimpleTensor &depthwise_weights, const TensorShape &depthwise_out_shape, - const SimpleTensor &pointwise_weights, - const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info); +SimpleTensor depthwise_separable_convolution_layer(const SimpleTensor &src, const SimpleTensor &depthwise_weights, const SimpleTensor &depthwise_biases, + const TensorShape &depthwise_out_shape, + const SimpleTensor &pointwise_weights, const SimpleTensor &pointwise_biases, const TensorShape &dst_shape, + const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info); } // namespace reference } // namespace validation } // namespace test -- cgit v1.2.1