aboutsummaryrefslogtreecommitdiff
path: root/src/backends/backendsCommon/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/backends/backendsCommon/test')
-rw-r--r--src/backends/backendsCommon/test/CompatibilityTests.cpp6
-rw-r--r--src/backends/backendsCommon/test/MemoryManagerTests.cpp40
-rw-r--r--src/backends/backendsCommon/test/OptimizedNetworkTests.cpp4
3 files changed, 26 insertions, 24 deletions
diff --git a/src/backends/backendsCommon/test/CompatibilityTests.cpp b/src/backends/backendsCommon/test/CompatibilityTests.cpp
index d18a8fbb6c..3685f75986 100644
--- a/src/backends/backendsCommon/test/CompatibilityTests.cpp
+++ b/src/backends/backendsCommon/test/CompatibilityTests.cpp
@@ -181,7 +181,7 @@ TEST_CASE ("Ref_Backends_Capability_Test")
{"ProtectedContentAllocation", false},
{"ConstantTensorsAsInputs", true},
{"PreImportIOTensors", true},
- {"ExternallyManagedMemory", false},
+ {"ExternallyManagedMemory", true},
{"MultiAxisPacking", false}});
}
@@ -200,7 +200,7 @@ TEST_CASE ("Neon_Backends_Capability_Test")
{"ProtectedContentAllocation", false},
{"ConstantTensorsAsInputs", false},
{"PreImportIOTensors", false},
- {"ExternallyManagedMemory", false},
+ {"ExternallyManagedMemory", true},
{"MultiAxisPacking", false}});
}
@@ -219,7 +219,7 @@ TEST_CASE ("Cl_Backends_Capability_Test")
{"ProtectedContentAllocation", true},
{"ConstantTensorsAsInputs", false},
{"PreImportIOTensors", false},
- {"ExternallyManagedMemory", false},
+ {"ExternallyManagedMemory", true},
{"MultiAxisPacking", false}});
}
diff --git a/src/backends/backendsCommon/test/MemoryManagerTests.cpp b/src/backends/backendsCommon/test/MemoryManagerTests.cpp
index c873499ef3..662a5c2423 100644
--- a/src/backends/backendsCommon/test/MemoryManagerTests.cpp
+++ b/src/backends/backendsCommon/test/MemoryManagerTests.cpp
@@ -59,17 +59,18 @@ TEST_CASE("MemoryManagerTest")
// Create mock up bufferStorageVector with 2 BufferStorage with the same TensorMemory
size_t numTensors = 5;
- std::vector<TensorMemory*> tensorMemoryPointerVector(numTensors);
- std::vector<TensorMemory> tensorMemoryVector;
+ std::vector<std::shared_ptr<TensorMemory>> tensorMemoryPointerVector(numTensors);
+ std::vector<std::shared_ptr<TensorMemory>> tensorMemoryVector;
tensorMemoryVector.reserve(numTensors);
std::vector<size_t> offsets(numTensors);
std::iota(std::begin(offsets), std::end(offsets), 0);
- for (uint32_t idx = 0; idx < tensorMemoryPointerVector.size(); ++idx)
+ for (uint idx = 0; idx < tensorMemoryPointerVector.size(); ++idx)
{
- tensorMemoryVector.emplace_back(TensorMemory{offsets[idx], nullptr, 0});
- tensorMemoryPointerVector[idx] = &tensorMemoryVector[idx];
+ tensorMemoryVector.emplace_back(std::make_shared<TensorMemory>(TensorMemory{offsets[idx], 0, nullptr}));
+
+ tensorMemoryPointerVector[idx] = tensorMemoryVector[idx];
}
std::vector<BufferStorage> bufferStorageVector;
@@ -77,30 +78,31 @@ TEST_CASE("MemoryManagerTest")
bufferStorageVector.emplace_back(BufferStorage{tensorMemoryPointerVector, numTensors});
// Create an instance of the SampleCustomAllocator
- SampleCustomAllocator customAllocator = SampleCustomAllocator();
- customAllocator.m_Values = {10, 11, 12, 13, 14};
+ std::shared_ptr<SampleCustomAllocator> customAllocator =
+ std::make_unique<SampleCustomAllocator>(SampleCustomAllocator());
+
+ customAllocator->m_Values = {10, 11, 12, 13, 14};
// Check that the test was set up correctly
- CHECK(customAllocator.m_Values.size() == numTensors);
+ CHECK(customAllocator->m_Values.size() == numTensors);
+ size_t bufferVecSize = bufferStorageVector.size();
// Utilise 3 functions in the MemoryManager. Check the counters and the pointer to the values are correct.
MemoryManager memoryManager;
- memoryManager.StoreMemToAllocate(bufferStorageVector, &customAllocator);
+ memoryManager.StoreMemToAllocate(bufferStorageVector, customAllocator);
memoryManager.Allocate();
- CHECK(customAllocator.m_CounterAllocate == bufferStorageVector.size());
- for (const auto& bufferStorage : bufferStorageVector)
+ CHECK(customAllocator->m_CounterAllocate == bufferVecSize);
+
+ uint idx = 0;
+ for (auto tensorMemory : tensorMemoryVector)
{
- uint32_t idx = 0;
- for (auto tensorMemory : bufferStorage.m_TensorMemoryVector)
- {
- auto value = reinterpret_cast<uint8_t *>(tensorMemory->m_Data);
- CHECK(customAllocator.m_Values[idx] == *value);
- idx += 1;
- }
+ auto value = reinterpret_cast<uint8_t *>(tensorMemory->m_Data);
+ CHECK(customAllocator->m_Values[idx] == *value);
+ idx += 1;
}
memoryManager.Deallocate();
- CHECK(customAllocator.m_CounterFree == bufferStorageVector.size());
+ CHECK(customAllocator->m_CounterFree == bufferStorageVector.size());
}
}
diff --git a/src/backends/backendsCommon/test/OptimizedNetworkTests.cpp b/src/backends/backendsCommon/test/OptimizedNetworkTests.cpp
index 012737e1d7..b0ee9bee32 100644
--- a/src/backends/backendsCommon/test/OptimizedNetworkTests.cpp
+++ b/src/backends/backendsCommon/test/OptimizedNetworkTests.cpp
@@ -138,7 +138,7 @@ TEST_CASE("OptimizeValidateDeviceNonSupportLayerWithFallback")
// the other layers are supported by CpuRef.
// If NEON is not enabled, all layers are supported by CpuRef.
#if defined(ARMCOMPUTENEON_ENABLED)
- if (layer->GetType() == armnn::LayerType::Input || layer->GetType() == armnn::LayerType::Output)
+ if (layer->GetType() == armnn::LayerType::Output)
{
CHECK(layer->GetBackendId() == armnn::Compute::CpuAcc);
}
@@ -337,7 +337,7 @@ TEST_CASE("OptimizeValidateWorkloadsDuplicateComputeDeviceWithFallback")
// the other layers are supported by CpuRef.
// If neither NEON, nor CL is enabled, all layers are supported by CpuRef.
#if defined(ARMCOMPUTENEON_ENABLED)
- if (layer->GetType() == armnn::LayerType::Input || layer->GetType() == armnn::LayerType::Output)
+ if (layer->GetType() == armnn::LayerType::Output)
{
CHECK(layer->GetBackendId() == armnn::Compute::CpuAcc);
}