Function QnnGraph_addNode

Function Documentation

Qnn_ErrorHandle_t QnnGraph_addNode(Qnn_GraphHandle_t graphHandle, Qnn_OpConfig_t opConfig)

A function to add a node to the graph.

Parameters
  • graphHandle[in] The graph or sub-graph handle to add the node to.

  • opConfig[in] A struct containing the configuration of the operation which should be added as a node in the graph. The tensor objects in this structure for inputs and outputs to the node must be created with APIs in QnnTensor.h which register them with a backend. Unrecognized tensors in the opConfig result in failure. Since the tensor ID is provided by the backend and is unique, it is sufficient to only specify a valid tensor ID in the Qnn_Tensor_t structures associated with the opConfig. All other fields including any static data are ignored by the backend when parsing these tensors.

Returns

Error code

  • QNN_SUCCESS: the node is successfully added to the graph

  • QNN_GRAPH_ERROR_INVALID_OP_CONFIG: misconfigured operation - invalid op config Thrown when a BE cannot match package name and/or op name with any registered op packages, or when tensor metadata for tensors in opConfig differs from that used in registering them with a graph using QnnTensor_createGraphTensor().

  • QNN_GRAPH_ERROR_INVALID_TENSOR: when tensor objects within opConfig are invalid

  • QNN_GRAPH_ERROR_INVALID_HANDLE: graph is not a valid handle

  • QNN_GRAPH_ERROR_GRAPH_FINALIZED: add nodes on a finalized graph

  • QNN_GRAPH_ERROR_UNCONNECTED_NODE: node added before its dependent node(s)

  • QNN_GRAPH_ERROR_UNSUPPORTED_FEATURE: some API feature is not supported yet

Note

The following conditions should be honored by tensors specified as part of opConfig:

  1. No tensor in the list opConfig.outputTensors can be of type QNN_TENSOR_TYPE_APP_WRITE or QNN_TENSOR_TYPE_STATIC.

  2. All parameters in the opConfig that happen to be tensors must be of the type QNN_TENSOR_TYPE_STATIC.

  3. Tensors express connectivity between nodes. However, it is permissible for tensors to remain ‘unconsumed’ in a graph, i.e., not act as inputs to any other node in the graph.

Note

QnnGraph does not validate opConfig used in creating node beyond checks for basic sanity. A thorough validation of opConfig for this node defined in a certain op package has to be done via QnnBackend_validateOpConfig().

Note

Nodes must be added in dependency order. i.e. all QNN_TENSOR_TYPE_NATIVE inputs to the node must be outputs of a previously added node.

Note

Use corresponding API through QnnInterface_t.