# Class SNPE

- Defined in [File SNPE.hpp](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#file-snpe-snpe-hpp)

## Class Documentation

- class SNPE

    - Public Functions

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::Optional&lt;[DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[StringList](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1StringList.html#_CPPv4N8DlSystem10StringListE)&gt; getInputTensorNames() const noexcept

    - Gets the names of input tensors to the network.

To support multiple input scenarios, where multiple tensors are passed through [execute()](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE_1a0d4c02b37496a07a6456c0a5ec844cbb) 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.

- Returns

    - An Optional List of input tensor names.

Note

Note that because the returned value is an Optional list, the list must be verified as boolean true value before being dereferenced.

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::Optional&lt;[DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[StringList](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1StringList.html#_CPPv4N8DlSystem10StringListE)&gt; getOutputTensorNames() const noexcept

    - Gets the names of output tensors to the network.

- Returns

    - List of output tensor names.

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[StringList](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1StringList.html#_CPPv4N8DlSystem10StringListE) getOutputTensorNamesByLayerName(const char \*name) const noexcept

    - Gets the names of output tensor from the input layer name.

- Parameters

    - **name** – **[in]** Layer name

- Returns

    - Output tensor names.

- bool execute(const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[TensorMap](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1TensorMap.html#_CPPv4N8DlSystem9TensorMapE) &input, [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[TensorMap](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1TensorMap.html#_CPPv4N8DlSystem9TensorMapE) &output) noexcept

    - Processes the input data and returns the output.

- Parameters

    - - **A** – **[in]** map of tensors that contains the input data for each input. The names of tensors needs to be matched with names retrieved through [getInputTensorNames()](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE_1a85a9b12a6cc42089ee721d60ea981870)
- **An** – **[inout]** 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

Note

output tensormap has to be empty. To forward propagate and get results in user-supplied tensors, use executeWithSuppliedOutputTensors.

- bool execute(const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[ITensor](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1ITensor.html#_CPPv4N8DlSystem7ITensorE) \*input, [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[TensorMap](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1TensorMap.html#_CPPv4N8DlSystem9TensorMapE) &output) noexcept

    - Processes the input data and returns the output.

- Parameters

    - - **A** – **[in]** single tensor contains the input data.
- **An** – **[inout]** 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

Note

output tensormap has to be empty.

- bool execute(const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[UserBufferMap](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1UserBufferMap.html#_CPPv4N8DlSystem13UserBufferMapE) &input, const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[UserBufferMap](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1UserBufferMap.html#_CPPv4N8DlSystem13UserBufferMapE) &output) noexcept

    - Processes the input data and returns the output, using user-supplied buffers.

Caller must guarantee that for the duration of [execute()](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE_1a0d4c02b37496a07a6456c0a5ec844cbb), 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

    - - **A** – **[in]** map of UserBuffers that contains the input data for each input. The names of UserBuffers needs to be matched with names retrieved through [getInputTensorNames()](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE_1a85a9b12a6cc42089ee721d60ea981870)
- **A** – **[inout]** map of UserBuffers that will hold the output data of potentially multiple layers (the key in the map is the UserBuffer name)

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.

- bool registerIonBuffers(const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[UserMemoryMap](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1UserMemoryMap.html#_CPPv4N8DlSystem13UserMemoryMapE) &ionBufferMap) noexcept

    - Register Client ION Buffers.

- Parameters

    - **A** – **[in]** UserMemoryMap of virtual addresses

Note

To be deprecated, please use new api registerMemoryMappedBuffers

Note

UserBuffer type passed for registration must match the data type of the tensor in the dlc For regular UserBuffers [SNPE](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE) performs an online data conversion (quantization or dequantization etc). This is not possible for ion buffers hence can lead to issues during execution or accuracy degradation

- bool deregisterIonBuffers(const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[StringList](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1StringList.html#_CPPv4N8DlSystem10StringListE) &ionBufferNames) noexcept

    - Deregister Client ION Buffers.

- Parameters

    - **A** – **[in]** StringList of ION Buffer names

Note

To be deprecated, please use new api deregisterMemoryMappedBuffers

- bool registerMemoryMappedBuffers(const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[UserMemoryMap](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1UserMemoryMap.html#_CPPv4N8DlSystem13UserMemoryMapE) &memoryMappedBufferMap) noexcept

    - Register Client Memory-Mapped Buffers (Example ION buffers in Android)

- Parameters

    - **A** – **[in]** UserMemoryMap of virtual addresses

Note

UserBuffer type passed for registration must match the data type of the tensor in the dlc For regular UserBuffers [SNPE](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE) 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

- bool deregisterMemoryMappedBuffers(const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[StringList](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1StringList.html#_CPPv4N8DlSystem10StringListE) &bufferNames) noexcept

    - Deregister Client Memory-Mapped Buffers (Example ION buffers in Android)

- Parameters

    - **A** – **[in]** StringList of memory mapped buffer names

- std::string getModelVersion() const

    - Returns the version string embedded at model conversion time.

- Returns

    - Model version string, which is a free-form string supplied at the time of the conversion

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::Optional&lt;[DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[TensorShape](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1TensorShape.html#_CPPv4N8DlSystem11TensorShapeE)&gt; getInputDimensions() const noexcept

    - 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

[DlSystem::ITensor](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_ITensor_hpp.html#classDlSystem_1_1ITensor)

See also

[DlSystem::TensorShape](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_TensorShape_hpp.html#classDlSystem_1_1TensorShape)

See also

[DlSystem::Optional](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlOptional_hpp.html#classDlSystem_1_1Optional)

- Returns

    - An Optional instance of 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.

Note

Because the returned type is an Optional instance, it must be verified as a boolean true value before being dereferenced.

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::Optional&lt;[DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[TensorShape](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1TensorShape.html#_CPPv4N8DlSystem11TensorShapeE)&gt; getInputDimensions(const char \*name) const noexcept

    - 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

Snpe\_ITensor\_Handle\_t

See also

Snpe\_TensorShape\_Handle\_t

- Parameters

    - **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.

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::Optional&lt;[DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[StringList](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1StringList.html#_CPPv4N8DlSystem10StringListE)&gt; getOutputLayerNames() const noexcept

    - Gets the output layer(s) for the network.

Note that the output layers returned by this function may be different than those specified when the network was created via the zdl::SNPE::SNPEBuilder. For example, if the network was created in debug mode with no explicit output layers specified, this will contain all layers.

See also

zdl::DlSystem::Optional

- Returns

    - A List of output layer names.

Note

Note that because the returned value is an Optional StringList, the list must be verified as a boolean true value before being dereferenced.

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::Optional&lt;[DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[IBufferAttributes](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1IBufferAttributes.html#_CPPv4N8DlSystem17IBufferAttributesE)\*&gt; getInputOutputBufferAttributes(const char \*name) const noexcept

    - Returns attributes of buffers used to feed input tensors and receive result from output tensors.

- Parameters

    - **Tensor** – **[in]** name.

- Returns

    - BufferAttributes of input/output tensor named

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::Optional&lt;[DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[StringList](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1StringList.html#_CPPv4N8DlSystem10StringListE)&gt; getInputTensorNamesForNetwork(const char \*networkName) const noexcept

    - Gets the names of input tensors to the network.

To support multiple input scenarios, where multiple tensors are passed through [execute()](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE_1a0d4c02b37496a07a6456c0a5ec844cbb) 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

    - **networkName** – **[in]** Network name.

- Returns

    - A StringList of input tensor names.

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::Optional&lt;[DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[StringList](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1StringList.html#_CPPv4N8DlSystem10StringListE)&gt; getOutputTensorNamesForNetwork(const char \*networkName) const noexcept

    - Gets the names of output tensors to the network.

- Parameters

    - **networkName** – **[in]** Network name.

- Returns

    - List of output tensor names.

Note

The networkName is specified in snpe-dlc-info and defaults to the name of the first graph in the DLC.

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[StringList](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1StringList.html#_CPPv4N8DlSystem10StringListE) getOutputTensorNamesByLayerNameForNetwork(const char \*networkName, const char \*name) const noexcept

    - Gets the names of output tensor from the input layer name.

- Parameters

    - - **networkName** – **[in]** Network name.
- **name** – **[in]** Layer name

- Returns

    - Output tensor names.

- bool execute(const char \*networkName, const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[TensorMap](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1TensorMap.html#_CPPv4N8DlSystem9TensorMapE) &input, [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[TensorMap](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1TensorMap.html#_CPPv4N8DlSystem9TensorMapE) &output) noexcept

    - Processes the input data and returns the output.

- Parameters

    - - **input** – **[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()](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE_1a85a9b12a6cc42089ee721d60ea981870)
- **output** – **[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().

- bool execute(const char \*networkName, const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[ITensor](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1ITensor.html#_CPPv4N8DlSystem7ITensorE) \*input, [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[TensorMap](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1TensorMap.html#_CPPv4N8DlSystem9TensorMapE) &output) noexcept

    - Processes the input data and returns the output.

- Parameters

    - - **networkName** – **[in]** Network name.
- **input** – **[in]** A single tensor contains the input data.
- **output** – **[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.

- bool execute(const char \*networkName, const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[UserBufferMap](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1UserBufferMap.html#_CPPv4N8DlSystem13UserBufferMapE) &input, const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[UserBufferMap](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1UserBufferMap.html#_CPPv4N8DlSystem13UserBufferMapE) &output) noexcept

    - Processes the input data and returns the output, using user-supplied buffers.

Caller must guarantee that for the duration of [execute()](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE_1a0d4c02b37496a07a6456c0a5ec844cbb), 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

    - - **networkName** – **[in]** Network name.
- **input** – **[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()](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE_1a85a9b12a6cc42089ee721d60ea981870)
- **output** – **[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.

- bool executeAsync(const char \*networkName, const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[UserBufferMap](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1UserBufferMap.html#_CPPv4N8DlSystem13UserBufferMapE) &input, const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[UserBufferMap](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1UserBufferMap.html#_CPPv4N8DlSystem13UserBufferMapE) &output, void (\*notifyFn)(void \*notifyParam, bool success), void \*notifyParam) noexcept

    - Async variant of execute(networkName, UserBufferMap, UserBufferMap). Enqueues execution and returns immediately. The notifyFn callback is invoked on a backend thread when execution completes. Only supported for single-subnet models. Requires async execution queue depth to be set via setAsyncExecuteQueueDepth.

- Parameters

    - - **networkName** – **[in]** Network name.
- **input** – **[in]** Input UserBufferMap.
- **output** – **[in]** Output UserBufferMap.
- **notifyFn** – **[in]** Callback invoked with (notifyParam, success) on completion.
- **notifyParam** – **[in]** Opaque user data forwarded to the callback.

- Returns

    - true if execution was successfully enqueued.

- bool registerMemoryMappedBuffersForNetwork(const char \*networkName, const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[UserMemoryMap](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1UserMemoryMap.html#_CPPv4N8DlSystem13UserMemoryMapE) &memoryMappedBufferMap) noexcept

    - Register Client Memory-Mapped Buffers (Example ION buffers in Android)

- Parameters

    - - **networkName** – **[in]** Network name.
- **memoryMappedBuuferMap** – **[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](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE) 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

- bool deregisterMemoryMappedBuffersForNetwork(const char \*networkName, const [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[StringList](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1StringList.html#_CPPv4N8DlSystem10StringListE) &bufferNames) noexcept

    - Deregister Client Memory-Mapped Buffers (Example ION buffers in Android)

- Parameters

    - - **networkName** – **[in]** Network name.
- **bufferNames** – **[in]** A StringList of memory mapped buffer names

- Returns

    - SNPE\_SUCCESS upon successful memory mapped buffer deregistration

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::Optional&lt;[DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[TensorShape](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1TensorShape.html#_CPPv4N8DlSystem11TensorShapeE)&gt; getInputDimensionsForNetwork(const char \*networkName) const noexcept

    - 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

Snpe\_ITensor\_Handle\_t

See also

Snpe\_TensorShape\_Handle\_t

- Parameters

    - **networkName** – **[in]** Network 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.

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::Optional&lt;[DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[TensorShape](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1TensorShape.html#_CPPv4N8DlSystem11TensorShapeE)&gt; getInputDimensionsForNetwork(const char \*networkName, const char \*name) const noexcept

    - 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

Snpe\_ITensor\_Handle\_t

See also

Snpe\_TensorShape\_Handle\_t

- Parameters

    - - **snpeHandle** – **[in]** Handle to access the [SNPE](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE) 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.

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::Optional&lt;[DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[StringList](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1StringList.html#_CPPv4N8DlSystem10StringListE)&gt; getOutputLayerNamesForNetwork(const char \*networkName) const noexcept

    - Gets the output layer(s) for the network.

- Parameters

    - **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.

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::Optional&lt;[DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[IBufferAttributes](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1IBufferAttributes.html#_CPPv4N8DlSystem17IBufferAttributesE)\*&gt; getInputOutputBufferAttributesForNetwork(const char \*networkName, const char \*name) const noexcept

    - Returns attributes of buffers used to feed input tensors and receive result from output tensors.

- Parameters

    - - **networkName** – **[in]** Network name.
- **name** – **[in]** Tensor name.

- Returns

    - BufferAttributes of input/output tensor named

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::Optional&lt;[DiagLog](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DiagLog_IDiagLog_hpp.html#_CPPv47DiagLog)::[IDiagLog](https://docs.qualcomm.com/doc/80-63442-10/topic/classDiagLog_1_1IDiagLog.html#_CPPv4N7DiagLog8IDiagLogE)\*&gt; getDiagLogInterface() noexcept

    - Get the diagnostic logging interface.

See also

[DlSystem::Optional](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlOptional_hpp.html#classDlSystem_1_1Optional)

Note

Note that because the returned type is an Optional instance, it must be verified as a boolean true value before being dereferenced.

- [DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::Optional&lt;[DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[StringList](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1StringList.html#_CPPv4N8DlSystem10StringListE)&gt; getNetworkNames() const noexcept

    - Returns a stringList of network names managed by the snpeHandle.

- Returns

    - StringListHandle of networkNames

- bool setPerformanceProfile([DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::PerformanceProfile\_t perfProfile) noexcept

    - Sets performance profile.

- Parameters

    - **perfProfile, performance** – **[in]** profile level

- Returns

    - true upon successful setting of performance profile

- bool setCustomPerfProfile([DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::[SNPEPerfProfile](https://docs.qualcomm.com/doc/80-63442-10/topic/classDlSystem_1_1SNPEPerfProfile.html#_CPPv4N8DlSystem15SNPEPerfProfileE) perfProfile) noexcept

    - Sets custom performance profile.

- Parameters

    - **perfProfile, custom** – **[in]** performance profile level

- Returns

    - true upon successful setting of custom performance profile

- bool setExecutionPriorityHint([DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlEnums_hpp.html#_CPPv48DlSystem)::ExecutionPriorityHint\_t priority)

    - Sets a preference for execution priority. Allows users to set the priority of the graph. Setting this option overwrites the previous priority. [SNPE](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE) runtime is free to use this information to co-ordinate between different workloads that may or may not extend beyond [SNPE](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE).

- Parameters

    - **priority** – **[in]** The target performance profile.

- Returns

    - true upon successful setting of custom performance profile

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.

- bool getSpillFillBufferSize(uint64\_t &size)

    - Gets the size of buffers to hold external weights.

- Parameters

    - **size** – **[in]** Variable to hold the size of buffers

- Returns

    - true on successful retrieval of spill-fill buffer size

- bool getWeightsBufferSize(uint64\_t &size)

    - Gets the size of buffers to hold external weights.

- Parameters

    - **size** – **[in]** Variable to hold the size of buffers

- Returns

    - true on successful retrieval of spill-fill buffer size

- bool getBufferAlignment(uint32\_t &size)

    - Gets the size of alignment of buffers in bytes.

- Parameters

    - **size** – **[in]** Variable to hold the size of alignment of buffers

- Returns

    - true on successful retrieval of size of alignment

- bool getContextHandle(const std::string &networkName, [zdl](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlError_hpp.html#_CPPv43zdl)::[DlSystem](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_DlSystem_DlError_hpp.html#_CPPv4N3zdl8DlSystemE)::Runtime\_t runtime, uint64\_t &contextHandle)

    - Gets the QNN context handle for the first subnet of the specified network and runtime. The returned value can be passed directly as the groupId parameter to [SNPEBuilder::registerMultiContext()](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPEBuilder_hpp.html#classSNPE_1_1SNPEBuilder_1afd3a6a2dc6e008d07d45da54416c9386) so a second [SNPE](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE) instance can join this instance’s spill-fill sharing group.

- Parameters

    - - **networkName** – **[in]** Name of the network graph
- **runtime** – **[in]** Runtime whose context handle to retrieve
- **contextHandle** – **[out]** Receives the QNN context handle as uint64\_t

- Returns

    - true on success; false if the network is not found or has no matching subnet.

- bool setDspVtcmRetention(const char \*networkName, bool enable) noexcept

    - Enables or disables VTCM retention for all DSP subnets of the named network.

Call after building the [SNPE](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE) instance and before the first execute. When enabled, VTCM remains allocated between inferences of the same graph, eliminating re-allocation overhead for back-to-back workloads. Only meaningful for DSP/HTP runtime; ignored for other backends.

- Parameters

    - - **networkName** – **[in]** Name of the network; pass “” to use the first network.
- **enable** – **[in]** If true, enables VTCM retention.

- Returns

    - true if at least one HTP subnet was found and updated; false otherwise.

- bool finalize(int32\_t spillFillBufferFd, int32\_t weightsBufferFd)

    - Register the allocated external buffers with the backend.

- Parameters

    - - **snpeHandle** – **[in]** Handle to access the [SNPE](https://docs.qualcomm.com/doc/80-63442-10/topic/cpp_api-rst_file_SNPE_SNPE_hpp.html#classSNPE_1_1SNPE) object
- **spillFillBufferFd** – **[in]** File descriptor for spill-fill buffer
- **weightsBufferFd** – **[in]** File descriptor for weights buffer

- Returns

    - true if successfully finalized

Last Published: Jul 02, 2026