Function QnnContext_getBinary

Function Documentation

Qnn_ErrorHandle_t QnnContext_getBinary(Qnn_ContextHandle_t context, void *binaryBuffer, Qnn_ContextBinarySize_t binaryBufferSize, Qnn_ContextBinarySize_t *writtenBufferSize)

A function to get the context content in binary (serialized) form. The binary can be used to re-create context by using QnnContext_createFromBinary(). This function must be called after all entities in the context have been finalized. Unconsumed tensors are not included in the binary. Client is responsible for allocating sufficient and valid memory to hold serialized context content produced by this method. It is recommended the user calls QnnContext_getBinarySize() to allocate a buffer of sufficient space to hold the binary.

Parameters
  • context[in] A context handle.

  • binaryBuffer[in] Pointer to the user-allocated context binary memory.

  • binaryBufferSize[in] Size of binaryBuffer to populate context binary with, in bytes.

  • writtenBufferSize[out] Amount of memory actually written into binaryBuffer, in bytes.

Returns

Error code:

  • QNN_SUCCESS: no error is encountered

  • QNN_CONTEXT_ERROR_UNSUPPORTED_FEATURE: a feature is not supported

  • QNN_CONTEXT_ERROR_INVALID_HANDLE: context is not a valid handle

  • QNN_CONTEXT_ERROR_INVALID_ARGUMENT: one of the arguments to the API is invalid/NULL

  • QNN_CONTEXT_ERROR_NOT_FINALIZED: if there were any non-finalized entities in the context

  • QNN_CONTEXT_ERROR_GET_BINARY_FAILED: Operation failure due to other factors

  • QNN_COMMON_ERROR_OPERATION_NOT_PERMITTED: Attempting to get binary for a context re-created from a cached binary.

  • QNN_CONTEXT_ERROR_MEM_ALLOC: Not enough memory is available to retrieve the context content.

Note

Use corresponding API through QnnInterface_t.