aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/NEON/MeanStdDev.cpp
diff options
context:
space:
mode:
authorGiorgio Arena <giorgio.arena@arm.com>2017-06-13 15:19:51 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-09-17 13:03:43 +0100
commitf795986c8d4594279c277b14a33d29e48b2a4def (patch)
tree83c6c888e69fa380acaf81988f6a05d8035f627d /tests/validation/NEON/MeanStdDev.cpp
parent7b06cde62a19ae0fda7bbbf0ab0bf18a88470af8 (diff)
downloadComputeLibrary-f795986c8d4594279c277b14a33d29e48b2a4def.tar.gz
COMPMID-378 NEMeanStdDev test completed.
Change-Id: I46fb77c0cb507a4c0fe3264a89dd7b2ba63c44dc Reviewed-on: http://mpd-gerrit.cambridge.arm.com/77427 Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com> Reviewed-by: Steven Niu <steven.niu@arm.com>
Diffstat (limited to 'tests/validation/NEON/MeanStdDev.cpp')
-rw-r--r--tests/validation/NEON/MeanStdDev.cpp145
1 files changed, 145 insertions, 0 deletions
diff --git a/tests/validation/NEON/MeanStdDev.cpp b/tests/validation/NEON/MeanStdDev.cpp
new file mode 100644
index 0000000000..79a30f62b2
--- /dev/null
+++ b/tests/validation/NEON/MeanStdDev.cpp
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2017 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include "Globals.h"
+#include "NEON/Helper.h"
+#include "NEON/NEAccessor.h"
+#include "TensorLibrary.h"
+#include "TypePrinter.h"
+#include "Utils.h"
+#include "validation/Datasets.h"
+#include "validation/Reference.h"
+#include "validation/Validation.h"
+
+#include "arm_compute/core/Helpers.h"
+#include "arm_compute/core/Types.h"
+#include "arm_compute/runtime/NEON/functions/NEMeanStdDev.h"
+#include "arm_compute/runtime/Tensor.h"
+#include "arm_compute/runtime/TensorAllocator.h"
+
+#include "boost_wrapper.h"
+
+#include <random>
+#include <string>
+
+using namespace arm_compute;
+using namespace arm_compute::test;
+using namespace arm_compute::test::neon;
+using namespace arm_compute::test::validation;
+
+namespace
+{
+/** Compute Neon mean and standard deviation function.
+ *
+ * @param[in] shape Shape of the input tensors.
+ *
+ * @return Computed mean and standard deviation.
+ */
+std::pair<float, float> compute_mean_and_standard_deviation(const TensorShape &shape)
+{
+ // Create tensor
+ Tensor src = create_tensor(shape, DataType::U8);
+
+ // Create output variables
+ float mean = 0.f;
+ float std_dev = 0.f;
+
+ // Create mean and standard deviation configure function
+ NEMeanStdDev mean_std_dev_image;
+ mean_std_dev_image.configure(&src, &mean, &std_dev);
+
+ // Allocate tensors
+ src.allocator()->allocate();
+
+ BOOST_TEST(!src.info()->is_resizable());
+
+ // Fill tensor
+ library->fill_tensor_uniform(NEAccessor(src), 0);
+
+ // Compute function
+ mean_std_dev_image.run();
+
+ return std::make_pair(mean, std_dev);
+}
+} // namespace
+
+#ifndef DOXYGEN_SKIP_THIS
+BOOST_AUTO_TEST_SUITE(NEON)
+BOOST_AUTO_TEST_SUITE(MeanStdDev)
+
+BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
+BOOST_DATA_TEST_CASE(Configuration, Small2DShapes() + Large2DShapes(), shape)
+{
+ // Create tensor
+ Tensor src = create_tensor(shape, DataType::U8);
+
+ // Create output variables
+ float mean = 0.f;
+ float std_dev = 0.f;
+
+ BOOST_TEST(src.info()->is_resizable());
+
+ // Create mean and standard deviation configure function
+ NEMeanStdDev mean_std_dev_image;
+ mean_std_dev_image.configure(&src, &mean, &std_dev);
+
+ // Validate valid region
+ const ValidRegion valid_region = shape_to_valid_region(shape);
+ validate(src.info()->valid_region(), valid_region);
+
+ // Validate padding
+ const PaddingSize padding(0, required_padding(shape.x(), 16), 0, 0);
+ validate(src.info()->padding(), padding);
+}
+
+BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
+BOOST_DATA_TEST_CASE(RunSmall, Small2DShapes(), shape)
+{
+ // Compute function
+ std::pair<float, float> output = compute_mean_and_standard_deviation(shape);
+
+ // Compute reference
+ std::pair<float, float> ref_output = Reference::compute_reference_mean_and_standard_deviation(shape);
+
+ // Validate output
+ BOOST_TEST(static_cast<int>(output.first) == static_cast<int>(ref_output.first));
+ BOOST_TEST(static_cast<int>(output.second) == static_cast<int>(ref_output.second));
+}
+
+BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
+BOOST_DATA_TEST_CASE(RunLarge, Large2DShapes(), shape)
+{
+ // Compute function
+ std::pair<float, float> output = compute_mean_and_standard_deviation(shape);
+
+ // Compute reference
+ std::pair<float, float> ref_output = Reference::compute_reference_mean_and_standard_deviation(shape);
+
+ // Validate output
+ BOOST_TEST(static_cast<int>(output.first) == static_cast<int>(ref_output.first));
+ BOOST_TEST(static_cast<int>(output.second) == static_cast<int>(ref_output.second));
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END()
+#endif