From a7a5b7b2ee6adcfe86339a402f287c4d0d368659 Mon Sep 17 00:00:00 2001 From: Sanghoon Lee Date: Thu, 14 Sep 2017 12:11:03 +0100 Subject: COMPMID-508: Port TableLookup to new validation Change-Id: I9e1a683afd64c351252617ba52131ca1ee829933 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/87698 Reviewed-by: Moritz Pflanzer Reviewed-by: Pablo Tello Tested-by: Kaizen --- tests/CL/CLLutAccessor.h | 2 +- tests/NEON/LutAccessor.h | 2 +- tests/validation/CL/ArithmeticAddition.cpp | 2 +- tests/validation/CL/TableLookup.cpp | 119 +++++++++++++ tests/validation/CPP/TableLookup.cpp | 54 ++++++ tests/validation/CPP/TableLookup.h | 44 +++++ tests/validation/Helpers.h | 17 ++ tests/validation/NEON/TableLookup.cpp | 118 +++++++++++++ tests/validation/fixtures/TableLookupFixture.h | 122 +++++++++++++ tests/validation_old/CL/TableLookup.cpp | 229 ------------------------- tests/validation_old/NEON/TableLookup.cpp | 229 ------------------------- tests/validation_old/Reference.cpp | 17 -- tests/validation_old/Reference.h | 10 -- tests/validation_old/ReferenceCPP.cpp | 13 -- tests/validation_old/ReferenceCPP.h | 8 - tests/validation_old/TensorOperations.h | 10 -- tests/validation_old/TensorVisitors.h | 23 --- 17 files changed, 477 insertions(+), 542 deletions(-) create mode 100644 tests/validation/CL/TableLookup.cpp create mode 100644 tests/validation/CPP/TableLookup.cpp create mode 100644 tests/validation/CPP/TableLookup.h create mode 100644 tests/validation/NEON/TableLookup.cpp create mode 100644 tests/validation/fixtures/TableLookupFixture.h delete mode 100644 tests/validation_old/CL/TableLookup.cpp delete mode 100644 tests/validation_old/NEON/TableLookup.cpp diff --git a/tests/CL/CLLutAccessor.h b/tests/CL/CLLutAccessor.h index 3877b1fe57..aa0285845d 100644 --- a/tests/CL/CLLutAccessor.h +++ b/tests/CL/CLLutAccessor.h @@ -24,7 +24,7 @@ #ifndef __ARM_COMPUTE_TEST_CL_CLLUTACCESSOR_H__ #define __ARM_COMPUTE_TEST_CL_CLLUTACCESSOR_H__ -#include "ILutAccessor.h" +#include "tests/ILutAccessor.h" #include "arm_compute/runtime/CL/CLLut.h" diff --git a/tests/NEON/LutAccessor.h b/tests/NEON/LutAccessor.h index 24ad63d84b..388e036edb 100644 --- a/tests/NEON/LutAccessor.h +++ b/tests/NEON/LutAccessor.h @@ -24,7 +24,7 @@ #ifndef __ARM_COMPUTE_TEST_NEON_LUTACCESSOR_H__ #define __ARM_COMPUTE_TEST_NEON_LUTACCESSOR_H__ -#include "ILutAccessor.h" +#include "tests/ILutAccessor.h" #include "arm_compute/runtime/Lut.h" diff --git a/tests/validation/CL/ArithmeticAddition.cpp b/tests/validation/CL/ArithmeticAddition.cpp index 5089ecabcf..51257b4b88 100644 --- a/tests/validation/CL/ArithmeticAddition.cpp +++ b/tests/validation/CL/ArithmeticAddition.cpp @@ -18,7 +18,7 @@ * 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 CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include "arm_compute/core/Types.h" diff --git a/tests/validation/CL/TableLookup.cpp b/tests/validation/CL/TableLookup.cpp new file mode 100644 index 0000000000..c2b2386492 --- /dev/null +++ b/tests/validation/CL/TableLookup.cpp @@ -0,0 +1,119 @@ +/* + * 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 "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/CLTableLookup.h" + +#include "tests/CL/CLAccessor.h" +#include "tests/CL/CLLutAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +#include "tests/validation/Helpers.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/TableLookupFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(CL) +TEST_SUITE(TableLookup) + +template +using CLTableLookupFixture = TableLookupValidationFixture, CLLut, T>; +TEST_SUITE(U8) +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })), + shape, data_type) +{ + // Create Lut + const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; + CLLut cllut(num_elem, data_type); + + switch(data_type) + { + case DataType::U8: + fill_lookuptable(CLLutAccessor(cllut)); + break; + case DataType::S16: + fill_lookuptable(CLLutAccessor(cllut)); + break; + default: + ARM_COMPUTE_ERROR("Not supported"); + } + + // Create tensors + CLTensor src = create_tensor(shape, data_type); + CLTensor dst = create_tensor(shape, data_type); + + // Create and Configure function + CLTableLookup table_lookup; + table_lookup.configure(&src, &cllut, &dst); + + // 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(), 8).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} +FIXTURE_DATA_TEST_CASE(RunSmallU8, CLTableLookupFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLargeU8, CLTableLookupFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::U8))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +TEST_SUITE_END() + +TEST_SUITE(S16) +FIXTURE_DATA_TEST_CASE(RunSmallS16, CLTableLookupFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::S16))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLargeS16, CLTableLookupFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::S16))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/TableLookup.cpp b/tests/validation/CPP/TableLookup.cpp new file mode 100644 index 0000000000..7f105d99ca --- /dev/null +++ b/tests/validation/CPP/TableLookup.cpp @@ -0,0 +1,54 @@ +/* + * 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 "TableLookup.h" + +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor table_lookup(const SimpleTensor &src, const std::map &rawlut) +{ + SimpleTensor result(src.shape(), src.data_type()); + + for(int i = 0; i < src.num_elements(); ++i) + { + result[i] = rawlut.at(src[i]); + } + + return result; +} + +template SimpleTensor table_lookup(const SimpleTensor &src, const std::map &rawlut); +template SimpleTensor table_lookup(const SimpleTensor &src, const std::map &rawlut); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/TableLookup.h b/tests/validation/CPP/TableLookup.h new file mode 100644 index 0000000000..3fdecac660 --- /dev/null +++ b/tests/validation/CPP/TableLookup.h @@ -0,0 +1,44 @@ +/* + * 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. + */ +#ifndef __ARM_COMPUTE_TEST_TABLE_LOOKUP_H__ +#define __ARM_COMPUTE_TEST_TABLE_LOOKUP_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor table_lookup(const SimpleTensor &src, const std::map &rawlut); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_TABLE_LOOKUP_H__ */ diff --git a/tests/validation/Helpers.h b/tests/validation/Helpers.h index 7043f1ebdc..85002eb599 100644 --- a/tests/validation/Helpers.h +++ b/tests/validation/Helpers.h @@ -185,6 +185,23 @@ inline void fill_mask_from_pattern(uint8_t *mask, int cols, int rows, MatrixPatt * @return The shape of output concatenated tensor. */ TensorShape calculate_depth_concatenate_shape(const std::vector &input_shapes); + +/** Helper function to fill the Lut random by a ILutAccessor. + * + * @param[in,out] table Accessor at the Lut. + * + */ +template +void fill_lookuptable(T &&table) +{ + std::mt19937 generator(library->seed()); + std::uniform_int_distribution distribution(std::numeric_limits::min(), std::numeric_limits::max()); + + for(int i = std::numeric_limits::min(); i <= std::numeric_limits::max(); i++) + { + table[i] = distribution(generator); + } +} } // namespace validation } // namespace test } // namespace arm_compute diff --git a/tests/validation/NEON/TableLookup.cpp b/tests/validation/NEON/TableLookup.cpp new file mode 100644 index 0000000000..8a9e05a96d --- /dev/null +++ b/tests/validation/NEON/TableLookup.cpp @@ -0,0 +1,118 @@ +/* + * 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 "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NETableLookup.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/NEON/Accessor.h" +#include "tests/NEON/LutAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +#include "tests/validation/Helpers.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/TableLookupFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(NEON) +TEST_SUITE(TableLookup) + +template +using NETableLookupFixture = TableLookupValidationFixture, Lut, T>; +TEST_SUITE(U8) +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })), + shape, data_type) +{ + // Create Lut + const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; + Lut lut(num_elem, data_type); + + switch(data_type) + { + case DataType::U8: + fill_lookuptable(LutAccessor(lut)); + break; + case DataType::S16: + fill_lookuptable(LutAccessor(lut)); + break; + default: + ARM_COMPUTE_ERROR("Not supported"); + } + + // Create tensors + Tensor src = create_tensor(shape, data_type); + Tensor dst = create_tensor(shape, data_type); + + // Create and Configure function + NETableLookup table_lookup; + table_lookup.configure(&src, &lut, &dst); + + // 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(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} +FIXTURE_DATA_TEST_CASE(RunSmallU8, NETableLookupFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLargeU8, NETableLookupFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::U8))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +TEST_SUITE_END() + +TEST_SUITE(S16) +FIXTURE_DATA_TEST_CASE(RunSmallS16, NETableLookupFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::S16))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLargeS16, NETableLookupFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::S16))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/fixtures/TableLookupFixture.h b/tests/validation/fixtures/TableLookupFixture.h new file mode 100644 index 0000000000..49e0f413ce --- /dev/null +++ b/tests/validation/fixtures/TableLookupFixture.h @@ -0,0 +1,122 @@ +/* + * 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. + */ +#ifndef ARM_COMPUTE_TEST_TABLE_LOOKUP_FIXTURE +#define ARM_COMPUTE_TEST_TABLE_LOOKUP_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/RawLutAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/TableLookup.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class TableLookupValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type) + { + _target = compute_target(shape, data_type); + _reference = compute_reference(shape, data_type); + } + +protected: + template + void fill(U &&tensor, int i) + { + library->fill_tensor_uniform(tensor, i); + } + + TensorType compute_target(const TensorShape &shape, DataType data_type) + { + // Create Lut + const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; + LutType lut(num_elem, data_type); + + //Fill the Lut + fill_lookuptable(LutAccessorType(lut)); + + // Create tensors + TensorType src = create_tensor(shape, data_type); + TensorType dst = create_tensor(shape, data_type); + + // Create and configure function + FunctionType table_lookup; + table_lookup.configure(&src, &lut, &dst); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src), 0); + fill(AccessorType(dst), 1); + + // Compute function + table_lookup.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) + { + // Create rawLut + std::map rawlut; + + // Fill the Lut + fill_lookuptable(RawLutAccessor(rawlut)); + + // Create reference + SimpleTensor src{ shape, data_type }; + + // Fill reference + fill(src, 0); + + return reference::table_lookup(src, rawlut); + } + + TensorType _target{}; + SimpleTensor _reference{}; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_TABLE_LOOKUP_FIXTURE */ diff --git a/tests/validation_old/CL/TableLookup.cpp b/tests/validation_old/CL/TableLookup.cpp deleted file mode 100644 index 26c38689f0..0000000000 --- a/tests/validation_old/CL/TableLookup.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* - * 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 "CL/CLAccessor.h" -#include "CL/CLLutAccessor.h" -#include "PaddingCalculator.h" -#include "RawLutAccessor.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/validation_old/Datasets.h" -#include "tests/validation_old/Helpers.h" -#include "tests/validation_old/Reference.h" -#include "tests/validation_old/Validation.h" - -#include "arm_compute/core/Helpers.h" -#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/CLTableLookup.h" - -#include "tests/validation_old/boost_wrapper.h" - -#include -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Table Lookup function. - * - * @param[in] shape Shape of the input tensors - * @param[in] data_type Type of the input/output tensor - * @param[in] lut The input LUT. - * - * @return Computed output cl tensor. - */ -CLTensor compute_table_lookup(const TensorShape &shape, DataType data_type, CLLut &lut) -{ - // Create tensors - CLTensor src = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); - - // Create and configure function - CLTableLookup table_lookup; - table_lookup.configure(&src, &lut, &dst); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - table_lookup.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(TableLookup) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, data_type) -{ - //Create Lut - const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; - CLLut cllut(num_elem, data_type); - - if(data_type == DataType::U8) - { - fill_lookuptable(CLLutAccessor(cllut)); - } - else - { - fill_lookuptable(CLLutAccessor(cllut)); - } - - // Create tensors - CLTensor src = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - CLTableLookup table_lookup; - table_lookup.configure(&src, &cllut, &dst); - - // 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); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 8).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, - SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, data_type) -{ - //Create Lut - const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; - CLLut cllut(num_elem, data_type); - - if(data_type == DataType::U8) - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(CLLutAccessor(cllut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - CLTensor dst = compute_table_lookup(shape, data_type, cllut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(CLAccessor(dst), ref_dst); - } - else - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(CLLutAccessor(cllut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - CLTensor dst = compute_table_lookup(shape, data_type, cllut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(CLAccessor(dst), ref_dst); - } -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, - LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, data_type) -{ - //Create Lut - const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; - CLLut cllut(num_elem, data_type); - - if(data_type == DataType::U8) - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(CLLutAccessor(cllut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - CLTensor dst = compute_table_lookup(shape, data_type, cllut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(CLAccessor(dst), ref_dst); - } - else - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(CLLutAccessor(cllut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - CLTensor dst = compute_table_lookup(shape, data_type, cllut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(CLAccessor(dst), ref_dst); - } -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/TableLookup.cpp b/tests/validation_old/NEON/TableLookup.cpp deleted file mode 100644 index f134e5d417..0000000000 --- a/tests/validation_old/NEON/TableLookup.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* - * 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 "NEON/Accessor.h" -#include "NEON/Helper.h" -#include "NEON/LutAccessor.h" -#include "PaddingCalculator.h" -#include "RawLutAccessor.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/validation_old/Datasets.h" -#include "tests/validation_old/Helpers.h" -#include "tests/validation_old/Reference.h" -#include "tests/validation_old/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NETableLookup.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "tests/validation_old/boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Table Lookup function. - * - * @param[in] shape Shape of the input tensors - * @param[in] data_type Datatype of the input/output tensors - * @param[in] lut The input LUT. - * - * @return Computed output tensor. - */ -Tensor compute_table_lookup(const TensorShape &shape, DataType data_type, Lut &lut) -{ - // Create tensors - Tensor src = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); - - // Create and configure function - NETableLookup table_lookup; - table_lookup.configure(&src, &lut, &dst); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - - // Compute function - table_lookup.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(TableLookup) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, data_type) -{ - //Create Lut - const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; - Lut lut(num_elem, data_type); - - if(data_type == DataType::U8) - { - fill_lookuptable(LutAccessor(lut)); - } - else - { - fill_lookuptable(LutAccessor(lut)); - } - - // Create tensors - Tensor src = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NETableLookup table_lookup; - table_lookup.configure(&src, &lut, &dst); - - // 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); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, - SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, data_type) -{ - //Create Lut - const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; - Lut lut(num_elem, data_type); - - if(data_type == DataType::U8) - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(LutAccessor(lut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - Tensor dst = compute_table_lookup(shape, data_type, lut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(Accessor(dst), ref_dst); - } - else - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(LutAccessor(lut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - Tensor dst = compute_table_lookup(shape, data_type, lut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(Accessor(dst), ref_dst); - } -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, - LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, data_type) -{ - //Create Lut - const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; - Lut lut(num_elem, data_type); - - if(data_type == DataType::U8) - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(LutAccessor(lut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - Tensor dst = compute_table_lookup(shape, data_type, lut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(Accessor(dst), ref_dst); - } - else - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(LutAccessor(lut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - Tensor dst = compute_table_lookup(shape, data_type, lut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(Accessor(dst), ref_dst); - } -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/Reference.cpp b/tests/validation_old/Reference.cpp index b8564dbb03..6a52cd016f 100644 --- a/tests/validation_old/Reference.cpp +++ b/tests/validation_old/Reference.cpp @@ -253,23 +253,6 @@ RawTensor Reference::compute_reference_fixed_point_pixel_wise_multiplication(con return ref_dst; } -template -RawTensor Reference::compute_reference_table_lookup(const TensorShape &shape, DataType dt_inout, std::map &lut) -{ - // Create reference - RawTensor ref_src(shape, dt_inout); - RawTensor ref_dst(shape, dt_inout); - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::table_lookup(ref_src, ref_dst, lut); - - return ref_dst; -} -template RawTensor arm_compute::test::validation::Reference::compute_reference_table_lookup(const TensorShape &shape, DataType dt_inout, std::map &lut); -template RawTensor arm_compute::test::validation::Reference::compute_reference_table_lookup(const TensorShape &shape, DataType dt_inout, std::map &lut); - RawTensor Reference::compute_reference_threshold(const TensorShape &shape, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) { // Create reference diff --git a/tests/validation_old/Reference.h b/tests/validation_old/Reference.h index b3f35ce43a..9c7baacbf6 100644 --- a/tests/validation_old/Reference.h +++ b/tests/validation_old/Reference.h @@ -177,16 +177,6 @@ public: */ static RawTensor compute_reference_fixed_point_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, int fixed_point_position, ConvertPolicy convert_policy, RoundingPolicy rounding_policy); - /** Compute reference Table Lookup. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_inout Data type of input/output tensor. - * @param[in] lut Input lookup table. - * - * @return Computed raw tensor. - */ - template - static RawTensor compute_reference_table_lookup(const TensorShape &shape, DataType dt_inout, std::map &lut); /** Compute reference threshold. * * @param[in] shape Shape of the input and output tensors. diff --git a/tests/validation_old/ReferenceCPP.cpp b/tests/validation_old/ReferenceCPP.cpp index 2f59103f95..86dc589bb1 100644 --- a/tests/validation_old/ReferenceCPP.cpp +++ b/tests/validation_old/ReferenceCPP.cpp @@ -193,19 +193,6 @@ void ReferenceCPP::fixed_point_pixel_wise_multiplication(const RawTensor &src1, boost::apply_visitor(tensor_visitors::fixed_point_pixel_wise_multiplication_visitor(s1, s2, scale, convert_policy, rounding_policy), d); } -// Table lookup -template -void ReferenceCPP::table_lookup(const RawTensor &src, RawTensor &dst, std::map &lut) -{ - const TensorVariant s = TensorFactory::get_tensor(src); - TensorVariant d = TensorFactory::get_tensor(dst); - boost::apply_visitor(tensor_visitors::table_lookup(s, lut), d); -} -#ifndef DOXYGEN_SKIP_THIS -template void arm_compute::test::validation::ReferenceCPP::table_lookup(const RawTensor &src, RawTensor &dst, std::map &lut); -template void arm_compute::test::validation::ReferenceCPP::table_lookup(const RawTensor &src, RawTensor &dst, std::map &lut); -#endif /* DOXYGEN_SKIP_THIS */ - // Threshold void ReferenceCPP::threshold(const RawTensor &src, RawTensor &dst, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) { diff --git a/tests/validation_old/ReferenceCPP.h b/tests/validation_old/ReferenceCPP.h index 851f34b236..5bc10a512f 100644 --- a/tests/validation_old/ReferenceCPP.h +++ b/tests/validation_old/ReferenceCPP.h @@ -176,14 +176,6 @@ public: * @param[in] rounding_policy Rounding policy. */ static void fixed_point_pixel_wise_multiplication(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy); - /** Table Lookup f@p src to @p dst - * - * @param[in] src Input tensor. - * @param[out] dst Result tensor. - * @param[in] lut Input lookup table. - */ - template - static void table_lookup(const RawTensor &src, RawTensor &dst, std::map &lut); /** Threshold of@p src to @p dst * * @param[in] src Input tensor. diff --git a/tests/validation_old/TensorOperations.h b/tests/validation_old/TensorOperations.h index 73e7661a1c..0c1ab4134e 100644 --- a/tests/validation_old/TensorOperations.h +++ b/tests/validation_old/TensorOperations.h @@ -740,16 +740,6 @@ void fixed_point_pixel_wise_multiplication(const Tensor &in1, const Tensor } } -//Table Lookup -template -void table_lookup(const Tensor &in, Tensor &out, std::map &lut) -{ - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = static_cast(lut[in[i]]); - } -} - // Threshold template void threshold(const Tensor &in, Tensor &out, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) diff --git a/tests/validation_old/TensorVisitors.h b/tests/validation_old/TensorVisitors.h index 7d67dca5a5..dafbfe0235 100644 --- a/tests/validation_old/TensorVisitors.h +++ b/tests/validation_old/TensorVisitors.h @@ -127,29 +127,6 @@ private: ConvertPolicy _convert_policy; RoundingPolicy _rounding_policy; }; -// Table lookup operation -template -struct table_lookup : public boost::static_visitor<> -{ -public: - explicit table_lookup(const TensorVariant &in, std::map &lut) - : _in(in), _lut(lut) - { - } - - template - void operator()(Tensor &out) const - { - const auto &in = boost::get>(_in); - tensor_operations::table_lookup(in, out, _lut); - } - -private: - const TensorVariant &_in; - std::map &_lut; -}; -template struct arm_compute::test::validation::tensor_visitors::table_lookup; -template struct arm_compute::test::validation::tensor_visitors::table_lookup; // Batch Normalization Layer visitor struct batch_normalization_layer_visitor : public boost::static_visitor<> -- cgit v1.2.1