aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorFinn Williams <finwil01@e127804.cambridge.arm.com>2021-10-02 15:06:39 +0100
committerFinn Williams <finwil01@e127804.cambridge.arm.com>2021-10-08 15:42:14 +0100
commit8636bc705cc33fd869f64ebf24b14836d5a40b29 (patch)
treee546319af87596d053c75d65eedd1efb1f946228 /include
parent521032fd424cf86681eb125afbf5eaee47d8c585 (diff)
downloadarmnn-8636bc705cc33fd869f64ebf24b14836d5a40b29.tar.gz
IVGCVSW-6313 Support pre-importing outputs
* Add ClearImportedInputs/Outputs function to IRuntime * Add UnImport function to ITensorHandle * Remove mutex from IWorkingMemHandle Change-Id: I34c9b6e1618755e10f3b4597afa1d9a9ea97e5fe Signed-off-by: Finn Williams <finwil01@e127804.cambridge.arm.com>
Diffstat (limited to 'include')
-rw-r--r--include/armnn/IRuntime.hpp18
-rw-r--r--include/armnn/IWorkingMemHandle.hpp15
-rw-r--r--include/armnn/Types.hpp2
-rw-r--r--include/armnn/backends/ITensorHandle.hpp3
4 files changed, 27 insertions, 11 deletions
diff --git a/include/armnn/IRuntime.hpp b/include/armnn/IRuntime.hpp
index ca9a0ceec2..47bfef588a 100644
--- a/include/armnn/IRuntime.hpp
+++ b/include/armnn/IRuntime.hpp
@@ -242,6 +242,21 @@ public:
/// Only compatible with AsyncEnabled networks
std::vector<ImportedInputId> ImportInputs(NetworkId networkId, const InputTensors& inputTensors);
+ /// ImportOutputs separates the importing and mapping of OutputTensors from network execution.
+ /// Allowing for a set of OutputTensors to be imported and mapped once, but used in execution many times.
+ /// This function is not thread safe and must not be used while other threads are calling Execute().
+ /// Only compatible with AsyncEnabled networks
+ std::vector<ImportedInputId> ImportOutputs(NetworkId networkId, const OutputTensors& outputTensors);
+
+ /// Un-import and delete the imported InputTensor/s
+ /// This function is not thread safe and must not be used while other threads are calling Execute().
+ /// Only compatible with AsyncEnabled networks
+ void ClearImportedInputs(NetworkId networkId, const std::vector<ImportedInputId> inputIds);
+
+ /// Un-import and delete the imported OutputTensor/s
+ /// This function is not thread safe and must not be used while other threads are calling Execute().
+ /// Only compatible with AsyncEnabled networks
+ void ClearImportedOutputs(NetworkId networkId, const std::vector<ImportedOutputId> outputIds);
/// Evaluates a network using input in inputTensors and outputs filled into outputTensors
Status EnqueueWorkload(NetworkId networkId,
@@ -255,7 +270,8 @@ public:
Status Execute(IWorkingMemHandle& workingMemHandle,
const InputTensors& inputTensors,
const OutputTensors& outputTensors,
- std::vector<ImportedInputId> preImportedInputs = {});
+ std::vector<ImportedInputId> preImportedInputs = {},
+ std::vector<ImportedOutputId> preImportedOutputs = {});
/// Unloads a network from the IRuntime.
/// At the moment this only removes the network from the m_Impl->m_Network.
diff --git a/include/armnn/IWorkingMemHandle.hpp b/include/armnn/IWorkingMemHandle.hpp
index 171fa3d81c..bbc4913c59 100644
--- a/include/armnn/IWorkingMemHandle.hpp
+++ b/include/armnn/IWorkingMemHandle.hpp
@@ -5,8 +5,6 @@
#pragma once
-#include <mutex>
-
namespace armnn
{
@@ -26,23 +24,20 @@ public:
virtual NetworkId GetNetworkId() = 0;
/// Allocate the backing memory required for execution. If this is not called, then allocation will be
- /// deferred to execution time. The mutex must be locked.
+ /// deferred to execution time.
virtual void Allocate() = 0;
- /// Free the backing memory required for execution. The mutex must be locked.
+ /// Free the backing memory required for execution.
virtual void Free() = 0;
- /// IsAllocated returns true if the backing memory is currently allocated. The mutex must be locked.
+ /// IsAllocated returns true if the backing memory is currently allocated.
virtual bool IsAllocated() = 0;
- /// Get a mutex which can be used for synchronizing access to the WorkingMemHandle object.
- virtual std::mutex& GetMutex() = 0;
-
- /// Get the WorkingMemDescriptor for a Layer. The mutex must be locked.
+ /// Get the WorkingMemDescriptor for a Layer.
virtual WorkingMemDescriptor& GetWorkingMemDescriptor(LayerGuid id) = 0;
/// Get the WorkingMemDescriptor at an index. The WorkingMemDescriptors are stored in the same order as
- /// the Workloads in a topologically sorted graph. The mutex must be locked.
+ /// the Workloads in a topologically sorted graph.
virtual WorkingMemDescriptor& GetWorkingMemDescriptorAt(unsigned int id) = 0;
};
diff --git a/include/armnn/Types.hpp b/include/armnn/Types.hpp
index 02f265c6e3..7f2e192102 100644
--- a/include/armnn/Types.hpp
+++ b/include/armnn/Types.hpp
@@ -263,6 +263,8 @@ public:
/// Type of identifiers for bindable layers (inputs, outputs).
using LayerBindingId = int;
using ImportedInputId = unsigned int;
+using ImportedOutputId = unsigned int;
+
class PermutationVector
{
diff --git a/include/armnn/backends/ITensorHandle.hpp b/include/armnn/backends/ITensorHandle.hpp
index 82f5ac6c75..d07909972c 100644
--- a/include/armnn/backends/ITensorHandle.hpp
+++ b/include/armnn/backends/ITensorHandle.hpp
@@ -77,6 +77,9 @@ public:
IgnoreUnused(memory, source);
return false;
};
+ /// Unimport externally allocated memory
+ virtual void Unimport()
+ {};
};
}