Function QnnTensor_createGraphTensor

Function Documentation

Qnn_ErrorHandle_t QnnTensor_createGraphTensor(Qnn_GraphHandle_t graph, Qnn_Tensor_t *tensor)

A function to create a new tensor on Qnn_GraphHandle_t.

   This call may or may not allocate memory, depending on the Qnn_TensorType_t
   value specified in tensor and the accelerator implementation.
   Optionally it may be initialized with data provided in the tensor if present.

Parameters
  • graph[in] The graph or sub-graph in which the tensor would be created.

  • tensor[inout] Pointer to a user-allocated struct containing information on the tensor (type, name, data format, dimensions, data, etc). For tensors containing static data (such as weights or biases), the tensor type is expected to be QNN_TENSOR_TYPE_STATIC. Valid data must be presented in the tensor object at creation. This data will be copied, and may be safely de-allocated after this call returns. Other tensor types (e.g: NATIVE, APP_READ, APP_WRITE, NULL) must have the data pointer set to NULL at the time of creation. Any preset value in id will be overwritten by the backend as part of this call. Subsequent usage of the tensor must reference this id. Creating a tensor with a name that duplicates a previously created tensor name in the graph or parent context results in undefined behaviour. The dimensions are treated as the maximum dimensions during tensor creation.

Returns

Error code:

  • QNN_SUCCESS: Successfully created a graph tensor

  • QNN_TENSOR_ERROR_INVALID_HANDLE: Provided graph handle is invalid

  • QNN_TENSOR_ERROR_INVALID_TENSOR_PARAM: One or more tensor parameters is invalid

  • QNN_TENSOR_ERROR_UNSUPPORTED_TENSOR_PARAM: One or more tensor parameters are unsupported

  • QNN_COMMON_ERROR_MEM_ALLOC: Failure in creating tensor due to issues with memory allocation

  • QNN_TENSOR_ERROR_UNSUPPORTED_FEATURE: some API feature is not supported yet

Note

Use corresponding API through QnnInterface_t.

Warning

Graph tensors cannot be of type QNN_TENSOR_TYPE_APP_READWRITE. R/W tensors connect multiple graphs.

Warning

Graph tensors cannot be of datatype QNN_DATATYPE_STRING.