aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKevin May <kevin.may@arm.com>2021-05-21 16:42:21 +0100
committerKevin May <kevin.may@arm.com>2021-05-26 11:56:54 +0000
commitb4b3ac91990eb5deaffca2300319f2ddf7aa0886 (patch)
treee480826fe604d652877459ce4bbf4314a461e4b2 /src
parent401c1c3f973da1a2e2cef7f88a5aac2cf295fac7 (diff)
downloadarmnn-b4b3ac91990eb5deaffca2300319f2ddf7aa0886.tar.gz
IVGCVSW-6009 Integrate threadpool into ExNet
* Remove concurrent flag from ExecuteNetwork as it is possible to deduce if SimultaneousIterations > 1 * Add void RunAsync() * Refactor some unit tests Change-Id: I7021d4821b0e460470908294cbd9462850e8b361 Signed-off-by: Keith Davis <keith.davis@arm.com> Signed-off-by: Kevin May <kevin.may@arm.com>
Diffstat (limited to 'src')
-rw-r--r--src/armnn/LoadedNetwork.cpp8
-rw-r--r--src/backends/backendsCommon/test/StridedSliceAsyncEndToEndTest.hpp109
-rw-r--r--src/backends/reference/test/RefEndToEndTests.cpp14
3 files changed, 17 insertions, 114 deletions
diff --git a/src/armnn/LoadedNetwork.cpp b/src/armnn/LoadedNetwork.cpp
index 53a9e18863..25f8ddf6e5 100644
--- a/src/armnn/LoadedNetwork.cpp
+++ b/src/armnn/LoadedNetwork.cpp
@@ -169,17 +169,17 @@ LoadedNetwork::LoadedNetwork(std::unique_ptr<IOptimizedNetwork> net,
}
// Create the thread pool which will have working memory handles assigned to each thread
- // Should occur after factories are registered so thet the WorkingMemHandles can be created
- if (m_NetworkProperties.m_NumThreads > 0 && networkProperties.m_AsyncEnabled)
+ // Should occur after factories are registered so that the WorkingMemHandles can be created
+ if (m_NetworkProperties.m_NumThreads > 1 && networkProperties.m_AsyncEnabled)
{
CreateThreadPool(m_NetworkProperties.m_NumThreads);
}
if (!networkProperties.m_AsyncEnabled)
{
- for (auto &&layer : order)
+ for (auto&& layer : order)
{
- auto &workloadFactory = GetWorkloadFactory(*layer);
+ auto& workloadFactory = GetWorkloadFactory(*layer);
switch (layer->GetType())
{
diff --git a/src/backends/backendsCommon/test/StridedSliceAsyncEndToEndTest.hpp b/src/backends/backendsCommon/test/StridedSliceAsyncEndToEndTest.hpp
index 87cade7dca..0ad6bc4964 100644
--- a/src/backends/backendsCommon/test/StridedSliceAsyncEndToEndTest.hpp
+++ b/src/backends/backendsCommon/test/StridedSliceAsyncEndToEndTest.hpp
@@ -123,7 +123,7 @@ void AsyncEndToEndTestImpl(INetworkPtr network,
const std::map<int, std::vector<TOutput>>& expectedOutputData,
std::vector<BackendId> backends,
float tolerance = 0.000001f,
- size_t numThreads = 0)
+ size_t numThreads = 1)
{
// Create Runtime in which test will run
IRuntime::CreationOptions options;
@@ -161,7 +161,7 @@ void AsyncEndToEndTestImpl(INetworkPtr network,
outputStorage.at(it.first).data())});
}
- if (numThreads == 0)
+ if (numThreads <= 1)
{
// Create WorkingMemHandle for this async network
std::unique_ptr<IWorkingMemHandle> workingMemHandle = runtime->CreateWorkingMemHandle(networkId);
@@ -254,7 +254,7 @@ INetworkPtr CreateStridedSliceNetwork(const TensorShape& inputShape,
}
template<armnn::DataType ArmnnType>
-void StridedSlicedEndToEndTest(const std::vector<BackendId>& backends)
+void StridedSlicedEndToEndTest(const std::vector<BackendId>& backends, size_t numThreads)
{
using namespace armnn;
using T = ResolveType<ArmnnType>;
@@ -300,103 +300,12 @@ void StridedSlicedEndToEndTest(const std::vector<BackendId>& backends)
std::map<int, std::vector<T>> inputTensorData = {{0, inputData}};
std::map<int, std::vector<T>> expectedOutputData = {{0, outputExpected}};
- AsyncEndToEndTestImpl<ArmnnType, ArmnnType>(move(net), inputTensorData, expectedOutputData, backends, 0.000001f);
-}
-
-template<armnn::DataType ArmnnType>
-void AsyncScheduledStridedSlicedEndToEndTest(const std::vector<BackendId>& backends)
-{
- using namespace armnn;
- using T = ResolveType<ArmnnType>;
-
- const TensorShape& inputShape = {3, 2, 3, 1};
- const TensorShape& outputShape = {1, 2, 3, 1};
- const std::vector<int>& beginData = {1, 0, 0, 0};
- const std::vector<int>& endData = {2, 2, 3, 1};
- const std::vector<int>& stridesData = {1, 1, 1, 1};
- int beginMask = 0;
- int endMask = 0;
- int shrinkAxisMask = 0;
- int ellipsisMask = 0;
- int newAxisMask = 0;
-
- // Builds up the structure of the network
- INetworkPtr net = CreateStridedSliceNetwork<ArmnnType>(inputShape,
- outputShape,
- beginData,
- endData,
- stridesData,
- beginMask,
- endMask,
- shrinkAxisMask,
- ellipsisMask,
- newAxisMask);
-
- // Creates structures for input & output.
- std::vector<T> inputData{
- 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f,
-
- 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 4.0f,
-
- 5.0f, 5.0f, 5.0f, 6.0f, 6.0f, 6.0f
- };
-
- std::vector<T> outputExpected{
- 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 4.0f
- };
-
- std::map<int, std::vector<T>> inputTensorData = {{0, inputData}};
- std::map<int, std::vector<T>> expectedOutputData = {{0, outputExpected}};
-
- AsyncEndToEndTestImpl<ArmnnType, ArmnnType>(move(net), inputTensorData, expectedOutputData, backends, 0.000001f, 1);
-}
-
-template<armnn::DataType ArmnnType>
-void AsyncScheduledStridedSlicedMultiThreadedEndToEndTest(const std::vector<BackendId>& backends)
-{
- using namespace armnn;
- using T = ResolveType<ArmnnType>;
-
- const TensorShape& inputShape = {3, 2, 3, 1};
- const TensorShape& outputShape = {1, 2, 3, 1};
- const std::vector<int>& beginData = {1, 0, 0, 0};
- const std::vector<int>& endData = {2, 2, 3, 1};
- const std::vector<int>& stridesData = {1, 1, 1, 1};
- int beginMask = 0;
- int endMask = 0;
- int shrinkAxisMask = 0;
- int ellipsisMask = 0;
- int newAxisMask = 0;
-
- // Builds up the structure of the network
- INetworkPtr net = CreateStridedSliceNetwork<ArmnnType>(inputShape,
- outputShape,
- beginData,
- endData,
- stridesData,
- beginMask,
- endMask,
- shrinkAxisMask,
- ellipsisMask,
- newAxisMask);
-
- // Creates structures for input & output.
- std::vector<T> inputData{
- 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f,
-
- 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 4.0f,
-
- 5.0f, 5.0f, 5.0f, 6.0f, 6.0f, 6.0f
- };
-
- std::vector<T> outputExpected{
- 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 4.0f
- };
-
- std::map<int, std::vector<T>> inputTensorData = {{0, inputData}};
- std::map<int, std::vector<T>> expectedOutputData = {{0, outputExpected}};
-
- AsyncEndToEndTestImpl<ArmnnType, ArmnnType>(move(net), inputTensorData, expectedOutputData, backends, 0.000001f, 3);
+ AsyncEndToEndTestImpl<ArmnnType, ArmnnType>(move(net),
+ inputTensorData,
+ expectedOutputData,
+ backends,
+ 0.000001f,
+ numThreads);
}
template<armnn::DataType ArmnnType>
diff --git a/src/backends/reference/test/RefEndToEndTests.cpp b/src/backends/reference/test/RefEndToEndTests.cpp
index 54b16dac38..910df292a9 100644
--- a/src/backends/reference/test/RefEndToEndTests.cpp
+++ b/src/backends/reference/test/RefEndToEndTests.cpp
@@ -1336,9 +1336,9 @@ BOOST_AUTO_TEST_CASE(RefStridedSliceInvalidSliceEndToEndTest)
StridedSliceInvalidSliceEndToEndTest(defaultBackends);
}
-BOOST_AUTO_TEST_CASE(RefAsyncFP32StridedSlicedEndToEndTest)
+BOOST_AUTO_TEST_CASE(RefThreadSafeFP32StridedSlicedEndToEndTest)
{
- armnn::experimental::StridedSlicedEndToEndTest<armnn::DataType::Float32>(defaultBackends);
+ armnn::experimental::StridedSlicedEndToEndTest<armnn::DataType::Float32>(defaultBackends, 1);
}
BOOST_AUTO_TEST_CASE(RefAsyncFP32StridedSlicedMultiThreadedEndToEndTest)
@@ -1346,15 +1346,9 @@ BOOST_AUTO_TEST_CASE(RefAsyncFP32StridedSlicedMultiThreadedEndToEndTest)
armnn::experimental::StridedSlicedMultiThreadedEndToEndTest<armnn::DataType::Float32>(defaultBackends);
}
-BOOST_AUTO_TEST_CASE(RefAsyncScheduledFP32StridedSlicedEndToEndTest)
+BOOST_AUTO_TEST_CASE(RefAsyncFP32StridedSlicedScheduledMultiThreadedEndToEndTest)
{
- armnn::experimental::AsyncScheduledStridedSlicedEndToEndTest<armnn::DataType::Float32>(defaultBackends);
-}
-
-BOOST_AUTO_TEST_CASE(RefAsyncScheduledStridedSlicedMultiThreadedEndToEndTest)
-{
- using namespace armnn::experimental;
- AsyncScheduledStridedSlicedMultiThreadedEndToEndTest<armnn::DataType::Float32>(defaultBackends);
+ armnn::experimental::StridedSlicedEndToEndTest<armnn::DataType::Float32>(defaultBackends, 3);
}
#endif