aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/CL/UNIT/DynamicTensor.cpp
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2019-09-19 12:09:32 +0100
committerGeorgios Pinitas <georgios.pinitas@arm.com>2019-09-24 01:35:57 +0000
commitb785dd4a4e1e662630f4d79e0f578513958a71fd (patch)
tree6a8becbd7e4390f7876da3f10e70f5bb6ff8e7a8 /tests/validation/CL/UNIT/DynamicTensor.cpp
parentee6454a3dfc5d9e921689f0b60cfa15ad4ef6654 (diff)
downloadComputeLibrary-b785dd4a4e1e662630f4d79e0f578513958a71fd.tar.gz
COMPMID-2670: [CL/GC] Create a test case for dynamic tensor support
Change-Id: I35d28786ee3843ac11c1211aea55328782a99382 Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com> Reviewed-on: https://review.mlplatform.org/c/1958 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation/CL/UNIT/DynamicTensor.cpp')
-rw-r--r--tests/validation/CL/UNIT/DynamicTensor.cpp105
1 files changed, 105 insertions, 0 deletions
diff --git a/tests/validation/CL/UNIT/DynamicTensor.cpp b/tests/validation/CL/UNIT/DynamicTensor.cpp
new file mode 100644
index 0000000000..38acbd5c3a
--- /dev/null
+++ b/tests/validation/CL/UNIT/DynamicTensor.cpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2019 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/BlobLifetimeManager.h"
+#include "arm_compute/runtime/CL/CLBufferAllocator.h"
+#include "arm_compute/runtime/CL/functions/CLL2NormalizeLayer.h"
+#include "arm_compute/runtime/MemoryGroup.h"
+#include "arm_compute/runtime/MemoryManagerOnDemand.h"
+#include "arm_compute/runtime/PoolManager.h"
+#include "support/ToolchainSupport.h"
+#include "tests/AssetsLibrary.h"
+#include "tests/CL/CLAccessor.h"
+#include "tests/Globals.h"
+#include "tests/Utils.h"
+#include "tests/framework/Asserts.h"
+#include "tests/framework/Macros.h"
+#include "tests/framework/datasets/Datasets.h"
+#include "tests/validation/fixtures/UNIT/DynamicTensorFixture.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace validation
+{
+namespace
+{
+using CLL2NormLayerWrapper = SimpleFunctionWrapper<MemoryManagerOnDemand, CLL2NormalizeLayer, ICLTensor>;
+template <>
+void CLL2NormLayerWrapper::configure(ICLTensor *src, ICLTensor *dst)
+{
+ _func.configure(src, dst, 0, 0.0001f);
+}
+} // namespace
+TEST_SUITE(CL)
+TEST_SUITE(UNIT)
+TEST_SUITE(DynamicTensor)
+
+using CLDynamicTensorType3SingleFunction = DynamicTensorType3SingleFunction<CLTensor, CLAccessor, CLBufferAllocator, BlobLifetimeManager, PoolManager, MemoryManagerOnDemand, CLL2NormLayerWrapper>;
+
+/** Tests the memory manager with dynamic input and output tensors.
+ *
+ * Create and manage the tensors needed to run a simple function. After the function is executed,
+ * change the input and output size requesting more memory and go through the manage/allocate process.
+ * The memory manager should be able to update the inner structures and allocate the requested memory
+ * */
+FIXTURE_DATA_TEST_CASE(DynamicTensorType3Single, CLDynamicTensorType3SingleFunction, framework::DatasetMode::ALL,
+ framework::dataset::zip(framework::dataset::make("Level0Shape", { TensorShape(12U, 11U, 3U), TensorShape(256U, 8U, 12U) }),
+ framework::dataset::make("Level1Shape", { TensorShape(67U, 31U, 15U), TensorShape(11U, 2U, 3U) })))
+{
+ ARM_COMPUTE_EXPECT(internal_l0.size() == internal_l1.size(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(cross_l0.size() == cross_l1.size(), framework::LogLevel::ERRORS);
+
+ const unsigned int internal_size = internal_l0.size();
+ const unsigned int cross_size = cross_l0.size();
+ if(input_l0.total_size() < input_l1.total_size())
+ {
+ for(unsigned int i = 0; i < internal_size; ++i)
+ {
+ ARM_COMPUTE_EXPECT(internal_l0[i].size < internal_l1[i].size, framework::LogLevel::ERRORS);
+ }
+ for(unsigned int i = 0; i < cross_size; ++i)
+ {
+ ARM_COMPUTE_EXPECT(cross_l0[i].size < cross_l1[i].size, framework::LogLevel::ERRORS);
+ }
+ }
+ else
+ {
+ for(unsigned int i = 0; i < internal_size; ++i)
+ {
+ ARM_COMPUTE_EXPECT(internal_l0[i].size == internal_l1[i].size, framework::LogLevel::ERRORS);
+ }
+ for(unsigned int i = 0; i < cross_size; ++i)
+ {
+ ARM_COMPUTE_EXPECT(cross_l0[i].size == cross_l1[i].size, framework::LogLevel::ERRORS);
+ }
+ }
+}
+
+TEST_SUITE_END() // DynamicTensor
+TEST_SUITE_END() // UNIT
+TEST_SUITE_END() // CL
+} // namespace validation
+} // namespace test
+} // namespace arm_compute