From 443c8b979518ad494b9e59648cbd061ebf37cba9 Mon Sep 17 00:00:00 2001 From: Moritz Pflanzer Date: Tue, 27 Jun 2017 12:36:21 +0100 Subject: COMPMID-417: Move ActivationLayer tests to boost This is only a quick&dirty solution to prevent the nightlies from failing. Clean up has to be done under COMPMID-426. Change-Id: Ife1a377efa6aaf389a36f1f8d913ad601b3fdb3c Reviewed-on: http://mpd-gerrit.cambridge.arm.com/78966 Tested-by: Kaizen Reviewed-by: Michele DiGiorgio Reviewed-by: Georgios Pinitas --- tests/validation/NEON/ActivationLayer.cpp | 73 +++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 19 deletions(-) (limited to 'tests/validation/NEON/ActivationLayer.cpp') diff --git a/tests/validation/NEON/ActivationLayer.cpp b/tests/validation/NEON/ActivationLayer.cpp index a4826accfa..11ac6696b1 100644 --- a/tests/validation/NEON/ActivationLayer.cpp +++ b/tests/validation/NEON/ActivationLayer.cpp @@ -76,14 +76,15 @@ float activation_layer_tolerance(ActivationLayerInfo::ActivationFunction activat /** Compute Neon activation layer function. * + * @param[in] in_place Compute the activation layer in-place. * @param[in] shape Shape of the input and output tensors. * @param[in] dt Shape Data type of tensors. * @param[in] act_info Activation layer information. - * @param[in] fixed_point_position Number of bits for the fractional part of fixed point numbers. + * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of fixed point numbers. * * @return Computed output tensor. */ -Tensor compute_activation_layer(const TensorShape &shape, DataType dt, ActivationLayerInfo act_info, int fixed_point_position = 0) +Tensor compute_activation_layer(bool in_place, const TensorShape &shape, DataType dt, ActivationLayerInfo act_info, int fixed_point_position = 0) { // Create tensors Tensor src = create_tensor(shape, dt, 1, fixed_point_position); @@ -91,14 +92,25 @@ Tensor compute_activation_layer(const TensorShape &shape, DataType dt, Activatio // Create and configure function NEActivationLayer act_layer; - act_layer.configure(&src, &dst, act_info); + + if(in_place) + { + act_layer.configure(&src, nullptr, act_info); + } + else + { + act_layer.configure(&src, &dst, act_info); + } // Allocate tensors src.allocator()->allocate(); - dst.allocator()->allocate(); - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); + + if(!in_place) + { + dst.allocator()->allocate(); + BOOST_TEST(!dst.info()->is_resizable()); + } // Fill tensors if(dt == DataType::F32) @@ -121,7 +133,14 @@ Tensor compute_activation_layer(const TensorShape &shape, DataType dt, Activatio // Compute function act_layer.run(); - return dst; + if(in_place) + { + return src; + } + else + { + return dst; + } } } // namespace @@ -130,10 +149,10 @@ BOOST_AUTO_TEST_SUITE(NEON) BOOST_AUTO_TEST_SUITE(ActivationLayer) BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * CNNDataTypes(), shape, dt) +BOOST_DATA_TEST_CASE(Configuration, boost::unit_test::data::make({ false, true }) * (SmallShapes() + LargeShapes()) * CNNDataTypes(), in_place, shape, dt) { // Set fixed point position data type allowed - int fixed_point_position = (arm_compute::is_data_type_fixed_point(dt)) ? 3 : 0; + const int fixed_point_position = (arm_compute::is_data_type_fixed_point(dt)) ? 3 : 0; // Create tensors Tensor src = create_tensor(shape, dt, 1, fixed_point_position); @@ -144,28 +163,44 @@ BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * CNNDataTyp // Create and configure function NEActivationLayer act_layer; - act_layer.configure(&src, &dst, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS)); + + if(in_place) + { + act_layer.configure(&src, nullptr, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS)); + } + else + { + act_layer.configure(&src, &dst, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS)); + } // Validate valid region const ValidRegion valid_region = shape_to_valid_region(shape); validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); + + if(!in_place) + { + validate(dst.info()->valid_region(), valid_region); + } // Validate padding const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); + + if(!in_place) + { + validate(dst.info()->padding(), padding); + } } BOOST_AUTO_TEST_SUITE(Float) BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * CNNFloatDataTypes() * ActivationFunctions(), shape, dt, act_function) +BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::make({ false, true }) * SmallShapes() * CNNFloatDataTypes() * ActivationFunctions(), in_place, shape, dt, act_function) { // Create activation layer info ActivationLayerInfo act_info(act_function, 1.f, 1.f); // Compute function - Tensor dst = compute_activation_layer(shape, dt, act_info); + Tensor dst = compute_activation_layer(in_place, shape, dt, act_info); // Compute reference RawTensor ref_dst = Reference::compute_reference_activation_layer(shape, dt, act_info); @@ -175,13 +210,13 @@ BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * CNNFloatDataTypes() * ActivationF } BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * CNNFloatDataTypes() * ActivationFunctions(), shape, dt, act_function) +BOOST_DATA_TEST_CASE(RunLarge, boost::unit_test::data::make({ false, true }) * LargeShapes() * CNNFloatDataTypes() * ActivationFunctions(), in_place, shape, dt, act_function) { // Create activation layer info ActivationLayerInfo act_info(act_function, 1.f, 1.f); // Compute function - Tensor dst = compute_activation_layer(shape, dt, act_info); + Tensor dst = compute_activation_layer(in_place, shape, dt, act_info); // Compute reference RawTensor ref_dst = Reference::compute_reference_activation_layer(shape, dt, act_info); @@ -196,14 +231,14 @@ BOOST_AUTO_TEST_SUITE_END() */ BOOST_AUTO_TEST_SUITE(Quantized) BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ActivationFunctions() * boost::unit_test::data::xrange(3, 6, 1), - shape, act_function, fixed_point_position) +BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::make({ false, true }) * SmallShapes() * ActivationFunctions() * boost::unit_test::data::xrange(3, 6, 1), + in_place, shape, act_function, fixed_point_position) { // Create activation layer info ActivationLayerInfo act_info(act_function, 1.f, 1.f); // Compute function - Tensor dst = compute_activation_layer(shape, DataType::QS8, act_info, fixed_point_position); + Tensor dst = compute_activation_layer(in_place, shape, DataType::QS8, act_info, fixed_point_position); // Compute reference RawTensor ref_dst = Reference::compute_reference_activation_layer(shape, DataType::QS8, act_info, fixed_point_position); -- cgit v1.2.1