aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSang-Hoon Park <sang-hoon.park@arm.com>2021-03-11 15:29:19 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2021-03-16 16:54:44 +0000
commitd0c9cb808f674ce8bbfbdf0e66c5b8451f6af0f2 (patch)
treecd3786ed52b06b8dac24586059dc3d6782ec6abc /tests
parent10b3826723e1e2f62a4e635801128ddf4438e50c (diff)
downloadComputeLibrary-d0c9cb808f674ce8bbfbdf0e66c5b8451f6af0f2.tar.gz
Add test case for memory managed softmax layer
A test case for softmax layer with a given memory manager is added to test the scenario where the external caller owns the memory manager. Resolves: COMPMID-4298 Change-Id: If37ce72f7dad5901740bd32de9d70ea576caa2ae Signed-off-by: Sang-Hoon Park <sang-hoon.park@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5258 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/validation/CL/SoftmaxLayer.cpp49
1 files changed, 48 insertions, 1 deletions
diff --git a/tests/validation/CL/SoftmaxLayer.cpp b/tests/validation/CL/SoftmaxLayer.cpp
index 396e274e0b..eb47b7f666 100644
--- a/tests/validation/CL/SoftmaxLayer.cpp
+++ b/tests/validation/CL/SoftmaxLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Arm Limited.
+ * Copyright (c) 2017-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -34,6 +34,12 @@
#include "tests/validation/Validation.h"
#include "tests/validation/fixtures/SoftmaxLayerFixture.h"
+#include "arm_compute/runtime/MemoryManagerOnDemand.h"
+#include "arm_compute/runtime/PoolManager.h"
+#include "arm_compute/runtime/BlobLifetimeManager.h"
+#include "arm_compute/runtime/CL/CLBufferAllocator.h"
+#include "arm_compute/runtime/BlobMemoryPool.h"
+
namespace arm_compute
{
namespace test
@@ -62,6 +68,47 @@ const auto CNNDataTypes = framework::dataset::make("DataType",
TEST_SUITE(CL)
TEST_SUITE(SoftmaxLayer)
+TEST_CASE(SimpleMemoryManaged, framework::DatasetMode::ALL)
+{
+ // The purpose of this test is to test if the function can
+ // run correctly even with the given memory manager from its caller
+ // (Similar scenario when the library is integrated into other software)
+ // especially when working with workspace() method of
+ // @ref arm_compute::opencl::ClSoftmax.
+ const auto shape = TensorShape{4,2}; // Random shape, not important
+ constexpr auto dt = DataType::F32; // Random data type, not important
+
+ // Create a memory manager
+ auto lm = std::make_shared<BlobLifetimeManager>();
+ auto pm = std::make_shared<arm_compute::PoolManager>();
+ auto alloc = std::make_unique<CLBufferAllocator>();
+ auto mm = std::make_shared<MemoryManagerOnDemand>(lm, pm);
+
+ auto src = create_tensor<CLTensor>(shape, dt);
+ auto dst = create_tensor<CLTensor>(shape, dt);
+ src.allocator()->allocate();
+ dst.allocator()->allocate();
+
+ // Create the function with the memory manager
+ CLSoftmaxLayer smx(mm);
+ smx.configure(&src, &dst);
+
+ // Populate the memory, acquire() will happen in run()
+ mm->populate(*alloc.get(), 1);
+
+ std::vector<float> input_vals{0.0f, 1.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f,};
+ library->fill_static_values(CLAccessor(src), input_vals);
+
+ smx.run();
+
+ // Compute reference to compare
+ SimpleTensor<float> ref_src{shape, dt};
+ library->fill_static_values(ref_src, input_vals);
+ auto ref_dst = reference::softmax_layer<float>(ref_src, 1., 0, false);
+
+ validate(CLAccessor(dst), ref_dst);
+}
+
// *INDENT-OFF*
// clang-format off
DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(