Getting Started
===============

Follow "To set up your environment" instruction from ${QNN_SDK_ROOT}/README


Building and Running Example Model
==================================

This section will show how to use the QNN SDK tools to build and run using an Op Package example
for DSP BE. It will walk through steps needed to generate and use a OpPackage library based on
an example op in the SDK located at ${QNN_SDK_ROOT}/examples/QNN/OpPackage/DSP. Specifically,
it explains the following stages:
   - Using make to generate the DSP Op package shared library from the example source.
   - Using qnn-net-run with the generated shared library.

-----------------------------------------------------------------
1. Building libQnnHv2OpPackage.so using OpPackage example
-----------------------------------------------------------------
# Go to the OpPackage example folder.
$ cd ${QNN_SDK_ROOT}/examples/QNN/OpPackage/DSP

# Before build Op package, there should be set some variables
$ export HEXAGON_SDK_ROOT=<HEXAGON_ROOT>
$ export QNN_SDK_ROOT=${QNN_SDK_ROOT}

# Build example source and generate libQnnHv2OpPackage.so library
$ make

# The command will generate OpPackage library for DSP in the build/ directory.
$ ls -l ./build/DSP

---------------------------------------------------------
2. Running qnn-net-run using libQnnHv2OpPackage.so
---------------------------------------------------------
# Using libQnnHv2OpPackage.so library created from step 1, you can run qnn-net-run
# Note: A pre-requisite step is to have set up the environment by having run envsetup.sh. Refer to
  the instruction at the top of this README for help.

# Running on arm64-v8a and armeabi-v7a
    # Push the following files to the device
    # QNN CPU Backend library
    adb push ${QNN_SDK_ROOT}/lib/<target>/libQnnDspV66Stub.so /data/local/tmp
    adb push ${QNN_SDK_ROOT}/lib/hexagon_v66/unsigned/libQnnDspV66Skel.so /data/local/tmp

    # Example OpPackage (to demonstrate external "examples.OpPackage" OpPackage, for now it contains RELU Op)
    adb push ${QNN_SDK_ROOT}/examples/QNN/OpPackage/DSP/build/DSP/libQnnHv2OpPackage.so /data/local/tmp

    # Running qnn-net-run
    # Setup LD_LIBRARY_PATH
    adb shell
    $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/local/tmp

    # Run net-run
    $ qnn-net-run --backend libQnnDspV66Stub.so
                  --model libqnn_model_8bit_quantized.so
                  --input_list input_list_float.txt
                  --op_packages libQnnHv2OpPackage.so:ExampleReluPackageInterfaceProvider

#NOTES:
# 1. The DSP backend will use the example op package for ops that are not present in the core library.
# 2. The rest of the ops in the model will be executed on the Qualcomm native op package
     distributed with the SDK.
# 3. For this release the DSP native op package is not exposed as a shared library
     but is consumed internally. In a subsequent release all op packages required by a model
     will need to be explicitly supplied to a runtime tool such as qnn-net-run.
