File QnnWrapperUtils.hpp

Parent directory (share/converter/jni)

Definition (share/converter/jni/QnnWrapperUtils.hpp)

Includes

  • QnnContext.h

  • QnnGraph.h

  • QnnTensor.h

  • QnnTypeMacros.hpp

  • QnnTypes.h

  • cstdio

  • string

Included By

Full File Listing

Defines

PRINTF(fmt, ...)

do {                            \

printf((fmt), ##__VA_ARGS__); \

} while (0)


PRINT_DEBUG(fmt, ...)
PRINT_ERROR(fmt, ...)

do {                            \

printf("[ ERROR ] ");         \

PRINTF((fmt), ##__VA_ARGS__); \

} while (0)


PRINT_WARNING(fmt, ...)

do {                            \

printf("[ WARNING ] ");       \

PRINTF((fmt), ##__VA_ARGS__); \

} while (0)


PRINT_INFO(fmt, ...)

do {                            \

printf("[ INFO ] ");          \

PRINTF((fmt), ##__VA_ARGS__); \

} while (0)


STRINGFY(str) str
STRINGFYVALUE(str) STRINGFY(str)
VALIDATE(value, retStatus)

do {                                                                                           \

retStatus = value;                                                                           \

if (retStatus !=

qnn_wrapper_api::MODEL_NO_ERROR) {                                          \       PRINT_ERROR

(                                                                               \

"%s expected MODEL_NO_ERROR, got %s\n", #value, getModelErrorName(retStatus).c_str()); \

return retStatus;                                                                          \

}                                                                                            \

} while (0)


BINVARSTART(NAME)

({                                                              \

extern const uint8_t _binary_obj_binary_##NAME##_raw_start[]; \

(void *)_binary_obj_binary_##NAME##_raw_start;                \

})


BINVAREND(NAME)

({                                                            \

extern const uint8_t _binary_obj_binary_##NAME##_raw_end[]; \

(void *)_binary_obj_binary_##NAME##_raw_end;                \

})


BINLEN(NAME)

({                                                                                             \

extern const uint8_t _binary_obj_binary_##NAME##_raw_start[];                                \

extern const uint8_t _binary_obj_binary_##NAME##_raw_end[];                                  \

(uint32_t)((_binary_obj_binary_##NAME##_raw_end) - (_binary_obj_binary_##NAME##_raw_start)); \

})


VALIDATE_TENSOR_VER(tensor, err) VALIDATE(ValidateTensorVer(tensor), err)
VALIDATE_OP_CONFIG_VER(op, err) VALIDATE(validateOpConfigVer(op), err)
namespace qnn_wrapper_api

Typedefs

typedef enum qnn_wrapper_api::ModelError ModelError_t
typedef struct qnn_wrapper_api::GraphInfo GraphInfo_t
typedef GraphInfo_t *GraphInfoPtr_t
typedef struct qnn_wrapper_api::GraphInfoV2 GraphInfoV2_t
typedef GraphInfoV2_t *GraphInfoV2Ptr_t
typedef struct qnn_wrapper_api::GraphConfigInfo GraphConfigInfo_t

Enums

enum ModelError

Values:

enumerator MODEL_NO_ERROR = 0
enumerator MODEL_TENSOR_ERROR = 1
enumerator MODEL_PARAMS_ERROR = 2
enumerator MODEL_NODES_ERROR = 3
enumerator MODEL_GRAPH_ERROR = 4
enumerator MODEL_CONTEXT_ERROR = 5
enumerator MODEL_GENERATION_ERROR = 6
enumerator MODEL_SETUP_ERROR = 7
enumerator MODEL_INVALID_ARGUMENT_ERROR = 8
enumerator MODEL_FILE_ERROR = 9
enumerator MODEL_MEMORY_ALLOCATE_ERROR = 10
enumerator MODEL_GRAPH_OP_VALIDATION_ERROR = 11
enumerator MODEL_UNKNOWN_ERROR = 0x7FFFFFFF

Functions

inline ModelError_t ValidateTensorVer(Qnn_Tensor_t tensor)

Verifies the tensor object passed is of supported Qnn_Tensor_t API version.

Parameters

tensor[in] Qnn_Tensor_t object to validate

Returns

Error code

inline ModelError_t validateOpConfigVer(Qnn_OpConfig_t opConfig)

Verifies the tensor object passed is of supported Qnn_OpConfig_t API version.

Parameters

tensor[in] Qnn_OpConfig_t object to validate

Returns

Error code

std::string getModelErrorName(ModelError_t modelError)

Returns the error message associated with a given error code.

Parameters

modelError[in] ModelError_t error code

Returns

string message

ModelError_t getQnnGraphConfigFromInfo(const char *graphName, const GraphConfigInfo_t **graphsConfigInfo, const uint32_t numGraphsConfigInfo, const QnnGraph_Config_t **&graphConfigs)

Helper function to get Qnn GraphConfig structure from provided GraphConfigInfo using graphName.

Parameters
  • graphName[in] the Qnn graphName to use for lookup

  • graphsConfigInfo[in] array of GraphConfig_t objects

  • numGraphsConfigInfo[in] the number of array elements in graphConfigInfo

  • graphConfigs[out] the result of query of graphName from graphsConfigInfo if successful.

Returns

Error code

ModelError_t deepCopyQnnTensors(Qnn_Tensor_t &source, Qnn_Tensor_t &destination)

Deep Copies QnnTensor_t structs to a pointer array destination location. Note: The copy will be stored on the heap and as such requires caller to make appropriate free call(s) using function below. Note 2: deepCopy is only done for metadata.

Parameters
  • source[in] tensor object to copy from

  • destination[in] tensor object to copy to

Returns

Error code

ModelError_t freeQnnTensor(Qnn_Tensor_t &tensor)

Frees all memory allocated tensor attributes.

Parameters

tensor[in] Qnn_Tensor_t object to free

Returns

Error code

ModelError_t freeQnnTensors(Qnn_Tensor_t *&tensors, uint32_t numTensors)

Loops through and frees all memory allocated tensor attributes for each tensor object.

Parameters
  • tensors[in] array of tensor objects to free

  • numTensors[in] length of the above tensors array

Returns

Error code

size_t memscpy(void *dst, size_t dstSize, const void *src, size_t copySize)
struct GraphInfo
#include <QnnWrapperUtils.hpp>

Public Members

Qnn_GraphHandle_t graph
char *graphName
Qnn_Tensor_t *inputTensors
uint32_t numInputTensors
Qnn_Tensor_t *outputTensors
uint32_t numOutputTensors
struct GraphInfoV2
#include <QnnWrapperUtils.hpp>

Public Members

Qnn_GraphHandle_t graph
char *graphName
Qnn_Tensor_t *inputTensors
uint32_t numInputTensors
Qnn_Tensor_t *outputTensors
uint32_t numOutputTensors
Qnn_Tensor_t *updateableTensors
uint32_t numUpdateableTensors
struct GraphConfigInfo
#include <QnnWrapperUtils.hpp>

Public Members

char *graphName
const QnnGraph_Config_t **graphConfigs