Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / library / ml / src / main / rust / Cargo.toml

Cargo.toml48 lines · 2.2 KiBRaw
1# The Vulkan compute ML runtime for `:library:ml`.
2#
3# Replaces `com.github.vayun-mathur:ncnn-android` for the two pure-CNN vision models
4# the repo ships: MediaPipe Selfie Segmentation (`:camera` portrait bokeh) and U^2-Net
5# portable (`:photos` auto-select-subject). ncnn stays for the two face models in
6# `:photos` and for `:library:ocr`, `:pdf`, `:translate` and `:speech`.
7#
8# Why this exists: the ncnn fork is built CPU-only (`NCNN_VULKAN=OFF`) and compiles
9# ncnn's entire layer registry into one `libncnn_android.so` for models that use a
10# small fraction of it. This runs on Vulkan compute with our own weights encoding and
11# only the ~11 shaders these two nets need.
12#
13# Why `ash` and not `androidx.webgpu`: the same reasoning as `library/map` — read the
14# header comment there. `features = ["loaded"]` dlopens the platform's Vulkan loader and
15# links nothing, so the only native code shipped is our own — and so the same code runs
16# on a development host, which is where the shaders get exercised before a phone sees
17# them.
18#
19# There is no graph interpreter: each net's forward pass is hardcoded Rust in `nets/`,
20# so a `.maml` file carries ordered tensors and no topology. See `src/weights.rs`.
21
22[package]
23name = "modelrunner"
24version = "0.1.0"
25edition = "2021"
26publish = false
27license = "GPL-2.0-only"
28description = "Vulkan compute ML runtime: .maml weights in, segmentation mask out"
29
30[lib]
31name = "modelrunner"
32# cdylib for the JNI surface; rlib so the host test binary can link it and exercise
33# the `.maml` reader and the CPU preprocessing without a device.
34crate-type = ["cdylib", "rlib"]
35
36[dependencies]
37jni.workspace = true
38jni_bridge = { path = "../../../../../library/jni-bridge/src/main/rust" }
39
40# `default-features = false` drops the `linked` feature, so nothing links against
41# libvulkan at build time; `loaded` dlopens it, which is what an Android app must do
42# anyway. It is not android-gated: `loaded` finds the platform loader on the host too,
43# which is the only way the shaders ever get executed before they reach a phone.
44ash = { workspace = true, default-features = false, features = ["loaded"] }
45
46# mmap for host row reads out of large weight files (`weights_part9.rs`).
47[target.'cfg(unix)'.dependencies]
48libc.workspace = true