aboutsummaryrefslogtreecommitdiff
path: root/tests/validation
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2019-06-17 17:46:17 +0100
committerGeorgios Pinitas <georgios.pinitas@arm.com>2019-06-24 14:27:42 +0000
commitdb09b3783ff9af67c6d373b12aa9a6aff3c5d0f1 (patch)
tree270aaba4e8e1553a32bc3e492f480fdbbaec3bd3 /tests/validation
parent3689fcd5915cd902cb4ea5f618f2a6e42f6dc4a1 (diff)
downloadComputeLibrary-db09b3783ff9af67c6d373b12aa9a6aff3c5d0f1.tar.gz
COMPMID-2392: Add documentation for import_memory interface
Change-Id: I943aefafe4131fc366d7ec336c9b94e89ce4fb8d Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com> Reviewed-on: https://review.mlplatform.org/c/1362 Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation')
-rw-r--r--tests/validation/NEON/UNIT/TensorAllocator.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/validation/NEON/UNIT/TensorAllocator.cpp b/tests/validation/NEON/UNIT/TensorAllocator.cpp
index 217933da48..4764bf63ca 100644
--- a/tests/validation/NEON/UNIT/TensorAllocator.cpp
+++ b/tests/validation/NEON/UNIT/TensorAllocator.cpp
@@ -142,6 +142,59 @@ TEST_CASE(ImportMemoryMalloc, framework::DatasetMode::ALL)
ARM_COMPUTE_EXPECT(tensor.info()->is_resizable(), framework::LogLevel::ERRORS);
}
+TEST_CASE(ImportMemoryMallocPadded, framework::DatasetMode::ALL)
+{
+ // Create tensor
+ Tensor tensor;
+ tensor.allocator()->init(TensorInfo(TensorShape(24U, 16U, 3U), 1, DataType::F32));
+
+ // Enforce tensor padding and validate that meta-data were updated
+ // Note: Padding might be updated after the function configuration in case of increased padding requirements
+ const PaddingSize enforced_padding(3U, 5U, 2U, 4U);
+ tensor.info()->extend_padding(enforced_padding);
+ validate(tensor.info()->padding(), enforced_padding);
+
+ // Create and configure activation function
+ NEActivationLayer act_func;
+ act_func.configure(&tensor, nullptr, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU));
+
+ // Allocate and import tensor
+ const size_t total_size_in_bytes = tensor.info()->total_size();
+ auto raw_data = support::cpp14::make_unique<uint8_t[]>(total_size_in_bytes);
+
+ ARM_COMPUTE_EXPECT(bool(tensor.allocator()->import_memory(raw_data.get())), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(!tensor.info()->is_resizable(), framework::LogLevel::ERRORS);
+
+ // Fill tensor while accounting padding
+ std::uniform_real_distribution<float> distribution(-5.f, 5.f);
+ std::mt19937 gen(library->seed());
+
+ Window tensor_window;
+ tensor_window.use_tensor_dimensions(tensor.info()->tensor_shape());
+ Iterator tensor_it(&tensor, tensor_window);
+
+ execute_window_loop(tensor_window, [&](const Coordinates &)
+ {
+ *reinterpret_cast<float *>(tensor_it.ptr()) = distribution(gen);
+ },
+ tensor_it);
+
+ // Execute function and sync
+ act_func.run();
+
+ // Validate result by checking that the input has no negative values
+ execute_window_loop(tensor_window, [&](const Coordinates &)
+ {
+ const float val = *reinterpret_cast<float *>(tensor_it.ptr());
+ ARM_COMPUTE_EXPECT(val >= 0, framework::LogLevel::ERRORS);
+ },
+ tensor_it);
+
+ // Release resources
+ tensor.allocator()->free();
+ ARM_COMPUTE_EXPECT(tensor.info()->is_resizable(), framework::LogLevel::ERRORS);
+}
+
#if !defined(BARE_METAL)
TEST_CASE(ImportMemoryMappedFile, framework::DatasetMode::ALL)
{