Skip to content

Conversation

@Juude
Copy link
Owner

@Juude Juude commented Feb 8, 2026

This change updates the source/backend/qnn/CMakeLists.txt to include ${_QNN_ROOT}/include/ in the search path. This ensures compatibility with the directory structure created by prepare_qnn_deps.sh (where headers are directly under include/) as well as the standard Qualcomm QNN SDK structure (where headers are under include/QNN/).

Usage Guide for MNN QNN (Offline Mode)

This guide explains how to compile and use mnn_qnn for offline model conversion and Android execution.

1. Prerequisites

  • Qualcomm QNN SDK: Required for running the conversion tool (host) and providing runtime libraries (device).
  • MNN Source Code: Clone the repository.
  • Dependencies: Run ./prepare_qnn_deps.sh to download necessary headers and libs to source/backend/qnn/3rdParty/, OR have the full QNN SDK installed.

2. Compile Model Converter (Host - Linux x86_64)

The MNN2QNNModel tool converts an MNN model into a QNN-compatible model (.mnn + .bin). It requires MNN_QNN and MNN_QNN_CONVERT_MODE enabled.

mkdir build_host
cd build_host
cmake .. \
    -DMNN_QNN=ON \
    -DMNN_QNN_CONVERT_MODE=ON \
    -DQNN_SDK_ROOT=/path/to/qnn/sdk_or_deps
make -j4 MNN2QNNModel

(Note: If using prepare_qnn_deps.sh, set QNN_SDK_ROOT to path/to/source/backend/qnn/3rdParty).

3. Convert Model (Host)

Running MNN2QNNModel requires the full QNN SDK (specifically bin/x86_64-linux-clang tools like qnn-context-binary-generator).

# Usage: ./MNN2QNNModel <qnnSDKPath> <socId> <hexagonArch> <srcMNNPath> <outputDir>
./MNN2QNNModel /opt/qcom/qnn/sdk 43 73 model.mnn ./output
  • socId: e.g., 43 for Snapdragon 8 Gen 2.
  • hexagonArch: e.g., 73 for Hexagon V73.
  • Output: model_43_73.mnn and model_43_73.bin.

4. Compile Runtime (Android - ARM64)

Build libMNN.so with QNN support. Crucially, MNN_WITH_PLUGIN=ON is required for loading offline models, and MNN_QNN_CONVERT_MODE must be OFF.

mkdir build_android
cd build_android
cmake .. \
    -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
    -DANDROID_ABI="arm64-v8a" \
    -DANDROID_STL=c++_static \
    -DANDROID_NATIVE_API_LEVEL=android-21 \
    -DMNN_QNN=ON \
    -DMNN_WITH_PLUGIN=ON \
    -DQNN_SDK_ROOT=/path/to/qnn/sdk_or_deps
make -j4 libMNN

5. Run on Android

  1. Push Libraries:

    • libMNN.so (built above).
    • libQnnHtp.so, libQnnHtpVxxSkel.so, libQnnHtpVxxStub.so, libQnnSystem.so (from QNN SDK lib/aarch64-android/).
    • Push these to /data/local/tmp (or app lib dir).
  2. Push Model:

    • model_43_73.mnn and model_43_73.bin.
  3. Execute:

    • Set LD_LIBRARY_PATH to include the directory with QNN libs.
    • Run your MNN application loading model_43_73.mnn.
export LD_LIBRARY_PATH=/data/local/tmp:$LD_LIBRARY_PATH
./your_mnn_app /data/local/tmp/model_43_73.mnn

PR created automatically by Jules for task 4451591356993808856 started by @Juude


Note

Low Risk
Build-system-only change that broadens header search paths; low functional risk, with the main concern being potential include-order/header ambiguity if both layouts are present.

Overview
Fixes QNN builds against alternate SDK layouts by adding ${_QNN_ROOT}/include/ to MNN_QNN's include directories (in addition to the existing ${_QNN_ROOT}/include/QNN/).

Written by Cursor Bugbot for commit 3bef715. This will update automatically on new commits. Configure here.

Co-authored-by: Juude <2675838+Juude@users.noreply.github.com>
@google-labs-jules
Copy link

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant