Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / library / ml / src / main / rust / Cargo.toml
Cargo.toml47 lines · 2.1 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] |
| 23 | name = "modelrunner" |
| 24 | version = "0.1.0" |
| 25 | edition = "2021" |
| 26 | publish = false |
| 27 | license = "GPL-2.0-only" |
| 28 | description = "Vulkan compute ML runtime: .maml weights in, segmentation mask out" |
| 29 | |
| 30 | [lib] |
| 31 | name = "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. |
| 34 | crate-type = ["cdylib", "rlib"] |
| 35 | |
| 36 | [dependencies] |
| 37 | jni.workspace = true |
| 38 | |
| 39 | # `default-features = false` drops the `linked` feature, so nothing links against |
| 40 | # libvulkan at build time; `loaded` dlopens it, which is what an Android app must do |
| 41 | # anyway. It is not android-gated: `loaded` finds the platform loader on the host too, |
| 42 | # which is the only way the shaders ever get executed before they reach a phone. |
| 43 | ash = { workspace = true, default-features = false, features = ["loaded"] } |
| 44 | |
| 45 | # mmap for host row reads out of large weight files (`weights_part9.rs`). |
| 46 | [target.'cfg(unix)'.dependencies] |
| 47 | libc.workspace = true |