Function QnnContext_createFromBinaryWithCallback¶
Defined in File QnnContext.h
Function Documentation¶
-
Qnn_ErrorHandle_t QnnContext_createFromBinaryWithCallback(Qnn_BackendHandle_t backend, Qnn_DeviceHandle_t device, const QnnContext_Config_t **config, const Qnn_ContextBinaryCallback_t *callback, const void *binaryBuffer, Qnn_ContextBinarySize_t binaryBufferSize, Qnn_ContextHandle_t *context, Qnn_ProfileHandle_t profile, Qnn_SignalHandle_t signal)¶
A function to create a context from a stored binary. This interface through the callback parameter provides a registration mechanism for external dma buffer management and custom data loading scheme. The callback method is used to manage external dma buffers (including allocation and release) for shared weights and non-shared weights, and to perform the data loading process, offering a client-defined alternative to the default scheme in QnnContext_createFromBinary.
- Parameters
backend – [in] A backend handle.
device – [in] A device handle to set hardware affinity for the created context. NULL value can be supplied for device handle and it is equivalent to calling QnnDevice_create() with NULL config.
config – [in] Pointer to a NULL terminated array of config option pointers. NULL is allowed and indicates no config options are provided. In case they are not provided, all config options have a default value in accordance with the serialized context. If the same config option type is provided multiple times, the last option value will be used.
callback – [in] Pointer to the callback parameters. The callback parameter primarily contains two client-defined callback: Qnn_ContextBinaryDataProviderFn_t and Qnn_ContextBinaryDataReleaseFn_t.
binaryBuffer – [in] A pointer to the context binary.
binaryBufferSize – [in] Holds the size of the context binary.
context – [out] A handle to the created context.
profile – [in] The profile handle on which metrics are populated and can be queried. Use NULL handle to disable profile collection. A handle being re-used would reset and is populated with values from the current call.
signal – [in] Signal object to control the create context from binary process. NULL may be passed to indicate that no execution control is requested, and the create operation should continue to completion uninterrupted. The signal object, if not NULL, is considered to be in-use for the duration of the call including the asynchronous deserialization/initialization.
- Returns
Error code:
QNN_SUCCESS: no error is encountered
QNN_CONTEXT_ERROR_UNSUPPORTED_FEATURE: a feature is not supported
QNN_CONTEXT_ERROR_INVALID_ARGUMENT: contextParams is empty or any individual contextParam’s binaryBuffer or notifyFunc is NULL or binaryBufferSize is 0
QNN_CONTEXT_ERROR_MEM_ALLOC: memory allocation error while creating any context
QNN_CONTEXT_ERROR_CREATE_FROM_BINARY: failed to deserialize any binary and create context from it
QNN_CONTEXT_ERROR_BINARY_VERSION: incompatible version of the binary
QNN_CONTEXT_ERROR_BINARY_CONFIGURATION: binary is not configured for this device
QNN_CONTEXT_ERROR_BINARY_SUBOPTIMAL: suboptimal binary is used when QNN_CONTEXT_BINARY_COMPATIBILITY_STRICT is specified in the config option
QNN_CONTEXT_ERROR_SET_PROFILE: failed to set profiling info
QNN_CONTEXT_ERROR_INVALID_HANDLE: backend, device, signal or any individual contextParam’s profile is not a valid handle
QNN_CONTEXT_ERROR_INVALID_CONFIG: one or more config values in either listConfig or any individual contextParam’s config is invalid
QNN_CONTEXT_ERROR_ABORTED: the call is aborted before completion due to user cancellation including during any individual asynchronous deserialization/initialization
QNN_CONTEXT_ERROR_TIMED_OUT: the call is aborted before completion due to a timeout including during any individual asynchronous deserialization/initialization
Note
Use corresponding API through QnnInterface_t.