aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/CL/DirectConvolutionLayer.cpp
diff options
context:
space:
mode:
authorSiCong Li <sicong.li@arm.com>2017-07-28 14:46:20 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-09-17 14:16:42 +0100
commitc51b72fe34e6018a1807a2c78228da7beeee1750 (patch)
treee1c969d6a54ae2561f8d4c6c35fd2534785f09b3 /tests/validation/CL/DirectConvolutionLayer.cpp
parent572ade736ab344a62afa7da214cd9407fe53a281 (diff)
downloadComputeLibrary-c51b72fe34e6018a1807a2c78228da7beeee1750.tar.gz
COMPMID-355 Implement CL DirectConvolution1x1
* Add FP16 to validation tests. * Complete benchmark tests for CL and NEON Direct Convolution. Change-Id: Ie73d8580832372db01b82b39786fd9c8be560090 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/82014 Reviewed-by: Anthony Barbier <anthony.barbier@arm.com> Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'tests/validation/CL/DirectConvolutionLayer.cpp')
-rw-r--r--tests/validation/CL/DirectConvolutionLayer.cpp45
1 files changed, 42 insertions, 3 deletions
diff --git a/tests/validation/CL/DirectConvolutionLayer.cpp b/tests/validation/CL/DirectConvolutionLayer.cpp
index 5b00a019ba..d9dd34b9ec 100644
--- a/tests/validation/CL/DirectConvolutionLayer.cpp
+++ b/tests/validation/CL/DirectConvolutionLayer.cpp
@@ -48,7 +48,24 @@ using namespace arm_compute::test::validation;
namespace
{
-const float tolerance_fp = 1e-3f; /**< Tolerance for floating point tests */
+/** Define tolerance of the direct convolution layer
+ *
+ * @param[in] dt DataType of the tensor.
+ *
+ * @return Tolerance depending on the data type.
+ */
+float direct_convolution_layer_tolerance(DataType dt)
+{
+ switch(dt)
+ {
+ case DataType::F16:
+ return 0.1f;
+ case DataType::F32:
+ return 1e-3f;
+ default:
+ return 0.f;
+ }
+}
/** Compute CL direct convolution layer function.
*
@@ -90,6 +107,7 @@ CLTensor compute_convolution_layer(const TensorShape &src_shape, const TensorSha
// Fill tensors
switch(dt)
{
+ case DataType::F16:
case DataType::F32:
{
std::uniform_real_distribution<> distribution(-1.f, 1.f);
@@ -133,8 +151,29 @@ BOOST_AUTO_TEST_SUITE(DirectConvolutionLayer)
BOOST_AUTO_TEST_SUITE(Float)
BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
-BOOST_DATA_TEST_CASE(W3x3, DirectConvolutionShapes() * CNNFloatDataTypes() * boost::unit_test::data::xrange(1, 3, 1) * boost::unit_test::data::xrange(1, 3, 1) * boost::unit_test::data::xrange(0, 2,
+BOOST_DATA_TEST_CASE(W1x1, DirectConvolutionShapes() * boost::unit_test::data::make({ DataType::F16, DataType::F32 }) * boost::unit_test::data::xrange(1, 4, 1) * boost::unit_test::data::xrange(1, 4,
+ 1)
+ * boost::unit_test::data::make({ 1, 4, 8, 16 }),
+ input_shape, dt, sx, sy, num_kernels)
+{
+ const unsigned int kernel_size = 1;
+ const PadStrideInfo conv_info(sx, sy, 0, 0, DimensionRoundingType::FLOOR);
+ const TensorShape w_shape(kernel_size, kernel_size, input_shape.z(), static_cast<unsigned int>(num_kernels));
+ const TensorShape b_shape(static_cast<unsigned int>(num_kernels));
+ const TensorShape d_shape(get_output_shape(input_shape, w_shape, conv_info));
+
+ CLTensor dst = compute_convolution_layer(input_shape, w_shape, b_shape, d_shape, dt, conv_info);
+
+ RawTensor ref = Reference::compute_reference_convolution_layer(input_shape, w_shape, b_shape, d_shape, dt, conv_info, 0);
+
+ // Validate output
+ validate(CLAccessor(dst), ref, direct_convolution_layer_tolerance(dt));
+}
+
+BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
+BOOST_DATA_TEST_CASE(W3x3, DirectConvolutionShapes() * boost::unit_test::data::make({ DataType::F16, DataType::F32 }) * boost::unit_test::data::xrange(1, 3, 1) * boost::unit_test::data::xrange(1, 3,
1)
+ * boost::unit_test::data::xrange(0, 2, 1)
* boost::unit_test::data::xrange(0, 2, 1) * boost::unit_test::data::make({ 1, 4, 8, 16 }),
input_shape, dt, sx, sy, px, py, num_kernels)
{
@@ -149,7 +188,7 @@ BOOST_DATA_TEST_CASE(W3x3, DirectConvolutionShapes() * CNNFloatDataTypes() * boo
RawTensor ref = Reference::compute_reference_convolution_layer(input_shape, w_shape, b_shape, d_shape, dt, conv_info, 0);
// Validate output
- validate(CLAccessor(dst), ref, tolerance_fp);
+ validate(CLAccessor(dst), ref, direct_convolution_layer_tolerance(dt));
}
BOOST_AUTO_TEST_SUITE_END()