Building the QNN Gen AI Transformer Model Library

Building an example model library is optional.

In the case of the GenAITransformer backend, the model is composed of a single custom op implemented by the pre-built libQnnGenAiTransformerCpuOpPkg.so and QnnGenAiTransformerCpuOpPkg.dll op packages.

Genie provides pre-built libQnnGenAiTransformerModel.so and QnnGenAiTransformerModel.dll libraries. The source for these libraries is provided by ${QNN_SDK_ROOT}/examples/Genie/Model/model.cpp. This section shows the user how to compile this source into a model library consumable by the Genie.

Model build on Linux host

Open a command shell on Linux host and run:

${QNN_SDK_ROOT}/bin/x86_64-linux-clang/qnn-model-lib-generator \
  -c ${QNN_SDK_ROOT}/examples/Genie/Model/model.cpp \
  -o ${QNN_SDK_ROOT}/examples/Genie/Model/model_libs # This can be any path

This will produce the following artifacts:

  • ${QNN_SDK_ROOT}/examples/Genie/Model/model_libs/aarch64-android/libqnn_model.so

  • ${QNN_SDK_ROOT}/examples/Genie/Model/model_libs/x86_64-linux-clang/libqnn_model.so

By default libraries are built for all targets. To compile for a specific target, use the -t <target> option with

qnn-model-lib-generator. Choices of <target> are aarch64-android and x86_64-linux-clang.