aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorManuel Bottini <manuel.bottini@arm.com>2019-01-14 15:14:43 +0000
committerManuel Bottini <manuel.bottini@arm.com>2019-01-23 14:11:17 +0000
commit1d4f3853dfd16f55338d772ad757db0ee8710d78 (patch)
tree344a48b5d296fef0e05d345d342ba0733f8db7a2 /tests
parent734151d20bef56cbedce2ae67945f42cb4e265c8 (diff)
downloadComputeLibrary-1d4f3853dfd16f55338d772ad757db0ee8710d78.tar.gz
COMPMID-1760: NEON: Implement Prod
Change-Id: I8062f4ca5ef5cf1a8183ac0834f240bbaf8f695d Reviewed-on: https://review.mlplatform.org/541 Reviewed-by: Pablo Marquez <pablo.tello@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/datasets/ShapeDatasets.h2
-rw-r--r--tests/validation/NEON/ReductionOperation.cpp28
-rw-r--r--tests/validation/reference/ReductionOperation.cpp30
3 files changed, 48 insertions, 12 deletions
diff --git a/tests/datasets/ShapeDatasets.h b/tests/datasets/ShapeDatasets.h
index bd29fe649a..9ee89f43e0 100644
--- a/tests/datasets/ShapeDatasets.h
+++ b/tests/datasets/ShapeDatasets.h
@@ -148,7 +148,7 @@ public:
Small4DShapes()
: ShapeDataset("Shape",
{
- TensorShape{ 1U, 7U, 1U, 3U },
+ TensorShape{ 2U, 7U, 1U, 3U },
TensorShape{ 7U, 7U, 5U, 3U },
TensorShape{ 27U, 13U, 37U, 2U },
TensorShape{ 128U, 64U, 21U, 3U }
diff --git a/tests/validation/NEON/ReductionOperation.cpp b/tests/validation/NEON/ReductionOperation.cpp
index e322947993..b9b4983ae6 100644
--- a/tests/validation/NEON/ReductionOperation.cpp
+++ b/tests/validation/NEON/ReductionOperation.cpp
@@ -49,7 +49,21 @@ RelativeTolerance<float> rel_tolerance_f32(0.00001f);
RelativeTolerance<float> tolerance_qasymm8(1);
const auto ReductionOperations = framework::dataset::make("ReductionOperation",
-{ ReductionOperation::SUM });
+{
+ ReductionOperation::SUM,
+ ReductionOperation::PROD
+});
+
+const auto QuantizationInfos = framework::dataset::make("QuantizationInfo",
+{
+ QuantizationInfo(1.f / 128, -10),
+ QuantizationInfo(1.f / 64, -5),
+ QuantizationInfo(1.f / 32, -2)
+});
+
+const auto Axises = framework::dataset::make("Axis",
+{ 0, 1, 2, 3 });
+
} // namespace
TEST_SUITE(NEON)
@@ -88,13 +102,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 })), ReductionOperations))
+ combine(combine(combine(datasets::Small4DShapes(), framework::dataset::make("DataType", DataType::F32)), Axises), 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 })), ReductionOperations))
+ combine(combine(combine(datasets::Large4DShapes(), framework::dataset::make("DataType", DataType::F32)), Axises), ReductionOperations))
{
// Validate output
validate(Accessor(_target), _reference, rel_tolerance_f32, 0, tolerance_f32);
@@ -106,17 +120,17 @@ 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 })),
+ combine(combine(combine(combine(datasets::Small4DShapes(), framework::dataset::make("DataType", DataType::QASYMM8)), Axises),
ReductionOperations),
- framework::dataset::make("QuantizationInfo", { QuantizationInfo(1.f / 255, 0) })))
+ QuantizationInfos))
{
// Validate output
validate(Accessor(_target), _reference, tolerance_qasymm8);
}
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 })),
+ combine(combine(combine(combine(datasets::Large4DShapes(), framework::dataset::make("DataType", DataType::QASYMM8)), Axises),
ReductionOperations),
- framework::dataset::make("QuantizationInfo", { QuantizationInfo(1.f / 255, 0) })))
+ QuantizationInfos))
{
// Validate output
validate(Accessor(_target), _reference, tolerance_qasymm8);
diff --git a/tests/validation/reference/ReductionOperation.cpp b/tests/validation/reference/ReductionOperation.cpp
index 8e79c3bfb0..fb7a6d6997 100644
--- a/tests/validation/reference/ReductionOperation.cpp
+++ b/tests/validation/reference/ReductionOperation.cpp
@@ -128,7 +128,7 @@ OT reduce_operation(const T *ptr, int reduce_elements, ReductionOperation op, in
} // namespace
template <typename T, typename OT>
-SimpleTensor<OT> reduction_operation(const SimpleTensor<T> &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op)
+SimpleTensor<OT> compute_reduction_operation(const SimpleTensor<T> &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op)
{
// Create reference
const bool is_arg_min_max = (op == ReductionOperation::ARG_IDX_MIN || op == ReductionOperation::ARG_IDX_MAX);
@@ -213,12 +213,34 @@ SimpleTensor<OT> reduction_operation(const SimpleTensor<T> &src, const TensorSha
return dst;
}
+template <typename T, typename OT>
+SimpleTensor<OT> reduction_operation(const SimpleTensor<T> &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op)
+{
+ return compute_reduction_operation<T, OT>(src, dst_shape, axis, op);
+}
+
+template <>
+SimpleTensor<uint8_t> reduction_operation(const SimpleTensor<uint8_t> &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op)
+{
+ if(src.data_type() == DataType::QASYMM8 && op != ReductionOperation::MEAN_SUM)
+ {
+ SimpleTensor<float> src_f = convert_from_asymmetric(src);
+ SimpleTensor<float> dst_f = reference::reduction_operation<float, float>(src_f, dst_shape, axis, op);
+ return convert_to_asymmetric(dst_f, src.quantization_info());
+ }
+ else
+ {
+ return compute_reduction_operation<uint8_t, uint8_t>(src, dst_shape, axis, op);
+ }
+}
+
+template SimpleTensor<float> reduction_operation(const SimpleTensor<float> &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op);
+template SimpleTensor<half> reduction_operation(const SimpleTensor<half> &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op);
+
template SimpleTensor<uint32_t> reduction_operation(const SimpleTensor<float> &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op);
template SimpleTensor<uint32_t> reduction_operation(const SimpleTensor<half> &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op);
template SimpleTensor<uint32_t> reduction_operation(const SimpleTensor<uint8_t> &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op);
-template SimpleTensor<float> reduction_operation(const SimpleTensor<float> &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op);
-template SimpleTensor<half> reduction_operation(const SimpleTensor<half> &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op);
-template SimpleTensor<uint8_t> reduction_operation(const SimpleTensor<uint8_t> &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op);
+
} // namespace reference
} // namespace validation
} // namespace test