ArmNN
 22.05.01
IRuntime Class Reference

#include <IRuntime.hpp>

Classes

struct  CreationOptions
 

Public Member Functions

Status LoadNetwork (NetworkId &networkIdOut, IOptimizedNetworkPtr network)
 Loads a complete network into the IRuntime. More...
 
Status LoadNetwork (NetworkId &networkIdOut, IOptimizedNetworkPtr network, std::string &errorMessage)
 Load a complete network into the IRuntime. More...
 
Status LoadNetwork (NetworkId &networkIdOut, IOptimizedNetworkPtr network, std::string &errorMessage, const INetworkProperties &networkProperties)
 
TensorInfo GetInputTensorInfo (NetworkId networkId, LayerBindingId layerId) const
 
TensorInfo GetOutputTensorInfo (NetworkId networkId, LayerBindingId layerId) const
 
std::vector< ImportedInputIdImportInputs (NetworkId networkId, const InputTensors &inputTensors, MemorySource forceImportMemorySource=MemorySource::Undefined)
 ImportInputs separates the importing and mapping of InputTensors from network execution. More...
 
std::vector< ImportedOutputIdImportOutputs (NetworkId networkId, const OutputTensors &outputTensors, MemorySource forceImportMemorySource=MemorySource::Undefined)
 ImportOutputs separates the importing and mapping of OutputTensors from network execution. More...
 
void ClearImportedInputs (NetworkId networkId, const std::vector< ImportedInputId > inputIds)
 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(). More...
 
void ClearImportedOutputs (NetworkId networkId, const std::vector< ImportedOutputId > outputIds)
 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(). More...
 
Status EnqueueWorkload (NetworkId networkId, const InputTensors &inputTensors, const OutputTensors &outputTensors, std::vector< ImportedInputId > preImportedInputIds={}, std::vector< ImportedOutputId > preImportedOutputIds={})
 Evaluates a network using input in inputTensors and outputs filled into outputTensors. More...
 
Status Execute (IWorkingMemHandle &workingMemHandle, const InputTensors &inputTensors, const OutputTensors &outputTensors, std::vector< ImportedInputId > preImportedInputs={}, std::vector< ImportedOutputId > preImportedOutputs={})
 This is an experimental function. More...
 
Status UnloadNetwork (NetworkId networkId)
 Unloads a network from the IRuntime. More...
 
const IDeviceSpecGetDeviceSpec () const
 
std::unique_ptr< IWorkingMemHandleCreateWorkingMemHandle (NetworkId networkId)
 Create a new unique WorkingMemHandle object. More...
 
const std::shared_ptr< IProfilerGetProfiler (NetworkId networkId) const
 Gets the profiler corresponding to the given network id. More...
 
void RegisterDebugCallback (NetworkId networkId, const DebugCallbackFunction &func)
 Registers a callback function to debug layers performing custom computations on intermediate tensors. More...
 

Static Public Member Functions

static IRuntimeCreateRaw (const CreationOptions &options)
 
static IRuntimePtr Create (const CreationOptions &options)
 
static void Destroy (IRuntime *runtime)
 

Protected Member Functions

 IRuntime ()
 
 IRuntime (const IRuntime::CreationOptions &options)
 
 ~IRuntime ()
 

Protected Attributes

std::unique_ptr< RuntimeImplpRuntimeImpl
 

Detailed Description

Definition at line 74 of file IRuntime.hpp.

Constructor & Destructor Documentation

◆ IRuntime() [1/2]

IRuntime ( )
protected

Definition at line 38 of file Runtime.cpp.

Referenced by IRuntime::CreateRaw().

◆ IRuntime() [2/2]

IRuntime ( const IRuntime::CreationOptions options)
protected

Definition at line 40 of file Runtime.cpp.

References IRuntime::~IRuntime().

40 : pRuntimeImpl(new RuntimeImpl(options)) {}
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ ~IRuntime()

~IRuntime ( )
protecteddefault

Referenced by IRuntime::IRuntime().

Member Function Documentation

◆ ClearImportedInputs()

void ClearImportedInputs ( NetworkId  networkId,
const std::vector< ImportedInputId inputIds 
)

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

