From 164a2727d3bbce0e575d24b7db787c85e2e2c203 Mon Sep 17 00:00:00 2001 From: giuros01 Date: Tue, 20 Nov 2018 18:34:46 +0000 Subject: COMPMID-1717: CL: Implement Maximum, Minimum, SquaredDifference Change-Id: Ice653e48211053bd3cd20a693bd76de6b4efc370 Reviewed-on: https://review.mlplatform.org/270 Reviewed-by: Georgios Pinitas Tested-by: Arm Jenkins --- tests/validation/CL/ArithmeticSubtraction.cpp | 83 ++++++++++++++------------- 1 file changed, 42 insertions(+), 41 deletions(-) (limited to 'tests/validation/CL/ArithmeticSubtraction.cpp') diff --git a/tests/validation/CL/ArithmeticSubtraction.cpp b/tests/validation/CL/ArithmeticSubtraction.cpp index cd13f42ec4..2cf410f373 100644 --- a/tests/validation/CL/ArithmeticSubtraction.cpp +++ b/tests/validation/CL/ArithmeticSubtraction.cpp @@ -24,7 +24,7 @@ #include "arm_compute/core/Types.h" #include "arm_compute/runtime/CL/CLTensor.h" #include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLArithmeticSubtraction.h" +#include "arm_compute/runtime/CL/functions/CLElementwiseOperations.h" #include "tests/CL/CLAccessor.h" #include "tests/PaddingCalculator.h" #include "tests/datasets/ConvertPolicyDataset.h" @@ -43,6 +43,7 @@ namespace validation { namespace { +constexpr unsigned int num_elems_processed_per_iteration = 16; /** Input data sets **/ const auto ArithmeticSubtractionU8Dataset = combine(combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::U8)), framework::dataset::make("DataType", @@ -64,26 +65,26 @@ TEST_SUITE(ArithmeticSubtraction) // *INDENT-OFF* // clang-format off DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( - framework::dataset::make("Input1Info", { TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), - TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), - TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), // Window shrink - TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), // Invalid data type combination - TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), // Mismatching shapes - }), - framework::dataset::make("Input2Info",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), - TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), - TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), - TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16), - TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), - })), - framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16), - TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), - TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), - TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), - TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), - })), - framework::dataset::make("Expected", { true, true, false, false, false})), - input1_info, input2_info, output_info, expected) + framework::dataset::make("Input1Info", { TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), // Window shrink + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), // Invalid data type combination + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), // Mismatching shapes + }), + framework::dataset::make("Input2Info",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16), + TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), + })), + framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16), + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), + TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), + TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), + TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), + })), + framework::dataset::make("Expected", { true, true, false, false, false})), + input1_info, input2_info, output_info, expected) { ARM_COMPUTE_EXPECT(bool(CLArithmeticSubtraction::validate(&input1_info.clone()->set_is_resizable(false), &input2_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), ConvertPolicy::WRAP)) == expected, framework::LogLevel::ERRORS); } @@ -103,15 +104,15 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::da CLTensor dst = create_tensor(shape, DataType::U8); // Create and Configure function - CLArithmeticSubtraction sub; - sub.configure(&ref_src1, &ref_src2, &dst, policy); + CLArithmeticSubtraction add; + add.configure(&ref_src1, &ref_src2, &dst, policy); // Validate valid region const ValidRegion valid_region = shape_to_valid_region(shape); validate(dst.info()->valid_region(), valid_region); // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); validate(ref_src1.info()->padding(), padding); validate(ref_src2.info()->padding(), padding); validate(dst.info()->padding(), padding); @@ -123,7 +124,7 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionFixture, framew // Validate output validate(CLAccessor(_target), _reference); } -TEST_SUITE_END() // U8 +TEST_SUITE_END() template using CLArithmeticSubtractionQuantizedFixture = ArithmeticSubtractionValidationQuantizedFixture; @@ -147,7 +148,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::da validate(dst.info()->valid_region(), valid_region); // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); validate(ref_src1.info()->padding(), padding); validate(ref_src2.info()->padding(), padding); validate(dst.info()->padding(), padding); @@ -165,8 +166,8 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionQuantizedFixture(shape, DataType::S16); // Create and Configure function - CLArithmeticSubtraction sub; - sub.configure(&ref_src1, &ref_src2, &dst, policy); + CLArithmeticSubtraction add; + add.configure(&ref_src1, &ref_src2, &dst, policy); // Validate valid region const ValidRegion valid_region = shape_to_valid_region(shape); validate(dst.info()->valid_region(), valid_region); // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); validate(ref_src1.info()->padding(), padding); validate(ref_src2.info()->padding(), padding); validate(dst.info()->padding(), padding); @@ -206,7 +207,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLArithmeticSubtractionFixture, framew // Validate output validate(CLAccessor(_target), _reference); } -TEST_SUITE_END() // S16 +TEST_SUITE_END() TEST_SUITE(Float) TEST_SUITE(FP16) @@ -216,7 +217,7 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionFixture, framework // Validate output validate(CLAccessor(_target), _reference); } -TEST_SUITE_END() // FP16 +TEST_SUITE_END() TEST_SUITE(FP32) DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), @@ -228,15 +229,15 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::da CLTensor dst = create_tensor(shape, DataType::F32); // Create and Configure function - CLArithmeticSubtraction sub; - sub.configure(&ref_src1, &ref_src2, &dst, policy); + CLArithmeticSubtraction add; + add.configure(&ref_src1, &ref_src2, &dst, policy); // Validate valid region const ValidRegion valid_region = shape_to_valid_region(shape); validate(dst.info()->valid_region(), valid_region); // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); validate(ref_src1.info()->padding(), padding); validate(ref_src2.info()->padding(), padding); validate(dst.info()->padding(), padding); @@ -274,11 +275,11 @@ FIXTURE_DATA_TEST_CASE(RunLargeBroadcast, CLArithmeticSubtractionBroadcastFixtur // Validate output validate(CLAccessor(_target), _reference); } -TEST_SUITE_END() // FP32 -TEST_SUITE_END() // Float +TEST_SUITE_END() +TEST_SUITE_END() -TEST_SUITE_END() // ArithmeticSubtraction -TEST_SUITE_END() // CL +TEST_SUITE_END() +TEST_SUITE_END() } // namespace validation } // namespace test -} // namespace arm_compute \ No newline at end of file +} // namespace arm_compute -- cgit v1.2.1