# Function QnnGraph\_execute

- Defined in [File QnnGraph.h](https://docs.qualcomm.com/doc/80-63442-10/topic/api-rst_file_include_QNN_QnnGraph_h.html#file-include-qnn-qnngraph-h)

## Function Documentation

- [Qnn\_ErrorHandle\_t](https://docs.qualcomm.com/doc/80-63442-10/topic/typedef_QnnCommon_8h_1a8e21e7c6a7471103b59098ef81c28570.html#_CPPv417Qnn_ErrorHandle_t) QnnGraph\_execute([Qnn\_GraphHandle\_t](https://docs.qualcomm.com/doc/80-63442-10/topic/typedef_QnnCommon_8h_1aac60af5d8bde388852ae15bd89fbcd3c.html#_CPPv417Qnn_GraphHandle_t) graphHandle, const [Qnn\_Tensor\_t](https://docs.qualcomm.com/doc/80-63442-10/topic/structQnn__Tensor__t.html#_CPPv412Qnn_Tensor_t) \*inputs, uint32\_t numInputs, [Qnn\_Tensor\_t](https://docs.qualcomm.com/doc/80-63442-10/topic/structQnn__Tensor__t.html#_CPPv412Qnn_Tensor_t) \*outputs, uint32\_t numOutputs, [Qnn\_ProfileHandle\_t](https://docs.qualcomm.com/doc/80-63442-10/topic/typedef_QnnCommon_8h_1a3d859a5097d3fe96b8d5bad77bf0afd5.html#_CPPv419Qnn_ProfileHandle_t) profileHandle, [Qnn\_SignalHandle\_t](https://docs.qualcomm.com/doc/80-63442-10/topic/typedef_QnnCommon_8h_1a57c5e514635d2d61c8c396974da8999a.html#_CPPv418Qnn_SignalHandle_t) signalHandle)

    - Synchronously execute a finalized graph.

- Parameters

    - - **graphHandle** – **[in]** Handle of finalized graph to execute.
- **inputs** – **[in]** Array of tensors with which to populate graph inputs.
- **numInputs** – **[in]** Number of input tensors.
- **outputs** – **[out]** Array of output tensors which the graph will populate with output values.
- **numOutputs** – **[in]** Number of output tensors.
- **profileHandle** – **[in]** The profile handle on which metrics is populated and can be queried. Use NULL handle to disable profile collection. A handle being reused would reset and is populated with values from the current call. This handle must be NULL when a continuous profile handle has been configured via the QNN\_GRAPH\_CONFIG\_OPTION\_PROFILE\_HANDLE option
- **signalHandle** – **[in]** Signal object which may be used to control the execution of this call. NULL indicates execution should proceed as normal. The signal object, if not NULL, is considered to be in-use for the duration of the call.

- Returns

    - Error code:

- QNN\_SUCCESS: the graph was successfully executed
- QNN\_GRAPH\_ERROR\_INVALID\_HANDLE: *graph* is not a valid handle
- QNN\_GRAPH\_ERROR\_GRAPH\_NOT\_FINALIZED: graph was not finalized
- QNN\_GRAPH\_ERROR\_SUBGRAPH: cannot execute a subgraph
- QNN\_GRAPH\_ERROR\_INVALID\_ARGUMENT:

    - *inputs* or *outputs* is NULL or ill-formed OR
    - *inputs* is NOT NULL and *numInputs* is 0 OR
    - *outputs* is NOT NULL and *numOutputs* is 0 OR
    - *profile* handle is invalid OR
    - continuous graph profiling is enabled and the per-API handle is not NULL.
- QNN\_GRAPH\_ERROR\_INVALID\_TENSOR: one or more tensors in *inputs* or *outputs* is invalid or not recognized by graph
- QNN\_GRAPH\_ERROR\_UNSUPPORTED\_FEATURE: graph execution is not supported on this backend or some API feature is not supported yet, e.g. signal, profile, or batch multiplier
- QNN\_GRAPH\_ERROR\_SET\_PROFILE: set profile failed
- QNN\_GRAPH\_ERROR\_SIGNAL\_IN\_USE: the supplied control signal is already in-use by another call.
- QNN\_GRAPH\_ERROR\_ABORTED: the call is aborted before completion due to user cancellation
- QNN\_GRAPH\_ERROR\_TIMED\_OUT: the call is aborted before completion due to a timeout
- QNN\_GRAPH\_ERROR\_DISABLED: the graph was not enabled when the context was deserialized
- QNN\_GRAPH\_ERROR\_DYNAMIC\_TENSOR\_SHAPE: An error occurred that is related to dynamic tensor shape. For example, a tensor maximum dimension was exceeded.
- QNN\_GRAPH\_ERROR\_TENSOR\_SPARSITY: An error occurred that is related to tensor sparsity. For example, the maximum number of specified elements was exceeded.
- QNN\_GRAPH\_ERROR\_EARLY\_TERMINATION: Graph execution terminated early due to defined op behavior.
- QNN\_GRAPH\_ERROR\_INVALID\_CONTEXT: Graph execution failed due to context already being freed.
- QNN\_COMMON\_ERROR\_SYSTEM\_COMMUNICATION: SSR occurence (successful recovery)
- QNN\_COMMON\_ERROR\_SYSTEM\_COMMUNICATION\_FATAL: SSR occurence (unsuccessful recovery)

Note

Tensors in *inputs* and *outputs* must carry the same ID that was assigned when they were created. Values for all other attributes in [Qnn\_Tensor\_t](https://docs.qualcomm.com/doc/80-63442-10/topic/api-rst_file_include_QNN_QnnTypes_h.html#structQnn__Tensor__t) are assumed from the point at which they were registered with a backend at the time of tensor creation, with the following exceptions:

- Tensor data provided by client in structs such as *clientBuf* can be changed between invocations to execute().
- Batch multiple: An *inputs* or *outputs* tensor *dimensions* field, if non-null, should match the values provided at tensor creation, with the following exception. The batch dimension, as determined by the op definition, can be an integer multiple of the respective dimension provided at tensor creation. All *inputs* and *outputs* tensors must have the same batch multiple.
- Dynamic output dimensions: An *outputs* tensor [Qnn\_TensorV1\_t](https://docs.qualcomm.com/doc/80-63442-10/topic/api-rst_file_include_QNN_QnnTypes_h.html#structQnn__TensorV1__t) *dimensions* field, if non-null, can vary after graph execution. As determined by the op definition, non-batch dimensions may be less than the respective dimension at tensor creation.
- Dynamic dimensions: If an *inputs* tensor was created with a non-null [Qnn\_TensorV2\_t](https://docs.qualcomm.com/doc/80-63442-10/topic/api-rst_file_include_QNN_QnnTypes_h.html#structQnn__TensorV2__t) *isDynamicDimensions* field, the corresponding dynamic dimensions must be provided by the caller. If an *outputs* tensor was created with a non-null [Qnn\_TensorV2\_t](https://docs.qualcomm.com/doc/80-63442-10/topic/api-rst_file_include_QNN_QnnTypes_h.html#structQnn__TensorV2__t) *isDynamicDimensions* field, the *dimensions* must be non-null and the output dimensions will be written by the backend. In a scenario where maximum dimensions will be exceeded, the backend will generate an error code indicating loss of data and will fill the tensor with as much data as possible.
- Other fields like *dataType* can also be permitted to change between invocations to [QnnGraph\_execute()](https://docs.qualcomm.com/doc/80-63442-10/topic/api-rst_file_include_QNN_QnnGraph_h.html#QnnGraph_8h_1a3ea05f42a9295f9a74a2e3a0cdd64228)/QnnGraph\_executeAsync() for certain ops that perform data type conversions.
- Some backends may be able to execute a graph with no *inputs* provided the graph has no application-writable tensors.
- [QnnGraph\_execute()](https://docs.qualcomm.com/doc/80-63442-10/topic/api-rst_file_include_QNN_QnnGraph_h.html#QnnGraph_8h_1a3ea05f42a9295f9a74a2e3a0cdd64228) can only accept tensors of type QNN\_TENSOR\_TYPE\_APP\_READ, QNN\_TENSOR\_TYPE\_APP\_WRITE, QNN\_TENSOR\_TYPE\_APP\_READ\_WRITE, QNN\_TENSOR\_TYPE\_OPTIONAL\_APP\_READ, QNN\_TENSOR\_TYPE\_OPTIONAL\_APP\_WRITE, and QNN\_TENSOR\_TYPE\_OPTIONAL\_APP\_READWRITE. Tensors provided with a different type will result in [QnnGraph\_execute()](https://docs.qualcomm.com/doc/80-63442-10/topic/api-rst_file_include_QNN_QnnGraph_h.html#QnnGraph_8h_1a3ea05f42a9295f9a74a2e3a0cdd64228) failure.
- Clients may exclude tensors of type QNN\_TENSOR\_TYPE\_OPTIONAL\_APP\_READ, QNN\_TENSOR\_TYPE\_OPTIONAL\_APP\_WRITE, and QNN\_TENSOR\_TYPE\_OPTIONAL\_APP\_READ from the *inputs* and *outputs* arguments. If a QNN\_TENSOR\_TYPE\_OPTIONAL\_APP\_WRITE tensor is excluded from the *inputs* argument, the value of that tensor will be dictated by the backend defined behavior for that model. QNN\_TENSOR\_TYPE\_OPTIONAL\_APP\_READ tensors may be excluded from the *outputs* argument. In this case a backend will not populate the tensor on the [QnnGraph\_execute()](https://docs.qualcomm.com/doc/80-63442-10/topic/api-rst_file_include_QNN_QnnGraph_h.html#QnnGraph_8h_1a3ea05f42a9295f9a74a2e3a0cdd64228) call, and the data of these tensors is null. This is an optional feature. Backends broadcast support for this feature with QNN\_PROPERTY\_TENSOR\_SUPPORT\_OPTIONAL\_APP\_WRITE, QNN\_PROPERTY\_TENSOR\_SUPPORT\_OPTIONAL\_APP\_READ, and QNN\_PROPERTY\_TENSOR\_SUPPORT\_OPTIONAL\_APP\_READWRITE.
- Mixing different tensor versions in the same graph (e.g. [Qnn\_TensorV1\_t](https://docs.qualcomm.com/doc/80-63442-10/topic/api-rst_file_include_QNN_QnnTypes_h.html#structQnn__TensorV1__t) and [Qnn\_TensorV2\_t](https://docs.qualcomm.com/doc/80-63442-10/topic/api-rst_file_include_QNN_QnnTypes_h.html#structQnn__TensorV2__t)) may result in performance degradation.

Note

If there are simultaneous calls to [QnnGraph\_execute()](https://docs.qualcomm.com/doc/80-63442-10/topic/api-rst_file_include_QNN_QnnGraph_h.html#QnnGraph_8h_1a3ea05f42a9295f9a74a2e3a0cdd64228) and [QnnGraph\_executeAsync()](https://docs.qualcomm.com/doc/80-63442-10/topic/api-rst_file_include_QNN_QnnGraph_h.html#QnnGraph_8h_1a690b74571029dd9f36e38cd902c86784), the priority for enqueuing or executing is equal. Both functions operate on the same queue, the only difference in behavior is whether the function returns when the execution is enqueued, or when the execution finishes. If there are executions already enqueued, the execution will be added to the end of the queue, and [QnnGraph\_execute()](https://docs.qualcomm.com/doc/80-63442-10/topic/api-rst_file_include_QNN_QnnGraph_h.html#QnnGraph_8h_1a3ea05f42a9295f9a74a2e3a0cdd64228) will block while waiting in the queue.

Note

Use corresponding API through [QnnInterface\_t](https://docs.qualcomm.com/doc/80-63442-10/topic/api-rst_file_include_QNN_QnnInterface_h.html#structQnnInterface__t).

Last Published: Jun 04, 2026