diff options
Diffstat (limited to 'tests/validation/UNIT')
-rw-r--r-- | tests/validation/UNIT/CPPScheduler.cpp | 91 | ||||
-rw-r--r-- | tests/validation/UNIT/GPUTarget.cpp | 24 | ||||
-rw-r--r-- | tests/validation/UNIT/LifetimeManager.cpp | 2 | ||||
-rw-r--r-- | tests/validation/UNIT/SafeIntegerOps.cpp | 3 | ||||
-rw-r--r-- | tests/validation/UNIT/SubTensorInfo.cpp | 113 | ||||
-rw-r--r-- | tests/validation/UNIT/TensorInfo.cpp | 17 | ||||
-rw-r--r-- | tests/validation/UNIT/TensorShape.cpp | 2 | ||||
-rw-r--r-- | tests/validation/UNIT/Utils.cpp | 2 | ||||
-rw-r--r-- | tests/validation/UNIT/Version.cpp | 47 | ||||
-rw-r--r-- | tests/validation/UNIT/WindowIterator.cpp | 2 |
10 files changed, 286 insertions, 17 deletions
diff --git a/tests/validation/UNIT/CPPScheduler.cpp b/tests/validation/UNIT/CPPScheduler.cpp new file mode 100644 index 0000000000..6a3f6819fc --- /dev/null +++ b/tests/validation/UNIT/CPPScheduler.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2023-2024 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/runtime/CPP/CPPScheduler.h" + +#include "arm_compute/core/CPP/ICPPKernel.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" + +#include <stdexcept> + +using namespace arm_compute; +using namespace arm_compute::test; + +namespace +{ +class TestException: public std::exception +{ +public: + const char* what() const noexcept override + { + return "Expected test exception"; + } +}; + +class TestKernel: public ICPPKernel +{ +public: + TestKernel() + { + Window window; + window.set(0, Window::Dimension(0, 2)); + configure(window); + } + + const char* name() const override + { + return "TestKernel"; + } + + void run(const Window &, const ThreadInfo &) override + { + throw TestException(); + } + +}; +} + +TEST_SUITE(UNIT) +TEST_SUITE(CPPScheduler) +#if defined(ARM_COMPUTE_CPP_SCHEDULER) && !defined(BARE_METAL) +TEST_CASE(RethrowException, framework::DatasetMode::ALL) +{ + CPPScheduler scheduler; + CPPScheduler::Hints hints(0); + TestKernel kernel; + + scheduler.set_num_threads(2); + try + { + scheduler.schedule(&kernel, hints); + } + catch(const TestException&) + { + return; + } + ARM_COMPUTE_EXPECT_FAIL("Expected exception not caught", framework::LogLevel::ERRORS); +} +#endif // defined(ARM_COMPUTE_CPP_SCHEDULER) && !defined(BARE_METAL) +TEST_SUITE_END() +TEST_SUITE_END() diff --git a/tests/validation/UNIT/GPUTarget.cpp b/tests/validation/UNIT/GPUTarget.cpp index c9d78661de..2e64635b7a 100644 --- a/tests/validation/UNIT/GPUTarget.cpp +++ b/tests/validation/UNIT/GPUTarget.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 ARM Limited. + * Copyright (c) 2018-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -22,7 +22,6 @@ * SOFTWARE. */ #include "arm_compute/core/GPUTarget.h" -#include "tests/AssetsLibrary.h" #include "tests/Globals.h" #include "tests/Utils.h" #include "tests/framework/Asserts.h" @@ -38,6 +37,7 @@ TEST_SUITE(GPUTarget) TEST_CASE(GetGPUTargetFromName, framework::DatasetMode::ALL) { + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-T000") == GPUTarget::MIDGARD, framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(get_target_from_name("Mali-T600") == GPUTarget::T600, framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(get_target_from_name("Mali-T700") == GPUTarget::T700, framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(get_target_from_name("Mali-T800") == GPUTarget::T800, framework::LogLevel::ERRORS); @@ -46,14 +46,24 @@ TEST_CASE(GetGPUTargetFromName, framework::DatasetMode::ALL) ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G51") == GPUTarget::G51, framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G51BIG") == GPUTarget::G51BIG, framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G51LIT") == GPUTarget::G51LIT, framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G52") == GPUTarget::G52, framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G52LIT") == GPUTarget::G52LIT, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G31") == GPUTarget::G31, framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G76") == GPUTarget::G76, framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G76 r0p0") == GPUTarget::G76, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G52") == GPUTarget::G52, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G52LIT") == GPUTarget::G52LIT, framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G77") == GPUTarget::G77, framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(get_target_from_name("Mali-TBOX") == GPUTarget::TBOX, framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(get_target_from_name("Mali-TODX") == GPUTarget::TODX, framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(get_target_from_name("Mali-T000") == GPUTarget::MIDGARD, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G57") == GPUTarget::G57, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G78") == GPUTarget::G78, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G68") == GPUTarget::G68, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G78AE") == GPUTarget::G78AE, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G710") == GPUTarget::G710, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G610") == GPUTarget::G610, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G510") == GPUTarget::G510, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G310") == GPUTarget::G310, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G715") == GPUTarget::G715, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G615") == GPUTarget::G615, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G720") == GPUTarget::G720, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(get_target_from_name("Mali-G620") == GPUTarget::G620, framework::LogLevel::ERRORS); } TEST_CASE(GPUTargetIsIn, framework::DatasetMode::ALL) diff --git a/tests/validation/UNIT/LifetimeManager.cpp b/tests/validation/UNIT/LifetimeManager.cpp index 44a52aa5e3..5345cba4c2 100644 --- a/tests/validation/UNIT/LifetimeManager.cpp +++ b/tests/validation/UNIT/LifetimeManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 ARM Limited. + * Copyright (c) 2019 Arm Limited. * * SPDX-License-Identifier: MIT * diff --git a/tests/validation/UNIT/SafeIntegerOps.cpp b/tests/validation/UNIT/SafeIntegerOps.cpp index e721c48aad..13e4ef5125 100644 --- a/tests/validation/UNIT/SafeIntegerOps.cpp +++ b/tests/validation/UNIT/SafeIntegerOps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020 ARM Limited. + * Copyright (c) 2019-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -23,7 +23,6 @@ */ #include "arm_compute/core/GPUTarget.h" #include "arm_compute/core/utils/math/SafeOps.h" -#include "tests/AssetsLibrary.h" #include "tests/Globals.h" #include "tests/Utils.h" #include "tests/framework/Asserts.h" diff --git a/tests/validation/UNIT/SubTensorInfo.cpp b/tests/validation/UNIT/SubTensorInfo.cpp new file mode 100644 index 0000000000..ca5e46550c --- /dev/null +++ b/tests/validation/UNIT/SubTensorInfo.cpp @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2020-2023 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/SubTensorInfo.h" +#include "arm_compute/core/TensorInfo.h" +#include "arm_compute/core/Types.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/validation/Validation.h" +#include "utils/TypePrinter.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(UNIT) +TEST_SUITE(SubTensorInfo) + +/** Validate sub-tensor creation + * + * Test performed: + * + * - Negative testing on X indexing + * - Negative testing on Y indexing + * - Positive testing by indexing on X,Y indexing + * */ +TEST_CASE(SubTensorCreation, framework::DatasetMode::ALL) +{ + // Create tensor info + TensorInfo info(TensorShape(23U, 17U, 3U), 1, DataType::F32); + + // Negative testing on X + ARM_COMPUTE_EXPECT_THROW(SubTensorInfo(&info, TensorShape(13U, 17U, 3U), Coordinates(24, 0, 0)), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT_THROW(SubTensorInfo(&info, TensorShape(13U, 17U, 3U), Coordinates(15, 0, 0)), framework::LogLevel::ERRORS); + + // Negative testing on Y + ARM_COMPUTE_EXPECT_THROW(SubTensorInfo(&info, TensorShape(23U, 8U, 3U), Coordinates(0, 18, 0)), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT_THROW(SubTensorInfo(&info, TensorShape(23U, 8U, 3U), Coordinates(0, 13, 0)), framework::LogLevel::ERRORS); + + // Positive testing on XY indexing + ARM_COMPUTE_EXPECT_NO_THROW(SubTensorInfo(&info, TensorShape(4U, 3U, 2U), Coordinates(5, 2, 1)), framework::LogLevel::ERRORS); +} + +/** Validate when extending padding on sub-tensor + * + * Tests performed: + * - A) Extend padding when SubTensor XY does not match parent tensor should fail + * B) Extend with zero padding when SubTensor XY does not match parent tensor should succeed + * - C) Extend padding when SubTensor XY matches parent tensor should succeed + * - D) Set lock padding to true, so that extend padding would fail + */ +TEST_CASE(SubTensorPaddingExpansion, framework::DatasetMode::ALL) +{ + // Test A + { + TensorInfo tensor_info(TensorShape(23U, 17U, 3U), 1, DataType::F32); + SubTensorInfo sub_tensor_info(&tensor_info, TensorShape(4U, 3U, 2U), Coordinates(5, 2, 1)); + ARM_COMPUTE_EXPECT_THROW(sub_tensor_info.extend_padding(PaddingSize(2, 1)), framework::LogLevel::ERRORS); + } + + // Test B + { + TensorInfo tensor_info(TensorShape(23U, 17U, 3U), 1, DataType::F32); + SubTensorInfo sub_tensor_info(&tensor_info, TensorShape(4U, 3U, 1U), Coordinates(5, 2, 1)); + ARM_COMPUTE_EXPECT_NO_THROW(sub_tensor_info.extend_padding(PaddingSize(0, 0)), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(tensor_info.padding().uniform(), framework::LogLevel::ERRORS); + } + + // Test C + { + TensorInfo tensor_info(TensorShape(23U, 17U, 3U), 1, DataType::F32); + SubTensorInfo sub_tensor_info(&tensor_info, TensorShape(23U, 17U, 1U), Coordinates(0, 0, 1)); + ARM_COMPUTE_EXPECT_NO_THROW(sub_tensor_info.extend_padding(PaddingSize(2, 1)), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(tensor_info.padding().top == 2, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(tensor_info.padding().right == 1, framework::LogLevel::ERRORS); + } + + // Test D + { + TensorInfo tensor_info(TensorShape(23U, 17U, 3U), 1, DataType::F32); + SubTensorInfo sub_tensor_info(&tensor_info, TensorShape(4U, 3U, 1U), Coordinates(5, 2, 1)); + sub_tensor_info.set_lock_paddings(true); + ARM_COMPUTE_EXPECT_THROW(sub_tensor_info.extend_padding(PaddingSize(2, 1)), framework::LogLevel::ERRORS); + } +} + +TEST_SUITE_END() // SubTensorInfo +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/UNIT/TensorInfo.cpp b/tests/validation/UNIT/TensorInfo.cpp index 009c757925..b79c1e9253 100644 --- a/tests/validation/UNIT/TensorInfo.cpp +++ b/tests/validation/UNIT/TensorInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -93,7 +93,7 @@ TEST_CASE(Clone, framework::DatasetMode::ALL) // Get clone of current tensor info std::unique_ptr<ITensorInfo> info_clone = info.clone(); - ARM_COMPUTE_EXPECT(info_clone != nullptr, framework::LogLevel::ERRORS); + ARM_COMPUTE_ASSERT(info_clone != nullptr); ARM_COMPUTE_EXPECT(info_clone->total_size() == info.total_size(), framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(info_clone->num_channels() == info.num_channels(), framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(info_clone->data_type() == info.data_type(), framework::LogLevel::ERRORS); @@ -184,8 +184,17 @@ TEST_CASE(SymmPerChannelQuantizationInfo, framework::DatasetMode::ALL) ARM_COMPUTE_EXPECT(info.quantization_info().offset().empty(), framework::LogLevel::ERRORS); } -TEST_SUITE_END() // TensorInfoValidation -TEST_SUITE_END() +/** Validates lock paddings flag*/ +TEST_CASE(SubTensorPaddingExpansion, framework::DatasetMode::ALL) +{ + TensorInfo tensor_info(TensorShape(23U, 17U, 3U), 1, DataType::F32); + tensor_info.set_lock_paddings(true); + + // Now lock padding is set to true, therefore the extend padding would fail + ARM_COMPUTE_EXPECT_THROW(tensor_info.extend_padding(PaddingSize(2, 1)), framework::LogLevel::ERRORS); +} +TEST_SUITE_END() // TensorInfo +TEST_SUITE_END() // UNIT } // namespace validation } // namespace test } // namespace arm_compute diff --git a/tests/validation/UNIT/TensorShape.cpp b/tests/validation/UNIT/TensorShape.cpp index 31f95e3f8c..ebe9b32e9d 100644 --- a/tests/validation/UNIT/TensorShape.cpp +++ b/tests/validation/UNIT/TensorShape.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017 Arm Limited. * * SPDX-License-Identifier: MIT * diff --git a/tests/validation/UNIT/Utils.cpp b/tests/validation/UNIT/Utils.cpp index 3980674170..9309278d0a 100644 --- a/tests/validation/UNIT/Utils.cpp +++ b/tests/validation/UNIT/Utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2018 Arm Limited. * * SPDX-License-Identifier: MIT * diff --git a/tests/validation/UNIT/Version.cpp b/tests/validation/UNIT/Version.cpp new file mode 100644 index 0000000000..72e2d48113 --- /dev/null +++ b/tests/validation/UNIT/Version.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021 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/AclVersion.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/validation/Validation.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(UNIT) +TEST_CASE(Version, framework::DatasetMode::ALL) +{ + const auto ver = AclVersionInfo(); + ARM_COMPUTE_EXPECT(ver->major == ARM_COMPUTE_LIBRARY_VERSION_MAJOR, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(ver->minor == ARM_COMPUTE_LIBRARY_VERSION_MINOR, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(ver->patch == ARM_COMPUTE_LIBRARY_VERSION_PATCH, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!std::string(ver->build_info).empty(), framework::LogLevel::ERRORS); +} +TEST_SUITE_END() // UNIT +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/UNIT/WindowIterator.cpp b/tests/validation/UNIT/WindowIterator.cpp index 402cab4990..4430299f5a 100644 --- a/tests/validation/UNIT/WindowIterator.cpp +++ b/tests/validation/UNIT/WindowIterator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2018 Arm Limited. * * SPDX-License-Identifier: MIT * |