File QnnSaver.h

Parent directory (include/QNN/Saver)

QNN Saver component API.

Definition (include/QNN/Saver/QnnSaver.h)

Detailed Description

Provides an interface to the client to allow configuration of settings that are specific to the Saver Backend

Includes

Full File Listing

QNN Saver component API.

   Provides an interface to the client to allow configuration
   of settings that are specific to the Saver Backend

Defines

QNN_SAVER_API
QNN_SAVER_CONFIG_INIT   {                                               \     QNN_SAVER_CONFIG_OPTION_UNDEFINED

, /*option*/ \

{                                             \

NULL /*outputDirectory*/                    \

}                                             \

}


QnnSaver_Config_t initializer macro.

Enums

enum QnnSaver_Error_t

QNN Saver API result / error codes.

Values:

enumerator QNN_SAVER_MIN_ERROR = 4950
enumerator QNN_SAVER_ERROR_DUMMY_RETVALUE = 4950 + 0

The API has been recorded by Saver, however the return value is fake and should not be used. This error code is generally returned from get() APIs where Saver has no capability to actually fulfill the request, but can still record the API in saver_output.c. Saver will return this error code from the following QNN APIs:

enumerator QNN_SAVER_ERROR_ALREADY_INSTANTIATED = 4950 + 1

The API must be called before any others, but backend instance has already been instantiated.

enumerator QNN_SAVER_MAX_ERROR = 4998
enum QnnSaver_ConfigOption_t

This enum contains the supported config options for Saver.

Values:

enumerator QNN_SAVER_CONFIG_OPTION_OUTPUT_DIRECTORY = 0

Configuration of the location Saver outputs. This config option must be provided before any other QNN APIs are called, unless provided concurrently with QNN_SAVER_CONFIG_OPTION_FILE_CONFIG.

enumerator QNN_SAVER_CONFIG_OPTION_APPEND_TIMESTAMP = 1

Configuration of timestamp appended to Saver outputs. This config option must be provided before any other QNN APIs are called, and is mutually exclusive with QNN_SAVER_CONFIG_OPTION_FILE_CONFIG.

enumerator QNN_SAVER_CONFIG_OPTION_BACKEND_ID = 2

Configuration indicating to Saver which backend to interpret custom configs as. This option should only be used if you are providing custom configs to QNN APIs that support them (e.g. QnnBackend_create()) and you want these custom configs to be recorded by Saver. This config option must be provided before any other QNN APIs are called, unless provided concurrently with QNN_SAVER_CONFIG_OPTION_FILE_CONFIG.

enumerator QNN_SAVER_CONFIG_OPTION_FILE_CONFIG = 3

Configuration of the filenames of outputs from Saver. This configuration can be used to switch the output file streams dynamically during runtime. This config option is mutually exclusive with QNN_SAVER_CONFIG_OPTION_APPEND_TIMESTAMP.

enumerator QNN_SAVER_CONFIG_WRITE_OUTPUT_HEADER = 4

Configuration controlling whether the header should be written to the saver output file. This config must be provided concurrently with QNN_SAVER_CONFIG_OPTION_FILE_CONFIG.

enumerator QNN_SAVER_CONFIG_WRITE_OUTPUT_FOOTER = 5

Configuration controlling whether the footer should be written to the saver output file. This config must be provided concurrently with QNN_SAVER_CONFIG_OPTION_FILE_CONFIG.

enumerator QNN_SAVER_CONFIG_OPTION_UNDEFINED = 0x7FFFFFFF

Functions

Qnn_ErrorHandle_t QnnSaver_initialize(const QnnSaver_Config_t **config)

Supply the Saver backend with configuration options. This function only needs to be called if you are providing configs to Saver. If no configuration is needed, you may simply call any other QNN API to initialize the Saver.

Parameters

config[in] Pointer to a NULL terminated array of config option pointers. NULL is allowed and indicates no config options are provided, however this function only serves to supply configs, so it is unnecessary to call if no configuration is desired. All config options have a default value, in case not provided. If the same config option type is provided multiple times, the last option value will be used.

Returns

Error code:

  • QNN_SUCCESS: No error encountered

  • QNN_COMMON_ERROR_INVALID_ARGUMENT: A config was supplied incorrectly

  • QNN_SAVER_ERROR_ALREADY_INSTANTIATED: Saver backend was already initialized

Note

There are restrictions which affect when certain configurations can be provided, refer to QnnSaver_ConfigOption_t.

struct QnnSaver_FileConfig_t
#include <QnnSaver.h>

A struct which is used to provide alternative model + data file names for Saver outputs.

Public Members

const char *modelFileName

Configuration of the model file name. Must not be NULL and must not contain slashes. Default is “saver_output.c”

const char *dataFileName

Configuration of the data file name. Must not be NULL and must not contain slashes. Default is “params.bin”

struct QnnSaver_Config_t
#include <QnnSaver.h>

A struct that provides configuration for Saver.

Public Members

QnnSaver_ConfigOption_t option

Type of Saver configuration option.

union unnamed
#include <QnnSaver.h>

Union of mutually exclusive config values based on the type specified by ‘option’.

Public Members

const char *outputDirectory

Path to a directory where Saver output should be stored. The directory will be created if it doesn’t exist already. If a relative filepath is given, the location is relative to the current working directory. Defaults to “./saver_output/” if not provided.

uint8_t appendTimestamp

Boolean flag to indicate if a timestamp should be appended to the filename of Saver outputs to prevent them from being overwritten during consecutive uses of Saver. Note that all input tensor data is dumped into params.bin, so this setting may use lots of storage over time. Any nonzero value will enable the timestamp. Defaults to 0 (false) if not provided.

uint32_t backendId

Backend identifier indicating which backend to interpret custom configs as. These identifiers are defined by each backend in a Qnn<Backend>Common.h file included with the SDK.

QnnSaver_FileConfig_t fileConfig

Alternative filenames for Saver outputs.

uint8_t writeOutputHeader

Boolean flag to indicate if the saver output header should be written or not. The ‘header’ refers to the static text at the top of the output file before any APIs are recorded (header includes, beginning of main(), command line parsing, etc.) This config would be used when writing to a pre-existing saver output file created from a previous call to QnnSaver_initialize(), providing a fileConfig (QNN_SAVER_CONFIG_OPTION_FILE_CONFIG) and writeOutputFooter == 0. Because the output files already exist, the they will be opened in append mode. Defaults to 1 (true) if not provided.

uint8_t writeOutputFooter

Boolean flag to indicate if the saver output footer should be written or not. The ‘footer’ refers to the static text at the bottom of the output file after all APIs have been recorded (misc. cleanup, the end of main(), etc.) This config would be used when writing to a saver output file that will be appended to at later point with a subsequent call to QnnSaver_initialize(), providing a fileConfig (QNN_SAVER_CONFIG_OPTION_FILE_CONFIG) and writeOutputHeader == 0 Defaults to 1 (true) if not provided.