主要内容

qnn.DSP

Interface to predict responses of deep learning model for QNN DSP backend

Since R2026a

Description

The qnn.DSP System object™ is an interface to predict responses of a deep learning model represented as a QNN model or QNN context binary for the DSP backend of Qualcomm® AI Direct Engine.

To create the interface to predict responses of QNN DSP:

  1. Create the qnn.DSP object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

You can deploy the code generated using the qnn.DSP System object to one of these boards that are available under the Hardware board parameter in Configuration Parameters:

  • Qualcomm Android Board

  • Qualcomm Linux Board

Creation

Description

qnnDSP = qnn.DSP(QNNHostModel=qnnhostmodel.so, QNNTargetModel=qnntargetmodel.so) creates an interface to predict responses of QNN models (compiled shared object (.so)) for host and target) for the DSP backend.

example

qnnDSP = qnn.DSP(QNNHostModel=qnnhostmodel.so,QNNTargetModel=qnntargetmodel.so,DeQuantizeOutput=true) creates an interface similar to the previous syntax and performs dequantization of the output.

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Name of QNN model on host (x-86) to perform inference, specified as a string representing a compiled shared object (.so). For details on creating a QNN model to run on device processors like DSP, refer to Qualcomm AI Engine Direct SDK documentation.

Data Types: string

Name of QNN model on target to perform inference, specified as a string representing a compiled shared object (.so) file. For details on creating a QNN model to run on device processors like DSP, refer to Qualcomm AI Engine Direct SDK documentation.

If the QNN model is not present in the current folder in MATLAB, specify the absolute path along with the filename.

Data Types: string

Option to use output dequantization to predict response, specified as true or false. Set the value to true to dequantize the output after inference. This setting results in the output data type always being single, irrespective of the data type of the deep learning neural network.

Data Types: logical

Maximum allowed time to simulate one step call, specified in seconds. This property is applicable only to MATLAB® execution and Simulink® - Normal and Accelerator mode simulations.

Data Types: double

Usage

Description

qnnResponse = qnnDSP(x) predicts responses for QNN DSP backend using the qnnDSP System object, based on the input data, x

Instead of calling the System object directly, you can also use the predict function to obtain the response.

Input Arguments

expand all

Data input, specified as an N-dimensional array. The array must be of the same size as Input layer size of the QNN host model.

The System objects support multiple-input multiple-output tensor with a maximum of four dimensions, but the batch size must always be 1. For example, if the input layer of the original deep learning network is 128-by-128-by-3, the input signal dimension must be either 128-by-128-by-3 or 1-by-128-by-128-by-3.

If the leading dimensions are 1 (singleton dimensions), you can remove these dimensions without affecting compatibility. For example, if the input layer of an AI model expects an input of size 1-by-1-by-128-by-3, you can specify an input of size 1-by-1-by-128-by-3 or 128-by-3. You can remove these dimensions because dimensions of size 1 can be broadcast to match the expected shape.

The input data type must match the data type of the QNN network's input layer. Additionally, the input can be floating-point even for a quantized QNN network.

Data Types: single | half | int8 | int16 | int32 | uint8 | uint16 | uint32

Output Arguments

expand all

Response from the QNN DSP backend, returned as an N-dimensional array. The array is of the same size as specified in Output layer size of the QNN host model. The output data type matches the data type of the QNN network's output layers. If you set DequantizeOuptut to true, the output is always single.

The System object support a multiple-input multiple-output tensor with a maximum of four dimensions, but the batch size must always be 1.

Data Types: single | half | int8 | int16 | int32 | uint8 | uint16 | uint32

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

predictPredict response based on given data using System objects created for QNN backends (HTP, CPU, or LPAI) or eNPU
releaseRelease resources and allow changes to System object property values and input characteristics
cloneCreate duplicate System object

Examples

collapse all

Prepare the QNN model for host and target, for the DSP backend. To create interface to DSP backend, it is recommended that you copy the files to the Current Folder in MATLAB. Alternatively, you can note the absolute path of the file.

Prepare the input data for inference. This example uses uniformly distributed random numbers of single data type.

x = rand(299,299,3,'single');

Create the QNN DSP interface object. This example first checks for the operating system (Linux or Windows) to use the appropriate model file. The host and target models defined using the variables must be present in the in the current folder in MATLAB.

if isunix
     QNNHostModel = "libinception.so" 
else
     QNNHostModel = "Inception.dll"
end
 
obj = qnn.DSP("QNN-Model",...
    QNNHostModel=QNNHostModel,...
    QNNTargetModel=libandroidIncpetion.so)

Predict the response by using the Predict function.

obj.predict(x);

Version History

Introduced in R2026a