Definition at line 101 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

102 {
103  return pRuntimeImpl->ClearImportedInputs(networkId, inputIds);
104 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ ClearImportedOutputs()

void ClearImportedOutputs ( NetworkId  networkId,
const std::vector< ImportedOutputId outputIds 
)

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

Definition at line 105 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

106 {
107  return pRuntimeImpl->ClearImportedOutputs(networkId, outputIds);
108 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ Create()

IRuntimePtr Create ( const CreationOptions options)
static
Examples:
AsyncExecutionSample.cpp, DynamicSample.cpp, and SimpleSample.cpp.

Definition at line 49 of file Runtime.cpp.

References IRuntime::CreateRaw(), and IRuntime::Destroy().

Referenced by armnn::experimental::AsyncEndToEndTestImpl(), armnn::experimental::AsyncThreadedEndToEndTestImpl(), GetSoftmaxProfilerJson(), InferenceModel< IParser, TDataType >::InferenceModel(), main(), TEST_CASE_FIXTURE(), and TEST_SUITE().

50 {
51  return IRuntimePtr(CreateRaw(options), &IRuntime::Destroy);
52 }
std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
Definition: IRuntime.hpp:33
static void Destroy(IRuntime *runtime)
Definition: Runtime.cpp:54
static IRuntime * CreateRaw(const CreationOptions &options)
Definition: Runtime.cpp:44

◆ CreateRaw()

IRuntime * CreateRaw ( const CreationOptions options)
static

Definition at line 44 of file Runtime.cpp.

References IRuntime::IRuntime().

Referenced by IRuntime::Create().

45 {
46  return new IRuntime(options);
47 }

◆ CreateWorkingMemHandle()

std::unique_ptr< IWorkingMemHandle > CreateWorkingMemHandle ( NetworkId  networkId)

Create a new unique WorkingMemHandle object.

Create multiple handles if you wish to have overlapped Execution by calling this function from different threads.

Definition at line 143 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

144 {
145  return pRuntimeImpl->CreateWorkingMemHandle(networkId);
146 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ Destroy()

void Destroy ( IRuntime runtime)
static

Definition at line 54 of file Runtime.cpp.

Referenced by IRuntime::Create().

55 {
56  delete runtime;
57 }

◆ EnqueueWorkload()

Status EnqueueWorkload ( NetworkId  networkId,
const InputTensors inputTensors,
const OutputTensors outputTensors,
std::vector< ImportedInputId preImportedInputIds = {},
std::vector< ImportedOutputId preImportedOutputIds = {} 
)

Evaluates a network using input in inputTensors and outputs filled into outputTensors.

Definition at line 110 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

115 {
116  return pRuntimeImpl->EnqueueWorkload(networkId, inputTensors, outputTensors,
117  preImportedInputIds, preImportedOutputIds);
118 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ Execute()

Status Execute ( IWorkingMemHandle workingMemHandle,
const InputTensors inputTensors,
const OutputTensors outputTensors,
std::vector< ImportedInputId preImportedInputs = {},
std::vector< ImportedOutputId preImportedOutputs = {} 
)

This is an experimental function.

Evaluates a network using input in inputTensors and outputs filled into outputTensors. This function performs a thread safe execution of the network. Returns once execution is complete. Will block until this and any other thread using the same workingMem object completes.

Definition at line 120 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

Referenced by Threadpool::TerminateThreadPool().

125 {
126  return pRuntimeImpl->Execute(workingMemHandle,
127  inputTensors,
128  outputTensors,
129  preImportedInputs,
130  preImportedOutputs);
131 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ GetDeviceSpec()

const IDeviceSpec & GetDeviceSpec ( ) const

Definition at line 138 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

139 {
140  return pRuntimeImpl->GetDeviceSpec();
141 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ GetInputTensorInfo()

armnn::TensorInfo GetInputTensorInfo ( NetworkId  networkId,
LayerBindingId  layerId 
) const

Definition at line 79 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

80 {
81  return pRuntimeImpl->GetInputTensorInfo(networkId, layerId);
82 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ GetOutputTensorInfo()

armnn::TensorInfo GetOutputTensorInfo ( NetworkId  networkId,
LayerBindingId  layerId 
) const

Definition at line 84 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

85 {
86  return pRuntimeImpl->GetOutputTensorInfo(networkId, layerId);
87 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ GetProfiler()

const std::shared_ptr< IProfiler > GetProfiler ( NetworkId  networkId) const

Gets the profiler corresponding to the given network id.

Parameters
networkIdThe id of the network for which to get the profile.
Returns
A pointer to the requested profiler, or nullptr if not found.

Definition at line 148 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

149 {
150  return pRuntimeImpl->GetProfiler(networkId);
151 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ ImportInputs()

std::vector< ImportedInputId > ImportInputs ( NetworkId  networkId,
const InputTensors inputTensors,
MemorySource  forceImportMemorySource = MemorySource::Undefined 
)

ImportInputs separates the importing and mapping of InputTensors from network execution.

Allowing for a set of InputTensors 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 and aligned memory import

Definition at line 89 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

91 {
92  return pRuntimeImpl->ImportInputs(networkId, inputTensors, forceImportMemorySource);
93 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ ImportOutputs()

std::vector< ImportedOutputId > ImportOutputs ( NetworkId  networkId,
const OutputTensors outputTensors,
MemorySource  forceImportMemorySource = MemorySource::Undefined 
)

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 and aligned memory import

Definition at line 95 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

97 {
98  return pRuntimeImpl->ImportOutputs(networkId, outputTensors, forceImportMemorySource);
99 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ LoadNetwork() [1/3]

Status LoadNetwork ( NetworkId networkIdOut,
IOptimizedNetworkPtr  network 
)

Loads a complete network into the IRuntime.

Parameters
[out]networkIdOut- Unique identifier for the network is returned in this reference.
[in]network- Complete network to load into the IRuntime. The runtime takes ownership of the network once passed in.
Returns
armnn::Status

Definition at line 59 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

Referenced by RuntimeImpl::LoadNetwork().

60 {
61  return pRuntimeImpl->LoadNetwork(networkIdOut, std::move(network));
62 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ LoadNetwork() [2/3]

Status LoadNetwork ( NetworkId networkIdOut,
IOptimizedNetworkPtr  network,
std::string &  errorMessage 
)

Load a complete network into the IRuntime.

Parameters
[out]networkIdOutUnique identifier for the network is returned in this reference.
[in]networkComplete network to load into the IRuntime.
[out]errorMessageError message if there were any errors. The runtime takes ownership of the network once passed in.
Returns
armnn::Status

Definition at line 64 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

67 {
68  return pRuntimeImpl->LoadNetwork(networkIdOut, std::move(network), errorMessage);
69 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ LoadNetwork() [3/3]

Status LoadNetwork ( NetworkId networkIdOut,
IOptimizedNetworkPtr  network,
std::string &  errorMessage,
const INetworkProperties networkProperties 
)

Definition at line 71 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

75 {
76  return pRuntimeImpl->LoadNetwork(networkIdOut, std::move(network), errorMessage, networkProperties);
77 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ RegisterDebugCallback()

void RegisterDebugCallback ( NetworkId  networkId,
const DebugCallbackFunction func 
)

Registers a callback function to debug layers performing custom computations on intermediate tensors.

Parameters
networkIdThe id of the network to register the callback.
funccallback function to pass to the debug layer.

Definition at line 153 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

154 {
155  return pRuntimeImpl->RegisterDebugCallback(networkId, func);
156 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

◆ UnloadNetwork()

Status UnloadNetwork ( NetworkId  networkId)

Unloads a network from the IRuntime.

At the moment this only removes the network from the m_Impl->m_Network. This might need more work in the future to be AndroidNN compliant.

Parameters
[in]networkId- Unique identifier for the network to be unloaded. Generated in LoadNetwork().
Returns
armnn::Status

Definition at line 133 of file Runtime.cpp.

References IRuntime::pRuntimeImpl.

134 {
135  return pRuntimeImpl->UnloadNetwork(networkId);
136 }
std::unique_ptr< RuntimeImpl > pRuntimeImpl
Definition: IRuntime.hpp:290

Member Data Documentation

◆ pRuntimeImpl


The documentation for this class was generated from the following files: