File QnnOpPackage.h¶
↰ Parent directory (include/QNN)
QNN Operation Package API.
Contents
Definition (include/QNN/QnnOpPackage.h)¶
Detailed Description¶
Provides interface to the backend to use registered OpPackage libraries.
Includes¶
QnnCommon.h(File QnnCommon.h)QnnLog.h(File QnnLog.h)QnnTypes.h(File QnnTypes.h)
Included By¶
Classes¶
Defines¶
Typedefs¶
Full File Listing¶
QNN Operation Package API.
Provides interface to the backend to use registered OpPackage libraries.
Defines
-
QNN_OP_PACKAGE_RESERVED_INFO_SIZE 12¶
-
QNN_OP_PACKAGE_INFO_INIT
{ \
NULL, /*packageName*/ \
NULL, /*operationNames*/ \
NULL, /*operationInfo*/ \
0u, /*numOperations*/ \
NULL, /*optimizations*/ \
0u, /*numOptimizations*/ \
NULL, /*sdkBuildId*/ \
NULL, /*sdkApiVersion*/ \
NULL, /*packageInfo*/ \
NULL, /*opsetVersion*/ \
{ 0u } /*reserved*/ \
}
¶ QnnOpPackage_Info_t initializer macro.
-
QNN_OP_PACKAGE_API_VERSION_1_4_0
{ \
1u, /*major*/ \
4u, /*minor*/ \
0u /*patch*/ \
}
¶ QnnOpPackage_ImplementationV1_4_t version initializer macro.
-
QNN_OP_PACKAGE_IMPLEMENTATION_V1_4_INIT
{ \
NULL, /*init*/ \
NULL, /*terminate*/ \
NULL, /*getInfo*/ \
NULL, /*validateOpConfig*/ \
NULL, /*createOpImpl*/ \
NULL, /*freeOpImpl*/ \
NULL, /*logInitialize*/ \
NULL, /*logSetLevel*/ \
NULL /*logTerminate*/ \
}
¶ QnnOpPackage_ImplementationV1_4_t initializer macro.
-
QNN_OP_PACKAGE_API_VERSION_2_0_0
{ \
2u, /*major*/ \
0u, /*minor*/ \
0u /*patch*/ \
}
¶ QnnOpPackage_ImplementationV2_0_t version initializer macro.
-
QNN_OP_PACKAGE_IMPLEMENTATION_V2_0_INIT
{ \
NULL, /*create*/ \
NULL, /*getInfo*/ \
NULL, /*validateOpConfig*/ \
NULL, /*createOpImpl*/ \
NULL, /*freeOpImpl*/ \
NULL, /*logSetLevel*/ \
NULL /*free*/ \
}
¶ QnnOpPackage_ImplementationV2_0_t initializer macro.
-
QNN_OP_PACKAGE_INTERFACE_INIT { \
QNN_OP_PACKAGE_API_VERSION_1_4_0
, /*interfaceVersion*/ \
{ \
QNN_OP_PACKAGE_IMPLEMENTATION_V1_4_INIT/*v1_4*/ \
} \
}
¶ QnnOpPackage_Interface_t initializer macro.
Typedefs
-
typedef Qnn_Handle_t Qnn_OpPackageHandle_t
A typedef for op package handles.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_InitFn_t)(QnnOpPackage_GlobalInfrastructure_t infrastructure)¶
Initialize an Op package library’s data structures. This function must be called before any other library functions. Calling multiple times will result in errors after the first call. This function can be called again after QnnOpPackage_TerminateFn_t.
- Param infrastructure
[in] Global infrastructure object provided by the backend, for use in all operations in the package. This is guaranteed to live at least until QnnOpPackage_TerminateFn_t returns, and is safe to cache.
- Return
Error code:
QNN_SUCCESS: Op package library was successfully initialized.
QNN_OP_PACKAGE_ERROR_LIBRARY_ALREADY_INITIALIZED: This package library has already been initialized.
QNN_OP_PACKAGE_ERROR_INVALID_INFRASTRUCTURE: Op package initialization failed due to invalid infrastructure content.
QNN_OP_PACKAGE_ERROR_GENERAL: Op package library failed to initialize.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_TerminateFn_t)()¶
Terminate an Op package library, freeing all data structures and invalidating any memory or handles provided by the library. This function may be called again after a subsequent call to QnnOpPackage_InitFn_t.
- Return
Error code:
QNN_SUCCESS: Op package library was successfully terminated.
QNN_OP_PACKAGE_ERROR_GENERAL: Op package library termination failed.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_GetInfoFn_t)(const QnnOpPackage_Info_t **info)¶
Retrieve a QnnOpPackage_Info_t struct from an Op package library describing all operations and optimizations provided by the library.
- Param info
[out] Info object for the library. This pointer shall point to memory owned by the op package library and remain valid until QnnOpPackage_TerminateFn_t is called on the library. The contents of this struct shall not change before QnnOpPackage_TerminateFn_t is called.
- Return
Error code:
QNN_SUCCESS: Info is fetched successfully.
QNN_OP_PACKAGE_ERROR_INVALID_INFO: ‘info’ argument was NULL or invalid.
QNN_OP_PACKAGE_ERROR_GENERAL: Other error occurred.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_ValidateOpConfigFn_t)(Qnn_OpConfig_t opConfig)¶
Verifies that this op with the specified config can be successfully executed.
- Param opConfig
[in] Op configuration in question.
- Return
error code:
QNN_SUCCESS if validation is successful
QNN_OP_PACKAGE_ERROR_VALIDATION_FAILURE: op config validation failed
QNN_OP_PACKAGE_ERROR_UNSUPPORTED_FEATURE: Validation API not supported
Note
inputTensors and outputTensors inside opConfig must be fully qualified for complete validation. However, their unique IDs (id) are ignored during validation.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_CreateOpImplFn_t)(QnnOpPackage_GraphInfrastructure_t graphInfrastructure, QnnOpPackage_Node_t node, QnnOpPackage_OpImpl_t *opImpl)¶
Create Op implementation with executable content for a given node.
- Param graphInfrastructure
[in] Infrastructure for the graph to which the node and kernels belong. This memory is guaranteed to live at least until all created kernels are freed, and may be safely cached.
- Param node
[in] Node object for which kernels should be created. This node may be freed before the created kernels. Neither the node nor it’s members should be cached.
- Param opImpl
[out] Op implementation with executable content to compute the operation specified by node. The Op implementation contents will be freed by the backend with QnnOpPackage_FreeOpImplFn_t.
- Pre
The corresponding QnnOpPackage_ValidateOpConfigFn_t should return QNN_SUCCESS for the supplied node.
- Return
Error code:
QNN_SUCCESS: Op implementation is created successfully
QNN_OP_PACKAGE_ERROR_INVALID_INFRASTRUCTURE: Failed to create op implementation due to invalid graph infrastructure content.
QNN_OP_PACKAGE_ERROR_INVALID_ARGUMENT: one or more invalid arguments (e.g. NULL)
QNN_OP_PACKAGE_ERROR_UNSUPPORTED_FEATURE: API not supported
QNN_OP_PACKAGE_ERROR_GENERAL: Other error occurred.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_FreeOpImplFn_t)(QnnOpPackage_OpImpl_t opImpl)¶
Free the resources associated with Op implementation previously allocated by QnnOpPackage_CreateOpImplFn_t.
- Param opImpl
[in] Op implementation which should be freed.
- Return
Error code:
QNN_SUCCESS if Op implementation resources are successfully freed.
QNN_OP_PACKAGE_ERROR_INVALID_ARGUMENT: opImpl argument was NULL.
QNN_OP_PACKAGE_ERROR_UNSUPPORTED_FEATURE: API not supported.
QNN_OP_PACKAGE_ERROR_GENERAL: Other error occurred.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_LogInitializeFn_t)(QnnLog_Callback_t callback, QnnLog_Level_t maxLogLevel)¶
See QnnLog_create() in QnnLog.h for documentation.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_LogSetLevelFn_t)(QnnLog_Level_t maxLogLevel)¶
See QnnLog_setLogLevel() in QnnLog.h for documentation.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_LogTerminateFn_t)(void)¶
See QnnLog_free() in QnnLog.h for documentation.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_CreateFn_t)(QnnOpPackage_GlobalInfrastructure_t infrastructure, QnnLog_Callback_t callback, QnnLog_Level_t maxLogLevel, Qnn_OpPackageHandle_t *opPackage)¶
Initialize an op package library and create an op package handle.
- Param infrastructure
[in] Global infrastructure object provided by the backend for use in all operations in the package.
- Param callback
[in] Callback to handle op package generated logging messages. NULL represents that logging is disabled.
- Param maxLogLevel
[in] Maximum level of messages which the op package will generate.
- Param opPackage
[out] The created op package handle.
- Return
Error code:
QNN_SUCCESS: Op package was successfully created.
QNN_OP_PACKAGE_ERROR_UNSUPPORTED_PLATFORM: Op package attempted to be created on an unsupported platform.
QNN_OP_PACKAGE_ERROR_INVALID_ARGUMENT: if one or more arguments is invalid.
QNN_OP_PACKAGE_ERROR_INVALID_INFRASTRUCTURE: Op package initialization failed due to invalid infrastructure content.
QNN_OP_PACKAGE_ERROR_GENERAL: Op package library failed to initialize.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_ValidateOpConfigHandleFn_t)(Qnn_OpPackageHandle_t opPackage, Qnn_OpConfig_t opConfig)¶
Verifies that this op with the specified config can be successfully executed.
- Param opPackage
[in] An op package handle.
- Param opConfig
[in] Op configuration in question.
- Return
error code:
QNN_SUCCESS No error encountered.
QNN_OP_PACKAGE_ERROR_INVALID_HANDLE: opPackage is not a valid handle.
QNN_OP_PACKAGE_ERROR_VALIDATION_FAILURE: op config validation failed
QNN_OP_PACKAGE_ERROR_UNSUPPORTED_FEATURE: Validation API not supported
Note
inputTensors and outputTensors inside opConfig must be fully qualified for complete validation. However, their unique id and name are ignored during validation.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_CreateOpImplHandleFn_t)(Qnn_OpPackageHandle_t opPackage, QnnOpPackage_GraphInfrastructure_t graphInfrastructure, QnnOpPackage_Node_t node, QnnOpPackage_OpImpl_t *opImpl)¶
Create op implementation with executable content for a given node.
- Param opPackage
[in] An op package handle.
- Param graphInfrastructure
[in] Infrastructure for the graph to which the node and kernels belong. This memory is guaranteed to live at least until all created kernels are freed and may be safely cached.
- Param node
[in] Node object for which kernels should be created. This node may be freed before the created kernels. Neither the node nor it’s members should be cached.
- Param opImpl
[out] Op implementation with executable content to compute the operation specified by node. The Op implementation contents will be freed by the backend with QnnOpPackage_FreeOpImplFn_t.
- Pre
The corresponding QnnOpPackage_ValidateOpConfigFn_t should return QNN_SUCCESS for the supplied node.
- Return
Error code:
QNN_SUCCESS: No error encountered.
QNN_OP_PACKAGE_ERROR_INVALID_HANDLE: opPackage is not a valid handle.
QNN_OP_PACKAGE_ERROR_INVALID_INFRASTRUCTURE: Failed to create op implementation due to invalid graph infrastructure content.
QNN_OP_PACKAGE_ERROR_INVALID_ARGUMENT: one or more invalid arguments (e.g. NULL)
QNN_OP_PACKAGE_ERROR_UNSUPPORTED_FEATURE: API not supported
QNN_OP_PACKAGE_ERROR_GENERAL: Other error occurred.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_FreeOpImplHandleFn_t)(Qnn_OpPackageHandle_t opPackage, QnnOpPackage_OpImpl_t opImpl)¶
Free the resources associated with Op implementation previously allocated by QnnOpPackage_CreateOpImplFn_t.
- Param opPackage
[in] An op package handle.
- Param opImpl
[in] Op implementation which should be freed.
- Return
Error code:
QNN_SUCCESS No error encountered.
QNN_OP_PACKAGE_ERROR_INVALID_HANDLE: opPackage is not a valid handle.
QNN_OP_PACKAGE_ERROR_INVALID_ARGUMENT: opImpl argument was NULL.
QNN_OP_PACKAGE_ERROR_UNSUPPORTED_FEATURE: API not supported.
QNN_OP_PACKAGE_ERROR_GENERAL: Other error occurred.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_LogSetLevelHandleFn_t)(Qnn_OpPackageHandle_t opPackage, QnnLog_Level_t maxLogLevel)¶
A function to change the log level for the supplied op package handle.
- Param opPackage
[in] An op package handle.
- Param maxLogLevel
[in] New maximum log level.
- Return
Error code:
QNN_SUCCESS: No error encountered.
QNN_OP_PACKAGE_ERROR_INVALID_HANDLE: opPackage is not a valid handle.
QNN_OP_PACKAGE_ERROR_INVALID_ARGUMENT: if maxLogLevel is not a valid log level.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_FreeFn_t)(Qnn_OpPackageHandle_t opPackage)¶
Free all resources associated with an op package handle.
- Param Op
[in] package handle to be freed.
- Return
Error code:
QNN_SUCCESS: No error encountered.
QNN_OP_PACKAGE_ERROR_INVALID_HANDLE: opPackage is not a valid handle.
QNN_OP_PACKAGE_ERROR_GENERAL: Indicates failure to free op package allocated resources.
-
typedef Qnn_ErrorHandle_t (*QnnOpPackage_InterfaceProvider_t)(QnnOpPackage_Interface_t *interface)¶
A function to retrieve the interface provided by the Op package. The name of this function is not prescribed by Op Package API, but must be documented by the package developer and supplied to QNN backend by the client. See QnnBackend_registerOpPackage().
- Param interface
[out] QNN Op Package interface structure, populated with the version and interface methods this Op package provides. Caller to manage the lifetime of the pointer, though the contents are to be considered invalid if the op package library is terminated/unloaded.
- Return
Error code:
QNN_SUCCESS: Op package interface is successfully retrieved.
QNN_OP_PACKAGE_ERROR_INVALID_ARGUMENT: interface argument was NULL.
QNN_OP_PACKAGE_ERROR_GENERAL: Other error occurred.
Enums
-
enum QnnOpPackage_Error_t
QNN OpPackage API result / error codes.
Values:
-
enumerator QNN_OP_PACKAGE_MIN_ERROR = 3000
-
enumerator QNN_OP_PACKAGE_NO_ERROR = 0
-
enumerator QNN_OP_PACKAGE_ERROR_UNSUPPORTED_FEATURE = QNN_COMMON_ERROR_NOT_SUPPORTED
There is optional API component that is not supported yet. See QnnProperty.
-
enumerator QNN_OP_PACKAGE_ERROR_LIBRARY_ALREADY_INITIALIZED = 3000 + 0
Op package library was already initialized.
-
enumerator QNN_OP_PACKAGE_ERROR_LIBRARY_NOT_INITIALIZED = 3000 + 1
Attempt to call a function in an uninitialized op package library.
-
enumerator QNN_OP_PACKAGE_ERROR_INVALID_HANDLE = 3000 + 2
An invalid op package handle was provided.
-
enumerator QNN_OP_PACKAGE_ERROR_INVALID_INFRASTRUCTURE = 3000 + 100
Invalid infrastructure object used in initializing op package.
-
enumerator QNN_OP_PACKAGE_ERROR_INVALID_INFO = 3000 + 101
Invalid op package info object used in initializing op package.
-
enumerator QNN_OP_PACKAGE_ERROR_VALIDATION_FAILURE = 3000 + 110
Op configuration failed validation.
-
enumerator QNN_OP_PACKAGE_ERROR_INVALID_ARGUMENT = 3000 + 200
Invalid function argument.
-
enumerator QNN_OP_PACKAGE_ERROR_GENERAL = QNN_COMMON_ERROR_GENERAL
Indicates an error has occurred due to a condition unforeseen by QNN, and possibly meaningful only in the context of the particular op package. Unless otherwise noted, any op package function may return this error.
-
enumerator QNN_OP_PACKAGE_MAX_ERROR = 3999
-
enumerator QNN_OP_PACKAGE_ERROR_UNDEFINED = 0x7FFFFFFF
-
enumerator QNN_OP_PACKAGE_MIN_ERROR = 3000
-
struct QnnOpPackage_Info_t¶
- #include <QnnOpPackage.h>
Struct describing the contents of an Op package.
Reported to the backend by QnnOpPackage_GetInfoFn_t.
Public Members
-
const char *packageName¶
Op package name. Must not be NULL nor empty string.
-
const char **operationNames¶
Array holding names of operations provided by the op package. Must not be NULL. Number of elements in the array is specified with numOperations.
-
const QnnOpPackage_OperationInfo_t *operationInfo¶
Array holding backend-defined operation information. This is optional, backend-specific information. Can be NULL. If not NULL, number of elements in the array is specified with numOperations.
-
uint32_t numOperations¶
Number of elements in operationNames and operationInfo arrays.
-
const QnnOpPackage_Optimization_t *optimizations¶
Array holding backend-defined graph optimizations. This is optional, backend-specific information. Can be NULL. If not NULL, number of elements in the array is specified with numOptimizations.
-
uint32_t numOptimizations¶
Number of elements in optimizations array.
-
const char *sdkBuildId¶
BuildId (as returned by QnnBackend_getBuildId(), also see QNN_SDK_BUILD_ID) from QNN SDK which was used to create this OpPackage with. Allowed to be NULL.
-
const Qnn_ApiVersion_t *sdkApiVersion¶
API Version (as returned by QnnBackend_getApiVersion()) from QNN SDK which was used to create this OpPackage with. Allowed to be NULL.
-
const QnnOpPackage_PackageInfo_t *packageInfo¶
Op package level information. Allowed to be NULL.
-
const Qnn_Version_t *opsetVersion¶
Version of the set of operations implemented in the op package.
-
size_t reserved[12]¶
Reserved for future extensibility. Must be memset to 0.
-
const char *packageName¶
-
struct QnnOpPackage_ImplementationV1_4_t¶
- #include <QnnOpPackage.h>
Version 1.4 QNN Op Package Implementation structure.
Contains function pointers for each interface method defined in the 1.4 QNN Op Package API.
Public Members
-
QnnOpPackage_TerminateFn_t terminate¶
-
QnnOpPackage_GetInfoFn_t getInfo¶
-
QnnOpPackage_ValidateOpConfigFn_t validateOpConfig¶
-
QnnOpPackage_CreateOpImplFn_t createOpImpl¶
-
QnnOpPackage_FreeOpImplFn_t freeOpImpl¶
-
QnnOpPackage_LogInitializeFn_t logInitialize¶
-
QnnOpPackage_LogSetLevelFn_t logSetLevel¶
-
QnnOpPackage_LogTerminateFn_t logTerminate¶
-
QnnOpPackage_TerminateFn_t terminate¶
-
struct QnnOpPackage_ImplementationV2_0_t¶
- #include <QnnOpPackage.h>
Version 2.0 QNN Op Package Implementation structure.
Contains function pointers for each interface method defined in the 2.0 QNN Op Package API.
Public Members
-
QnnOpPackage_CreateFn_t create¶
-
QnnOpPackage_GetInfoFn_t getInfo¶
-
QnnOpPackage_ValidateOpConfigHandleFn_t validateOpConfig¶
-
QnnOpPackage_CreateOpImplHandleFn_t createOpImpl¶
-
QnnOpPackage_FreeOpImplHandleFn_t freeOpImpl¶
-
QnnOpPackage_LogSetLevelHandleFn_t logSetLevel¶
-
QnnOpPackage_CreateFn_t create¶
-
struct QnnOpPackage_Interface_t¶
- #include <QnnOpPackage.h>
Structure which provides the package version and implementation for a given package. Will be queried by the backend using the package’s implementation provider.
Public Members
-
Qnn_Version_t interfaceVersion¶
Version of the QNN Op Package Interface which this package provides. The Op Package Interface is accessed through correspondingly named implementation.
-
union unnamed
- #include <QnnOpPackage.h>
-
Qnn_Version_t interfaceVersion¶