Start the inference engine from both apps and show its choice in Settings
The desktop names where a package may have put libonnxruntime — an override variable, beside the executable, the package's own library directory, the Flatpak prefix, the system library directory — and Android points at the APK's native library directory, which is also what Qualcomm's DSP loader must be told for the Hexagon skel. Android starts the engine at the end of the model unpack rather than at launch, because the probe fingerprints the model files and a first launch has none until then. The About panel gains an Inference row beside Graphics, re-read every two seconds while the probe runs and engines land, and faces.model_id carries the detector's form: an int8 detector finds a different set of faces and is a different population (docs/inference.md §7). A low-memory signal drops every idle session with the GPU caches. The APK assembly bundles ONNX Runtime and the Qualcomm HTP libraries from Maven, fetched by tools/fetch-android-runtime.sh with their published checksums; RUNTIME_DIR=none builds the tract-only APK, which is a slower app and not a broken one. The desktop packages carry no runtime yet. Two probe fixes from the first desktop run: the floor must not be built with CPU fallback disabled, and a versioned libonnxruntime.so is a runtime too. On the reference desktop the probe now loads ONNX Runtime 1.30, measures 30 ms on the CPU provider, and selects TensorRT at 1.5 ms.
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
# JNILIBS where cargo-ndk wrote the .so (default: $TARGET_DIR/jniLibs)
|
||||
# OUT output directory (default: $TARGET_DIR/apk)
|
||||
# KEYSTORE signing keystore (default: $TARGET_DIR/debug.keystore)
|
||||
# RUNTIME_DIR the inference runtime (default: $TARGET_DIR/runtime,
|
||||
# fetched by tools/fetch-android-runtime.sh)
|
||||
# ABI Android ABI (default: arm64-v8a)
|
||||
# RUST_TARGET Rust target triple (default: aarch64-linux-android)
|
||||
#
|
||||
@@ -43,6 +45,7 @@ TARGET_DIR="$(cd "${TARGET_DIR}" && pwd)"
|
||||
JNILIBS="${JNILIBS:-${TARGET_DIR}/jniLibs}"
|
||||
OUT="${OUT:-${TARGET_DIR}/apk}"
|
||||
KEYSTORE="${KEYSTORE:-${TARGET_DIR}/debug.keystore}"
|
||||
RUNTIME_DIR="${RUNTIME_DIR:-${TARGET_DIR}/runtime}"
|
||||
|
||||
# Release signing is selected by supplying a password, not by a flag, so there
|
||||
# is no way to ask for a release build and silently get a debug one.
|
||||
@@ -255,6 +258,25 @@ fi
|
||||
cp "${SO}" "${OUT}/staging/lib/${ABI}/libdarkroom.so"
|
||||
cp "${DEX}" "${OUT}/staging/classes.dex"
|
||||
|
||||
# The inference runtime (docs/inference.md §3): ONNX Runtime and Qualcomm's
|
||||
# Hexagon backend, beside libdarkroom.so so the app finds them in its own
|
||||
# native library directory. The build links none of it — the app dlopens
|
||||
# `libonnxruntime.so` at launch and runs on tract if it is not there — so an
|
||||
# APK without these is a slower app, not a broken one, and `RUNTIME_DIR=none`
|
||||
# builds exactly that. 174 MB for the default set; the script says which
|
||||
# Hexagon generations that buys.
|
||||
if [[ "${RUNTIME_DIR}" != "none" ]]; then
|
||||
if [[ ! -f "${RUNTIME_DIR}/lib/libonnxruntime.so" ]]; then
|
||||
"${REPO}/tools/fetch-android-runtime.sh" "${RUNTIME_DIR}"
|
||||
fi
|
||||
cp "${RUNTIME_DIR}"/lib/*.so "${OUT}/staging/lib/${ABI}/"
|
||||
mkdir -p "${OUT}/staging/assets/licences"
|
||||
cp "${RUNTIME_DIR}"/QNN-*.* "${OUT}/staging/assets/licences/" 2>/dev/null || true
|
||||
echo " runtime: $(ls "${RUNTIME_DIR}/lib" | wc -l) libraries from ${RUNTIME_DIR}/lib"
|
||||
else
|
||||
echo " runtime: none (tract only)"
|
||||
fi
|
||||
|
||||
# The models. Android has no other route to one — app-private storage is not
|
||||
# user-reachable and the in-app fetch is unbuilt (docs/faces.md §2.2a) — so
|
||||
# they go in the APK and `android_main` unpacks them on first launch. The
|
||||
@@ -274,7 +296,7 @@ cp "${DEX}" "${OUT}/staging/classes.dex"
|
||||
#
|
||||
# Cleared first: a previous run that died between staging and cleanup would
|
||||
# otherwise leave models in the APK that are no longer in the tree.
|
||||
rm -rf "${OUT}/staging/assets"
|
||||
rm -rf "${OUT}/staging/assets/models"
|
||||
mkdir -p "${OUT}/staging/assets/models"
|
||||
_bundled=""
|
||||
for _dir in face scene; do
|
||||
@@ -315,7 +337,7 @@ fi
|
||||
# install times sane.
|
||||
cd "${OUT}/staging"
|
||||
cp "${OUT}/base.apk" "${OUT}/unaligned.apk"
|
||||
zip -q -0 -X "${OUT}/unaligned.apk" "lib/${ABI}/libdarkroom.so"
|
||||
zip -q -0 -X "${OUT}/unaligned.apk" lib/"${ABI}"/*.so
|
||||
zip -q -X "${OUT}/unaligned.apk" classes.dex
|
||||
# Stored, not deflated: an ONNX graph is mostly incompressible float data, so
|
||||
# deflating it buys a few percent and costs the whole file being inflated into
|
||||
|
||||
Reference in New Issue
Block a user