aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorManuel Bottini <manuel.bottini@arm.com>2018-12-10 17:40:23 +0000
committerManuel Bottini <manuel.bottini@arm.com>2019-01-14 13:53:11 +0000
commitb412fab0e3c8ec10e104f4d85760898a5b26179c (patch)
treee0cd062cdd32e78db3e2e67bcdb39e7efab6dff5 /tests
parent1c9efebf4344e8db97e6d9282b2bf48b52090b58 (diff)
downloadComputeLibrary-b412fab0e3c8ec10e104f4d85760898a5b26179c.tar.gz
COMPMID-1724: CL Implement Prod
Change-Id: I17e51f25064b53a8f7e13d6fcbecc14a192de103 Reviewed-on: https://review.mlplatform.org/387 Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/datasets/ReductionOperationDataset.h53
-rw-r--r--tests/validation/CL/ReductionOperation.cpp20
-rw-r--r--tests/validation/NEON/ReductionOperation.cpp12
-rw-r--r--tests/validation/reference/ReductionOperation.cpp11
4 files changed, 28 insertions, 68 deletions
diff --git a/tests/datasets/ReductionOperationDataset.h b/tests/datasets/ReductionOperationDataset.h
deleted file mode 100644
index dadc4e9249..0000000000
--- a/tests/datasets/ReductionOperationDataset.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2017-2018 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.
- */
-#ifndef __ARM_COMPUTE_TEST_REDUCTION_OPERATION_DATASET_H__
-#define __ARM_COMPUTE_TEST_REDUCTION_OPERATION_DATASET_H__
-
-#include "arm_compute/core/Types.h"
-#include "tests/framework/datasets/ContainerDataset.h"
-#include "utils/TypePrinter.h"
-
-#include <vector>
-
-namespace arm_compute
-{
-namespace test
-{
-namespace datasets
-{
-class ReductionOperations final : public framework::dataset::ContainerDataset<std::vector<ReductionOperation>>
-{
-public:
- ReductionOperations()
- : ContainerDataset("ReductionOperation",
- {
- ReductionOperation::SUM
- })
- {
- }
-};
-} // namespace datasets
-} // namespace test
-} // namespace arm_compute
-#endif /* __ARM_COMPUTE_TEST_REDUCTION_OPERATION_DATASET_H__ */
diff --git a/tests/validation/CL/ReductionOperation.cpp b/tests/validation/CL/ReductionOperation.cpp
index 2adb4e90d6..c8474e97e6 100644
--- a/tests/validation/CL/ReductionOperation.cpp
+++ b/tests/validation/CL/ReductionOperation.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018 ARM Limited.
+ * Copyright (c) 2017-2019 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -27,7 +27,6 @@
#include "arm_compute/runtime/CL/functions/CLReductionOperation.h"
#include "tests/CL/CLAccessor.h"
#include "tests/PaddingCalculator.h"
-#include "tests/datasets/ReductionOperationDataset.h"
#include "tests/datasets/ShapeDatasets.h"
#include "tests/framework/Asserts.h"
#include "tests/framework/Macros.h"
@@ -44,10 +43,17 @@ namespace validation
namespace
{
/** Tolerance for float operations */
-AbsoluteTolerance<float> tolerance_f32(0.01f);
+AbsoluteTolerance<float> tolerance_f32(0.001f);
RelativeTolerance<float> rel_tolerance_f32(0.00001f);
AbsoluteTolerance<float> tolerance_f16(0.5f);
RelativeTolerance<float> rel_tolerance_f16(0.2f);
+
+const auto ReductionOperations = framework::dataset::make("ReductionOperation",
+{
+ ReductionOperation::SUM,
+ ReductionOperation::PROD
+});
+
} // namespace
TEST_SUITE(CL)
@@ -89,13 +95,13 @@ using CLReductionOperationFixture = ReductionOperationFixture<CLTensor, CLAccess
TEST_SUITE(Float)
TEST_SUITE(FP16)
FIXTURE_DATA_TEST_CASE(RunSmall, CLReductionOperationFixture<half>, framework::DatasetMode::PRECOMMIT,
- combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), datasets::ReductionOperations()))
+ combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), ReductionOperations))
{
// Validate output
validate(CLAccessor(_target), _reference, tolerance_f16);
}
FIXTURE_DATA_TEST_CASE(RunLarge, CLReductionOperationFixture<half>, framework::DatasetMode::NIGHTLY,
- combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F16)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), datasets::ReductionOperations()))
+ combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F16)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), ReductionOperations))
{
// Validate output
validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0, tolerance_f16);
@@ -103,13 +109,13 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLReductionOperationFixture<half>, framework::D
TEST_SUITE_END() // F16
TEST_SUITE(FP32)
FIXTURE_DATA_TEST_CASE(RunSmall, CLReductionOperationFixture<float>, framework::DatasetMode::PRECOMMIT,
- combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), datasets::ReductionOperations()))
+ combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), ReductionOperations))
{
// Validate output
validate(CLAccessor(_target), _reference, tolerance_f32);
}
FIXTURE_DATA_TEST_CASE(RunLarge, CLReductionOperationFixture<float>, framework::DatasetMode::NIGHTLY,
- combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), datasets::ReductionOperations()))
+ combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), ReductionOperations))
{
// Validate output
validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0, tolerance_f32);
diff --git a/tests/validation/NEON/ReductionOperation.cpp b/tests/validation/NEON/ReductionOperation.cpp
index d064940366..e322947993 100644
--- a/tests/validation/NEON/ReductionOperation.cpp
+++ b/tests/validation/NEON/ReductionOperation.cpp
@@ -27,7 +27,6 @@
#include "arm_compute/runtime/TensorAllocator.h"
#include "tests/NEON/Accessor.h"
#include "tests/PaddingCalculator.h"
-#include "tests/datasets/ReductionOperationDataset.h"
#include "tests/datasets/ShapeDatasets.h"
#include "tests/framework/Asserts.h"
#include "tests/framework/Macros.h"
@@ -48,6 +47,9 @@ AbsoluteTolerance<float> tolerance_f32(0.0001f);
RelativeTolerance<float> rel_tolerance_f32(0.00001f);
/** Tolerance for quantized operations */
RelativeTolerance<float> tolerance_qasymm8(1);
+
+const auto ReductionOperations = framework::dataset::make("ReductionOperation",
+{ ReductionOperation::SUM });
} // namespace
TEST_SUITE(NEON)
@@ -86,13 +88,13 @@ using NEReductionOperationFixture = ReductionOperationFixture<Tensor, Accessor,
TEST_SUITE(FP32)
FIXTURE_DATA_TEST_CASE(RunSmall, NEReductionOperationFixture<float>, framework::DatasetMode::PRECOMMIT,
- combine(combine(combine(datasets::Small4DShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), datasets::ReductionOperations()))
+ combine(combine(combine(datasets::Small4DShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), ReductionOperations))
{
// Validate output
validate(Accessor(_target), _reference, tolerance_f32);
}
FIXTURE_DATA_TEST_CASE(RunLarge, NEReductionOperationFixture<float>, framework::DatasetMode::NIGHTLY,
- combine(combine(combine(datasets::Large4DShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), datasets::ReductionOperations()))
+ combine(combine(combine(datasets::Large4DShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), ReductionOperations))
{
// Validate output
validate(Accessor(_target), _reference, rel_tolerance_f32, 0, tolerance_f32);
@@ -105,7 +107,7 @@ using NEReductionOperationQuantizedFixture = ReductionOperationQuantizedFixture<
TEST_SUITE(QASYMM8)
FIXTURE_DATA_TEST_CASE(RunSmall, NEReductionOperationQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
combine(combine(combine(combine(datasets::Small4DShapes(), framework::dataset::make("DataType", DataType::QASYMM8)), framework::dataset::make("Axis", { 0, 1, 2, 3 })),
- datasets::ReductionOperations()),
+ ReductionOperations),
framework::dataset::make("QuantizationInfo", { QuantizationInfo(1.f / 255, 0) })))
{
// Validate output
@@ -113,7 +115,7 @@ FIXTURE_DATA_TEST_CASE(RunSmall, NEReductionOperationQuantizedFixture<uint8_t>,
}
FIXTURE_DATA_TEST_CASE(RunLarge, NEReductionOperationQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY,
combine(combine(combine(combine(datasets::Large4DShapes(), framework::dataset::make("DataType", DataType::QASYMM8)), framework::dataset::make("Axis", { 0, 1, 2, 3 })),
- datasets::ReductionOperations()),
+ ReductionOperations),
framework::dataset::make("QuantizationInfo", { QuantizationInfo(1.f / 255, 0) })))
{
// Validate output
diff --git a/tests/validation/reference/ReductionOperation.cpp b/tests/validation/reference/ReductionOperation.cpp
index fc12e31d75..8e79c3bfb0 100644
--- a/tests/validation/reference/ReductionOperation.cpp
+++ b/tests/validation/reference/ReductionOperation.cpp
@@ -42,11 +42,11 @@ template <typename T, typename OT>
OT reduce_operation(const T *ptr, int reduce_elements, ReductionOperation op, int stride)
{
using type = typename std::remove_cv<OT>::type;
- auto res = type(0);
+ auto res = (op == ReductionOperation::PROD) ? type(1) : type(0);
if(std::is_integral<type>::value)
{
- uint32_t int_res = 0;
+ auto int_res = static_cast<uint32_t>(res);
for(int i = 0; i < reduce_elements; ++i)
{
auto elem = *(ptr + stride * i);
@@ -72,6 +72,9 @@ OT reduce_operation(const T *ptr, int reduce_elements, ReductionOperation op, in
case ReductionOperation::SUM:
int_res += elem;
break;
+ case ReductionOperation::PROD:
+ int_res *= elem;
+ break;
default:
ARM_COMPUTE_ERROR("Operation not supported");
}
@@ -108,6 +111,9 @@ OT reduce_operation(const T *ptr, int reduce_elements, ReductionOperation op, in
case ReductionOperation::SUM:
res += elem;
break;
+ case ReductionOperation::PROD:
+ res *= elem;
+ break;
default:
ARM_COMPUTE_ERROR("Operation not supported");
}
@@ -117,7 +123,6 @@ OT reduce_operation(const T *ptr, int reduce_elements, ReductionOperation op, in
res /= reduce_elements;
}
}
-
return res;
}
} // namespace