File SNPE.h¶
↰ Parent directory (SNPE)
Definition (SNPE/SNPE.h)¶
Includes¶
DiagLog/IDiagLog.h(File IDiagLog.h)DlSystem/DlEnums.h(File DlEnums.h)DlSystem/DlError.h(File DlError.h)DlSystem/IBufferAttributes.h(File IBufferAttributes.h)DlSystem/ITensor.h(File ITensor.h)DlSystem/IUserBuffer.h(File IUserBuffer.h)DlSystem/SNPEPerfProfile.h(File SNPEPerfProfile.h)DlSystem/SnpeApiExportDefine.h(File SnpeApiExportDefine.h)DlSystem/StringList.h(File StringList.h)DlSystem/TensorMap.h(File TensorMap.h)DlSystem/TensorShape.h(File TensorShape.h)DlSystem/UserBufferMap.h(File UserBufferMap.h)DlSystem/UserMemoryMap.h(File UserMemoryMap.h)
Included By¶
Functions¶
Typedefs¶
Full File Listing¶
Typedefs
-
typedef void *Snpe_SNPE_Handle_t¶
A typedef to indicate a SNPE handle
Functions
-
Snpe_ErrorCode_t Snpe_SNPE_Delete(Snpe_SNPE_Handle_t snpeHandle)¶
Destroys/frees a SNPE object
- Parameters
snpeHandle – [in] Handle to access the SNPE object
- Returns
SNPE_SUCCESS if Delete operation successful.
-
Snpe_StringList_Handle_t Snpe_SNPE_GetInputTensorNames(Snpe_SNPE_Handle_t snpeHandle)¶
Gets the names of input tensors to the network.
To support multiple input scenarios, where multiple tensors are passed through execute() in a TensorMap, each tensor needs to be uniquely named. The names of tensors can be retrieved through this function.
In the case of a single input, one name will be returned.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
- Returns
A StringList of input tensor names.
-
Snpe_StringList_Handle_t Snpe_SNPE_GetOutputTensorNames(Snpe_SNPE_Handle_t snpeHandle)¶
Gets the names of output tensors to the network.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
- Returns
List of output tensor names.
-
Snpe_StringList_Handle_t Snpe_SNPE_GetOutputTensorNamesByLayerName(Snpe_SNPE_Handle_t snpeHandle, const char *name)¶
Gets the names of output tensor from the input layer name.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
name – [in] Layer name
- Returns
Output tensor names.
-
Snpe_ErrorCode_t Snpe_SNPE_ExecuteITensors(Snpe_SNPE_Handle_t snpeHandle, Snpe_TensorMap_Handle_t inputHandle, Snpe_TensorMap_Handle_t outputHandle)¶
Processes the input data and returns the output.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
inputHandle – [in] A map of tensors that contains the input data for each input. The names of tensors needs to be matched with names retrieved through getInputTensorNames()
outputHandle – [inout] An empty map of tensors that will contain the output data of potentially multiple layers (the key in the map is the layer name) upon return
- Returns
SNPE_SUCCESS upon successful execution
Note
output TensorMap has to be empty. To forward propagate and get results in user-supplied tensors, use Snpe_SNPE_ExecuteUserBuffers().
-
Snpe_ErrorCode_t Snpe_SNPE_ExecuteITensor(Snpe_SNPE_Handle_t snpeHandle, Snpe_ITensor_Handle_t inputHandle, Snpe_TensorMap_Handle_t outputHandle)¶
Processes the input data and returns the output.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
inputHandle – [in] A single tensor contains the input data.
outputHandle – [inout] An empty map of tensors that will contain the output data of potentially multiple layers (the key in the map is the layer name) upon return
- Returns
SNPE_SUCCESS upon successful execution
Note
output TensorMap has to be empty. To forward propagate and get results in user-supplied tensors, use Snpe_SNPE_ExecuteUserBuffers.
-
Snpe_ErrorCode_t Snpe_SNPE_ExecuteUserBuffers(Snpe_SNPE_Handle_t snpeHandle, Snpe_UserBufferMap_Handle_t inputHandle, Snpe_UserBufferMap_Handle_t outputHandle)¶
Processes the input data and returns the output, using user-supplied buffers.
Caller must guarantee that for the duration of execute(), the buffer stored in UserBuffer would remain valid. For more detail on buffer ownership and lifetime requirements, please refer to zdl::DlSystem::UserBuffer documentation.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
inputHandle – [in] A map of UserBuffers that contains the input data for each input. The names of UserBuffers needs to be matched with names retrieved through getInputTensorNames()
outputHandle – [inout] A map of UserBuffers that will hold the output data of potentially multiple layers (the key in the map is the UserBuffer name)
- Returns
SNPE_SUCCESS upon successful execution
Note
input and output UserBuffer maps must be fully pre-populated. with dimensions matching what the network expects. For example, if there are 5 output UserBuffers they all have to be present in map.
-
Snpe_ErrorCode_t Snpe_SNPE_RegisterIonBuffers(Snpe_SNPE_Handle_t snpeHandle, Snpe_UserMemoryMap_Handle_t ionBufferMapHandle)¶
Register Client ION Buffers.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
ionBufferMapHandle – [in] A UserMemoryMap of virtual addresses
- Returns
SNPE_SUCCESS upon successful ION Buffer registration
Note
To be deprecated, please use new api Snpe_SNPE_RegisterUserMemoryMappedBuffers
-
Snpe_ErrorCode_t Snpe_SNPE_DeregisterIonBuffers(Snpe_SNPE_Handle_t snpeHandle, Snpe_StringList_Handle_t ionBufferNamesHandle)¶
Deregister Client ION Buffers.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
ionBufferNamesHandle – [in] A StringList of ION Buffer names
- Returns
SNPE_SUCCESS upon successful ION Buffer deregistration
Note
To be deprecated, please use new api Snpe_SNPE_DeregisterUserMemoryMappedBuffers
-
Snpe_ErrorCode_t Snpe_SNPE_RegisterUserMemoryMappedBuffers(Snpe_SNPE_Handle_t snpeHandle, Snpe_UserMemoryMap_Handle_t bufferMapHandle)¶
Register Client Memory-Mapped Buffers (Example ION buffers in Android)
- Parameters
snpeHandle – [in] Handle to access the SNPE object
bufferMapHandle – [in] A UserMemoryMap of virtual addresses
- Returns
SNPE_SUCCESS upon successful memory mapped buffer registration
Note
UserBuffer type passed for registration must match the data type of the tensor in the dlc For regular UserBuffers SNPE performs an online data conversion (quantization or dequantization etc). This is not possible for memory mapped buffers hence can lead to issues during execution or accuracy degradation
-
Snpe_ErrorCode_t Snpe_SNPE_DeregisterUserMemoryMappedBuffers(Snpe_SNPE_Handle_t snpeHandle, Snpe_StringList_Handle_t bufferNamesHandle)¶
Deregister Client Memory-Mapped Buffers (Example ION buffers in Android)
- Parameters
snpeHandle – [in] Handle to access the SNPE object
bufferNamesHandle – [in] A StringList of memory mapped buffer names
- Returns
SNPE_SUCCESS upon successful memory mapped buffer deregistration
-
const char *Snpe_SNPE_GetModelVersion(Snpe_SNPE_Handle_t snpeHandle)¶
Returns the version string embedded at model conversion time.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
- Returns
Model version string, which is a free-form string supplied at the time of the conversion
-
Snpe_TensorShape_Handle_t Snpe_SNPE_GetInputDimensions(Snpe_SNPE_Handle_t snpeHandle, const char *name)¶
Returns the dimensions of the input data to the model in the form of TensorShape. The dimensions in TensorShape corresponds to what the tensor dimensions would need to be for an input tensor to the model.
See also
See also
- Parameters
snpeHandle – [in] Handle to access the SNPE object
name – [in] input name.
- Returns
a TensorShape that maintains dimensions, matching the tensor dimensions for input to the model, where the last entry is the fastest varying dimension, etc.
Note
Note that this function only makes sense for networks that have a fixed input size. For networks in which the input size varies with each call of Execute(), this function should not be used.
-
Snpe_TensorShape_Handle_t Snpe_SNPE_GetInputDimensionsOfFirstTensor(Snpe_SNPE_Handle_t snpeHandle)¶
Returns the dimensions of the first input’s data to the model in the form of TensorShape. The dimensions in TensorShape corresponds to what the tensor dimensions would need to be for an input tensor to the model.
See also
See also
- Parameters
snpeHandle – [in] Handle to access the SNPE object
- Returns
a TensorShape that maintains dimensions, matching the tensor dimensions for first input to the model, where the last entry is the fastest varying dimension, etc.
Note
Note that this function only makes sense for networks that have a fixed input size. For networks in which the input size varies with each call of Execute(), this function should not be used.
-
Snpe_StringList_Handle_t Snpe_SNPE_GetOutputLayerNames(Snpe_SNPE_Handle_t snpeHandle)¶
Gets the output layer(s) for the network.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
- Returns
A StringList of output layer names.
Note
The output layers returned by this function may be different than those specified when the network was created via the SNPEBuilder. For example, if the network was created in debug mode with no explicit output layers specified, this will contain all layers.
-
Snpe_IBufferAttributes_Handle_t Snpe_SNPE_GetInputOutputBufferAttributes(Snpe_SNPE_Handle_t snpeHandle, const char *name)¶
Returns attributes of buffers used to feed input tensors and receive result from output tensors.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
name – [in] Tensor name.
- Returns
BufferAttributes of input/output tensor named
-
Snpe_StringList_Handle_t Snpe_SNPE_GetInputTensorNamesForNetwork(Snpe_SNPE_Handle_t snpeHandle, const char *networkName)¶
Gets the names of input tensors to the network.
To support multiple input scenarios, where multiple tensors are passed through execute() in a TensorMap, each tensor needs to be uniquely named. The names of tensors can be retrieved through this function.
In the case of a single input, one name will be returned.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
networkName – [in] Network name.
- Returns
A StringList of input tensor names.
Note
The networkName is specified in snpe-dlc-info and defaults to the name of the first graph in the DLC.
-
Snpe_StringList_Handle_t Snpe_SNPE_GetOutputTensorNamesForNetwork(Snpe_SNPE_Handle_t snpeHandle, const char *networkName)¶
Gets the names of output tensors to the network.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
networkName – [in] Network name.
- Returns
List of output tensor names.
-
Snpe_StringList_Handle_t Snpe_SNPE_GetOutputTensorNamesByLayerNameForNetwork(Snpe_SNPE_Handle_t snpeHandle, const char *networkName, const char *name)¶
Gets the names of output tensor from the input layer name.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
networkName – [in] Network name.
name – [in] Layer name
- Returns
Output tensor names.
-
Snpe_ErrorCode_t Snpe_SNPE_ExecuteITensorsForNetwork(Snpe_SNPE_Handle_t snpeHandle, const char *networkName, Snpe_TensorMap_Handle_t inputHandle, Snpe_TensorMap_Handle_t outputHandle)¶
Processes the input data and returns the output.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
networkName – [in] Network name.
inputHandle – [in] A map of tensors that contains the input data for each input. The names of tensors needs to be matched with names retrieved through getInputTensorNames()
outputHandle – [inout] An empty map of tensors that will contain the output data of potentially multiple layers (the key in the map is the layer name) upon return
- Returns
SNPE_SUCCESS upon successful execution
Note
output TensorMap has to be empty. To forward propagate and get results in user-supplied tensors, use Snpe_SNPE_ExecuteUserBuffers().
-
Snpe_ErrorCode_t Snpe_SNPE_ExecuteITensorForNetwork(Snpe_SNPE_Handle_t snpeHandle, const char *networkName, Snpe_ITensor_Handle_t inputHandle, Snpe_TensorMap_Handle_t outputHandle)¶
Processes the input data and returns the output.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
networkName – [in] Network name.
inputHandle – [in] A single tensor contains the input data.
outputHandle – [inout] An empty map of tensors that will contain the output data of potentially multiple layers (the key in the map is the layer name) upon return
- Returns
SNPE_SUCCESS upon successful execution
Note
output TensorMap has to be empty. To forward propagate and get results in user-supplied tensors, use Snpe_SNPE_ExecuteUserBuffers.
-
Snpe_ErrorCode_t Snpe_SNPE_ExecuteUserBuffersForNetwork(Snpe_SNPE_Handle_t snpeHandle, const char *networkName, Snpe_UserBufferMap_Handle_t inputHandle, Snpe_UserBufferMap_Handle_t outputHandle)¶
Processes the input data and returns the output, using user-supplied buffers.
Caller must guarantee that for the duration of execute(), the buffer stored in UserBuffer would remain valid. For more detail on buffer ownership and lifetime requirements, please refer to zdl::DlSystem::UserBuffer documentation.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
networkName – [in] Network name.
inputHandle – [in] A map of UserBuffers that contains the input data for each input. The names of UserBuffers needs to be matched with names retrieved through getInputTensorNames()
outputHandle – [inout] A map of UserBuffers that will hold the output data of potentially multiple layers (the key in the map is the UserBuffer name)
- Returns
SNPE_SUCCESS upon successful execution
Note
input and output UserBuffer maps must be fully pre-populated. with dimensions matching what the network expects. For example, if there are 5 output UserBuffers they all have to be present in map.
-
Snpe_ErrorCode_t Snpe_SNPE_RegisterUserMemoryMappedBuffersForNetwork(Snpe_SNPE_Handle_t snpeHandle, const char *networkName, Snpe_UserMemoryMap_Handle_t bufferMapHandle)¶
Register Client Memory-Mapped Buffers (Example ION buffers in Android)
- Parameters
snpeHandle – [in] Handle to access the SNPE object
networkName – [in] Network name.
bufferMapHandle – [in] A UserMemoryMap of virtual addresses
- Returns
SNPE_SUCCESS upon successful memory mapped buffer registration
Note
UserBuffer type passed for registration must match the data type of the tensor in the dlc For regular UserBuffers SNPE performs an online data conversion (quantization or dequantization etc). This is not possible for memory mapped buffers hence can lead to issues during execution or accuracy degradation
-
Snpe_ErrorCode_t Snpe_SNPE_DeregisterUserMemoryMappedBuffersForNetwork(Snpe_SNPE_Handle_t snpeHandle, const char *networkName, Snpe_StringList_Handle_t bufferNamesHandle)¶
Deregister Client Memory-Mapped Buffers (Example ION buffers in Android)
- Parameters
snpeHandle – [in] Handle to access the SNPE object
networkName – [in] Network name.
bufferNamesHandle – [in] A StringList of memory mapped buffer names
- Returns
SNPE_SUCCESS upon successful memory mapped buffer deregistration
-
Snpe_TensorShape_Handle_t Snpe_SNPE_GetInputDimensionsForNetwork(Snpe_SNPE_Handle_t snpeHandle, const char *networkName, const char *name)¶
Returns the dimensions of the input data to the model in the form of TensorShape. The dimensions in TensorShape corresponds to what the tensor dimensions would need to be for an input tensor to the model.
See also
See also
- Parameters
snpeHandle – [in] Handle to access the SNPE object
networkName – [in] Network name.
name – [in] input name.
- Returns
a TensorShape that maintains dimensions, matching the tensor dimensions for input to the model, where the last entry is the fastest varying dimension, etc.
Note
Note that this function only makes sense for networks that have a fixed input size. For networks in which the input size varies with each call of Execute(), this function should not be used.
-
Snpe_TensorShape_Handle_t Snpe_SNPE_GetInputDimensionsOfFirstTensorForNetwork(Snpe_SNPE_Handle_t snpeHandle, const char *networkName)¶
Returns the dimensions of the first input’s data to the model in the form of TensorShape. The dimensions in TensorShape corresponds to what the tensor dimensions would need to be for an input tensor to the model.
See also
See also
- Parameters
snpeHandle – [in] Handle to access the SNPE object
networkName – [in] Network name.
- Returns
a TensorShape that maintains dimensions, matching the tensor dimensions for first input to the model, where the last entry is the fastest varying dimension, etc.
Note
Note that this function only makes sense for networks that have a fixed input size. For networks in which the input size varies with each call of Execute(), this function should not be used.
-
Snpe_StringList_Handle_t Snpe_SNPE_GetOutputLayerNamesForNetwork(Snpe_SNPE_Handle_t snpeHandle, const char *networkName)¶
Gets the output layer(s) for the network.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
networkName – [in] Network name.
- Returns
A StringList of output layer names.
Note
The output layers returned by this function may be different than those specified when the network was created via the SNPEBuilder. For example, if the network was created in debug mode with no explicit output layers specified, this will contain all layers.
-
Snpe_IBufferAttributes_Handle_t Snpe_SNPE_GetInputOutputBufferAttributesForNetwork(Snpe_SNPE_Handle_t snpeHandle, const char *networkName, const char *name)¶
Returns attributes of buffers used to feed input tensors and receive result from output tensors.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
networkName – [in] Network name.
name – [in] Tensor name.
- Returns
BufferAttributes of input/output tensor named
-
Snpe_IDiagLog_Handle_t Snpe_SNPE_GetDiagLogInterface_Ref(Snpe_SNPE_Handle_t snpeHandle)¶
Get the diagnostic logging interface
- Parameters
snpeHandle – [in] Handle to access the SNPE object
-
Snpe_StringList_Handle_t Snpe_SNPE_GetNetworkNames(Snpe_SNPE_Handle_t snpeHandle)¶
Returns a stringList of network names managed by the snpeHandle.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
- Returns
StringListHandle of networkNames
-
Snpe_ErrorCode_t Snpe_SNPE_SetPerformanceProfile(Snpe_SNPE_Handle_t snpeHandle, Snpe_PerformanceProfile_t performanceProfile)¶
Set Performance profile.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
performanceProfile – [in] Value of performance profile to be set
- Returns
true if successfully applied
-
Snpe_ErrorCode_t Snpe_SNPE_SetCustomPerfProfile(Snpe_SNPE_Handle_t snpeHandle, Snpe_SNPEPerfProfile_Handle_t perfProfileHandle)¶
Set custom performance profile.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
perfProfileHandle – [in] Handle of perfProfile object
- Returns
true if successfully applied
-
Snpe_ErrorCode_t Snpe_SNPE_SetExecutionPriorityHint(Snpe_SNPE_Handle_t snpeHandle, Snpe_ExecutionPriorityHint_t priority)¶
Sets a preference for execution priority.
Sets a preference for execution priority. Allows users to set the priority of the graph. Setting this option overwrites the previous priority. SNPE runtime is free to use this information to co-ordinate between different workloads that may or may not extend beyond SNPE.
- Parameters
snpeHandle – [in] Handle to access the SNPE object
priority – [in] The target performance profile
- Returns
true if successfully applied
Note
On the Android platform, performance is determined by the priority level. In contrast, on Windows, the operating system can adjust the priority level, which means that performance cannot be guaranteed.