diff --git a/.gitattributes b/.gitattributes index a6344aac8c09253b3b630fb776ae94478aa0275b..dbc9fd7991d027afb52bf980d0845e6a4fe99478 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,35 +1,20 @@ -*.7z filter=lfs diff=lfs merge=lfs -text -*.arrow filter=lfs diff=lfs merge=lfs -text *.bin filter=lfs diff=lfs merge=lfs -text -*.bz2 filter=lfs diff=lfs merge=lfs -text -*.ckpt filter=lfs diff=lfs merge=lfs -text -*.ftz filter=lfs diff=lfs merge=lfs -text -*.gz filter=lfs diff=lfs merge=lfs -text -*.h5 filter=lfs diff=lfs merge=lfs -text -*.joblib filter=lfs diff=lfs merge=lfs -text -*.lfs.* filter=lfs diff=lfs merge=lfs -text -*.mlmodel filter=lfs diff=lfs merge=lfs -text -*.model filter=lfs diff=lfs merge=lfs -text -*.msgpack filter=lfs diff=lfs merge=lfs -text -*.npy filter=lfs diff=lfs merge=lfs -text -*.npz filter=lfs diff=lfs merge=lfs -text -*.onnx filter=lfs diff=lfs merge=lfs -text -*.ot filter=lfs diff=lfs merge=lfs -text -*.parquet filter=lfs diff=lfs merge=lfs -text -*.pb filter=lfs diff=lfs merge=lfs -text -*.pickle filter=lfs diff=lfs merge=lfs -text -*.pkl filter=lfs diff=lfs merge=lfs -text -*.pt filter=lfs diff=lfs merge=lfs -text -*.pth filter=lfs diff=lfs merge=lfs -text -*.rar filter=lfs diff=lfs merge=lfs -text -*.safetensors filter=lfs diff=lfs merge=lfs -text -saved_model/**/* filter=lfs diff=lfs merge=lfs -text -*.tar.* filter=lfs diff=lfs merge=lfs -text -*.tar filter=lfs diff=lfs merge=lfs -text *.tflite filter=lfs diff=lfs merge=lfs -text -*.tgz filter=lfs diff=lfs merge=lfs -text -*.wasm filter=lfs diff=lfs merge=lfs -text -*.xz filter=lfs diff=lfs merge=lfs -text +*.gguf filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.wav filter=lfs diff=lfs merge=lfs -text +*.so filter=lfs diff=lfs merge=lfs -text +*.bf16 filter=lfs diff=lfs merge=lfs -text +*.f16 filter=lfs diff=lfs merge=lfs -text +*.f32 filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.tkb filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text -*.zst filter=lfs diff=lfs merge=lfs -text -*tfevents* filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..eed7da50ce0babf77c2349475aaa6fdfe7a2e06d --- /dev/null +++ b/LICENSE @@ -0,0 +1,16 @@ +MIT License + +Copyright (c) the authors of moonshine-ai/moonshine-streaming (Moonshine AI) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit +persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000000000000000000000000000000000000..611186cbd642e67b518e5208771f30bf76c29ddc --- /dev/null +++ b/NOTICE @@ -0,0 +1,4 @@ +This repository is a modified version of moonshine-ai/moonshine-streaming by Moonshine AI, revision da30bae714913eb0057e733bccb4700104afb1b0. + +Changes, made by nnopt (https://nnopt.dev): +- `sm8850-npu-fp16/` (nnopt job NN-466F3D): included: models/*.tflite (4 graphs AOT-compiled for SM8850 by nnopt, Moonshine v2 Streaming Medium) and models/vocab.bin; Qualcomm's QNN runtime is fetched. The runtime code (src/, build.sh, deploy.sh, run.sh) is new, written by nnopt's agents for this device. diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d8bd41848c0c02c3a97873d30a50a1bdc2b2d100 --- /dev/null +++ b/README.md @@ -0,0 +1,76 @@ +--- +license: mit +base_model: moonshine-ai/moonshine-streaming +pipeline_tag: automatic-speech-recognition +tags: +- on-device +- nnopt +- litert +- tflite +- android +- npu +- hexagon +- qualcomm +- asr +- streaming +- galaxy-s26-plus +--- + +# moonshine-streaming on Samsung Galaxy S26+ (LiteRT) + +Ported and verified on a real Samsung Galaxy S26+ by [nnopt.dev](https://nnopt.dev) — AI agents that port and optimize models for the hardware you ship. + +The model is [moonshine-ai/moonshine-streaming](https://huggingface.co/moonshine-ai/moonshine-streaming) by Moonshine AI, and it is theirs. The LiteRT port in this repository is nnopt's work: nnopt job NN-466F3D. + +| | | +|---|---| +| Device | Samsung Galaxy S26+, Android 16 | +| Chip | Snapdragon 8 Elite Gen 5 (SM8850) | +| Processor | NPU (Hexagon HTP v81) for every model graph; CPU for WAV I/O, chunking, argmax, detokenizing | +| Runtime | LiteRT 2.3.1 (Qualcomm dispatch), QNN 2.50.0 | +| Precision | FP16 on the HTP (fp32-exported graphs, AOT-compiled; fp16 cross/self KV cache I/O) | +| Modality | speech -> text (streaming ASR) | +| Weights | included: models/*.tflite (4 graphs AOT-compiled for SM8850 by nnopt, Moonshine v2 Streaming Medium) and models/vocab.bin; Qualcomm's QNN runtime is fetched | +| nnopt job | NN-466F3D (port) | +| Folder | [`sm8850-npu-fp16/`](https://huggingface.co/nnopt-dev/moonshine-streaming-LiteRT/tree/main/sm8850-npu-fp16) | + +## Verified results + +nnopt built the folder from a clean copy, deployed it to the device and checked it against the model's reference code on hidden inputs. The full report is `report.html` in the folder. + +- Passed. Word error rate vs reference 0.0% (bar at most 2.0%, original precision) +- full check passed +- no speculative decoding +- Real-time factor 0.076 (faster than real time) +- Latency 436 ms +- Decode 40.3 tokens/s +- Load time 286 ms +- Peak memory 623 MB +- 4 graphs, NPU 100% + +## Use it + +``` +mkdir moonshine-streaming-LiteRT && cd moonshine-streaming-LiteRT +curl -fsSL https://huggingface.co/nnopt-dev/moonshine-streaming-LiteRT/resolve/main/config.json -o config.json +hf download nnopt-dev/moonshine-streaming-LiteRT --include "sm8850-npu-fp16/*" --local-dir . +cd sm8850-npu-fp16 +bash fetch.sh +bash deploy.sh /data/local/tmp/moonshine # adb: runner, LiteRT, QNN libs, 4 NPU graphs +adb push demo/input.wav /data/local/tmp/moonshine/in.wav +adb shell 'cd /data/local/tmp/moonshine && sh ./run.sh --audio in.wav --out out.json --metrics m.json' +``` + +Needs: A Snapdragon SM8850 phone (Galaxy S26+), adb, ~1.3 GB free storage; curl and unzip on the host. Rebuilding the runner (`bash build.sh`) fetches the NDK itself. + +`README.md` in the folder has every flag, the requirements and the known limits; `REPRO.md` (where present) reproduces the measurements. + +## License + +MIT, like moonshine-ai/moonshine-streaming: see LICENSE and NOTICE. LiteRT in `vendor/litert/` is Apache 2.0. Qualcomm's QNN runtime is not here: `fetch.sh` gets it from Maven Central, under Qualcomm's license. + +## Made with nnopt + +[nnopt](https://nnopt.dev) is a platform where AI agents port, optimize and benchmark a model for a specific device. They write the runtime code on the real device, and a locked verification kit then checks the result against the model's own reference code before anything ships. Every number on this page comes from that check. + +Want your model on your device? Start a job at [nnopt.dev](https://nnopt.dev). diff --git a/config.json b/config.json new file mode 100644 index 0000000000000000000000000000000000000000..e2d2237051ba1aa1caf1e99831fc085002999c65 --- /dev/null +++ b/config.json @@ -0,0 +1,33 @@ +{ + "nnopt_manifest": 1, + "repo": "nnopt-dev/moonshine-streaming-LiteRT", + "model": { + "name": "moonshine-streaming", + "source_repo": "moonshine-ai/moonshine-streaming", + "source_revision": "da30bae714913eb0057e733bccb4700104afb1b0", + "authors": "Moonshine AI", + "license": "mit" + }, + "variants": [ + { + "id": "sm8850-npu-fp16", + "device": "Samsung Galaxy S26+", + "chip": "Snapdragon 8 Elite Gen 5 (SM8850)", + "os": "Android 16", + "processor": "NPU (Hexagon HTP v81) for every model graph; CPU for WAV I/O, chunking, argmax, detokenizing", + "runtime": "LiteRT 2.3.1 (Qualcomm dispatch), QNN 2.50.0", + "runtime_version": "LiteRT 2.3.1 + QNN 2.50.0", + "precision": "FP16 on the HTP (fp32-exported graphs, AOT-compiled; fp16 cross/self KV cache I/O)", + "weights": "included: models/*.tflite (4 graphs AOT-compiled for SM8850 by nnopt, Moonshine v2 Streaming Medium) and models/vocab.bin; Qualcomm's QNN runtime is fetched", + "nnopt_job": "NN-466F3D", + "job_kind": "port", + "verified": { + "verdict": "Passed. Word error rate vs reference 0.0% (bar at most 2.0%, original precision); full check passed; no speculative decoding", + "speed": "Real-time factor 0.076 (faster than real time); Latency 436 ms; Decode 40.3 tokens/s; Load time 286 ms; Peak memory 623 MB; 4 graphs, NPU 100%" + }, + "fetch": "sm8850-npu-fp16/fetch.sh" + } + ], + "license": "mit", + "made_by": "nnopt (https://nnopt.dev)" +} diff --git a/sm8850-npu-fp16/README.md b/sm8850-npu-fp16/README.md new file mode 100644 index 0000000000000000000000000000000000000000..e538082ee3e8d3ce80a8efe3552987ba13b8c27f --- /dev/null +++ b/sm8850-npu-fp16/README.md @@ -0,0 +1,125 @@ +# Moonshine v2 Streaming Medium on the Galaxy S26+ NPU (LiteRT) + +Streaming speech to text with Moonshine v2 Streaming Medium (moonshine-ai/moonshine-streaming @ da30bae, the +`tensilier` checkpoint, 245 M parameters). Audio is consumed in 320 ms chunks; the program prints partial transcripts +while audio arrives and the final transcript at the end. + +- Device: Samsung Galaxy S26+ (Snapdragon 8 Elite Gen 5, SM8850), Android 16 +- Runtime: LiteRT 2.3.1 C API with the Qualcomm dispatch, QNN (QAIRT) 2.50.0 +- Processor: Hexagon NPU (HTP v81), every model graph: 4 graphs, 100% DISPATCH_OP, no CPU or GPU fallback. + The CPU only does glue: WAV reading, chunking, state copies, greedy argmax, detokenizing. +- Precision: fp16 (fp32 graphs compiled for the HTP, fp16 K/V caches, fp32 logits) + +## Layout +``` +src/runner.c the phone program (moonshine_stream), LiteRT C API +src/run.sh entry point on the phone (sets LD_LIBRARY_PATH / ADSP_LIBRARY_PATH) +src/port.json runtime description copied to DEST +src/moonshine_npu.py the graphs as static-shape PyTorch modules (EncoderChunk, DecoderStep), fp16-safe rewrites +src/export_tflite.py export to .tflite with litert-torch + CPU check; src/vm_pipeline.sh export + src/aot_compile.py AOT compile +src/convert_ckpt.py customer checkpoint -> transformers-style state dict (weight norm folded) +src/make_vocab.py tokenizer.json -> models/vocab.bin (token bytes for the runner's detokenizer) +src/host_stream.py host (CPU, torch) model of the same streaming loop, with --check-hf against transformers +src/make_cases.py captures real graph inputs for export checks +models/ the compiled NPU models (SM8850 only) and vocab.bin +vendor/litert/2.3.1/ libLiteRt.so, libLiteRtDispatch_Qualcomm.so, headers, LICENSE (Apache 2.0), SHA256SUMS +``` + +## Requirements +- Build host: Linux x86-64 or macOS, with bash, curl, unzip, python3 and internet access. build.sh fetches the + Android NDK r27d and Qualcomm's qnn-runtime 2.50.0 AAR (Maven Central, sha256-pinned) into `.deps/`. +- adb with the phone connected (ANDROID_SERIAL selects it). No root. + +## Build, deploy, run +``` +bash build.sh # -> build/moonshine_stream, build/stage/ +bash deploy.sh /data/local/tmp/nnopt/port # pushes runner, libs, models; leaves run.sh and port.json +adb shell "cd /data/local/tmp/nnopt/port && sh ./run.sh --audio /data/local/tmp/in.wav --out /data/local/tmp/out.json --metrics /data/local/tmp/m.json" +``` +run.sh flags: +- `--audio IN.wav` 16 kHz mono 16-bit PCM; `--out OUT.json` writes `{"text": ..., "partials": [{"audio_s", "text"}]}` +- `--metrics M.json` load_ms, and per run total_ms, ttft_ms (= time to first partial), first_partial_audio_s, + chunk_ms (per 320 ms chunk), chunk_latency_ms, final_decode_ms, decode_ms_per_token, rtf, end_latency_ms +- `--repeat R` repeat the request R times in one process (warm timings) +- `--partial-every SEC` partial transcript interval (default 1.0; 0 = final transcript only) +- `--realtime` feed chunks at live-microphone pace (a chunk is processed when it would have arrived), to measure + latency per chunk and time to first partial as a live user sees them +- `--quiet` no PARTIAL/FINAL lines on stderr + +## Check +``` +nnopt-verify check --split public --bundle --port /data/local/tmp/nnopt/port +``` + +## Measured (Galaxy S26+, burst mode) +| | | +|---|---| +| WER vs the PyTorch reference, 13 public LibriSpeech cases | 0.0 (bar 0.02) | +| Encoder per 320 ms chunk | 4.3 ms | +| Decoder per token (graph for <=10 s / <=30 s / <=82 s audio) | 5.5 / 6.6 / 8.6 ms | +| p002, 5.9 s, as fast as possible (with 5 partials) | 639 ms, RTF 0.11 | +| p010, 13.3 s, as fast as possible (with 13 partials) | 2.67 s, RTF 0.20 | +| --realtime p002: first partial | at 1.28 s of audio, 41 ms after its chunk arrived | +| --realtime p002: final transcript after the end of speech | 144 ms | +| Load (4 context binaries) | 0.32-0.34 s | +| 48 s (two cases joined), largest decoder graph | 11.8 s, RTF 0.245, transcript identical to host fp32 | +| nnopt-verify bench (p000, 5.7 s): request latency / RTF | 439 ms / 0.077 (median of 10) | +| nnopt-verify bench: sustained 10 min | RTF 0.077-0.085, 96 runs, 0 failures; peak memory 621 MB | + +## Known limits +- At most 81.9 s of audio per request (the model's 4096-position table); longer input fails with an error. +- A partial is a full greedy re-decode of the audio so far. To keep long inputs fast, the next partial waits at least + max(--partial-every, 0.04 s x the tokens the last partial decoded) of audio: short utterances get one per second, + long ones fewer (48 s test: 20 partials, RTF 0.25 instead of 0.84). The final transcript is unaffected. +- The model itself drops words on very long single utterances (a 48 s test stopped mid-sentence); the port matches the + PyTorch reference exactly there too. +- The models are compiled for SM8850 (HTP v81) only. + +## How the models were made +On an x86-64 Linux machine with Python 3.12 and >= 64 GB RAM (they were made on 16 vCPU / 128 GB): +``` +bash src/vm_pipeline.sh ~/moonshine-export enc16 dec512h dec1536h dec4096h +``` +It creates its own venv from src/export_requirements.txt (torch 2.14.1 CPU, litert-torch 0.10.0, ai-edge-litert 2.3.0, +ai-edge-quantizer 0.10.0, ai-edge-litert-sdk-qualcomm 2.3.0 = the QAIRT 2.50 AOT compiler; top-level pins, the full +transitive freeze of the original machine was not recorded), downloads tensilier @ da30bae (sha256-checked), exports +each graph with src/export_tflite.py (checked on the CPU against the torch module) and compiles it for SM8850 with +src/aot_compile.py, which fails unless every op went to the NPU. About a minute per graph. + +sha256 of the shipped files in models/: +``` +a8010fb0397243d2d67c4c84f8f76ff85d6f94cf35467c3b8157f556e2563d3b enc16_Qualcomm_SM8850_apply_plugin.tflite +7b1b4993c19de245475f04f8f404a5de7e0b564eae9342c9f8ef0e0e75c48222 dec512h_Qualcomm_SM8850_apply_plugin.tflite +a28fad21faf2097c7141316fb1417260338c4de8737e7f79890e4f32e5d5cc8b dec1536h_Qualcomm_SM8850_apply_plugin.tflite +c6f23a91a62d214af113ee469001b6cc82741e34ca7dadec8af6fb61a38e0e7c dec4096h_Qualcomm_SM8850_apply_plugin.tflite +5b3e9c217d081a41c249dd4bf991da435d339ecc139360f2b149dbdaef2a3359 vocab.bin +``` +Details, fp16 fixes, the NPU proof: NOTES.md. + +## Verified by nnopt + +**Passed** moonshine-ai/moonshine-streaming on Samsung Galaxy S26+ (2026-11-03). nnopt built this folder from a clean copy, deployed it to the device and ran it on hidden inputs; the full report is report.html. + +| Check | Measured | Bar | Result | +|---|---|---|---| +| Outputs match your reference code | Word error rate vs reference 0.0% | at most 2.0% (original precision) | pass | +| Runs on LiteRT and QNN and the Hexagon NPU | src/runner.c:95: if (LiteRtCreateModelFromFile(env, path, &g->model) != kLiteRtStatusOk) DIE("cannot load model %s", path); | the runtime you asked for | pass | +| Decodes one token per pass | one token per pass through the model: no speculative decoding in the port's code | no speculative decoding | pass | + +| Speed | This port | +|---|---| +| Real-time factor | 0.076 | +| Latency | 436 ms | +| Decode, tokens/s | 40.3 | +| Load time | 286 ms | +| Peak memory | 623 MB | + +| Measurement | Median | +|---|---| +| Real-time factor | 0.0761763 | +| Latency | 435.695 ms | +| Decode | 40.3124 tokens/s (23% of roofline) | +| Load time | 285.8 ms | +| Peak memory | 622.8 MB | + +To get these results on your own device, follow REPRO.md. diff --git a/sm8850-npu-fp16/REPRO.md b/sm8850-npu-fp16/REPRO.md new file mode 100644 index 0000000000000000000000000000000000000000..3b019526014e31dc6f406a1ac8c49f0f4480e35c --- /dev/null +++ b/sm8850-npu-fp16/REPRO.md @@ -0,0 +1,141 @@ +# Reproduce: moonshine-ai/moonshine-streaming on Samsung Galaxy S26+ + +nnopt ported this (NN-466F3D, 2026-11-03). Runtime: LiteRT 2.3.1, Qualcomm dispatch, QNN 2.50.0. Follow the steps on the same device model and OS build; the results should land within the tolerances in the last table. + +## 1. Device + +| Property | nnopt ran on | +|---|---| +| Chip | Snapdragon 8 Elite Gen 5 | +| GPU | Adreno 840 | +| Memory | 12 GB | +| OS | Android 16 | + +Keep the phone plugged in, screen on and awake (Developer options > Stay awake), no other apps open, and let it rest about 10 minutes before measuring (a warm phone throttles). + +## 2. Tools + +**Tested:** nnopt built this folder from scratch on 2026-11-03 in the public image `ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac` with only these packages installed: git, curl, python3, python3-venv, build-essential, unzip, xz-utils. build.sh fetched everything else itself (its downloads are listed under step 3), and that build is the one nnopt deployed and measured. + +Any Linux x86-64 machine with those packages builds it. build.sh is written to build on macOS arm64 as well (Xcode command line tools, git, curl, python3); nnopt did not test that for this deliverable. + +| Tool | Version | Get it | +|---|---|---| +| gcc | 13.3.0 | – | +| Python | 3.12.3 | https://www.python.org/downloads/ | +| git | 2.43.0 | – | +| curl | 8.5.0 | – | + +To deploy and measure you also need adb (Android platform-tools) and python3 (3.8 or newer, no packages). + +build.sh and deploy.sh read these environment variables: + +- `ANDROID_NDK`: the Android NDK folder (same as ANDROID_NDK_HOME) +- `BUILD`: set it before building +- `DEPS`: set it before building +- `WORK_ROOT`: set it before building + +The same machine in Docker (`repro/Dockerfile`: the public image and packages above, nothing else): + +``` +docker build --platform linux/amd64 -t build-env repro +docker run --rm --platform linux/amd64 --user "$(id -u):$(id -g)" -e HOME=/tmp -v "$PWD:/src" -w /src build-env bash build.sh +``` + +## 3. Model and inputs + +**reference_code**: Hugging Face `moonshine-ai/moonshine-streaming` at revision `da30bae714913eb0057e733bccb4700104afb1b0`. + +``` +huggingface-cli download moonshine-ai/moonshine-streaming --revision da30bae714913eb0057e733bccb4700104afb1b0 .gitattributes README.md slinkier/model.safetensors spindlier/model.safetensors tensilier/model.safetensors --local-dir inputs/reference_code +``` + +| File | Size | sha256 | +|---|---|---| +| .gitattributes | 2.5 KB | `9cc1f73aa682dd96559d3671e8e09bea75ddf6be105f043e3841211c7b37ce87` | +| README.md | 24 B | `d8d7a46d41a1a37fe4f0a5f637bf55c649310185329127d8a2204632e480be17` | +| slinkier/model.safetensors | 128.1 MB | `da9fb3e3aa7d5596427c4173dfc738d8dbb2035dcfff29edff51f752e9730246` | +| spindlier/model.safetensors | 470.6 MB | `c6d88232d9258262a01aa7e6e7c77f5dda87618dca93ed30080552b52b2a8159` | +| tensilier/model.safetensors | 934.4 MB | `6a454dd0a064151946c7076d7b89c79d42a02eb41fc261083392a0349a34d86f` | + +**weights**: Hugging Face `moonshine-ai/moonshine-streaming` at revision `da30bae714913eb0057e733bccb4700104afb1b0`. + +``` +huggingface-cli download moonshine-ai/moonshine-streaming --revision da30bae714913eb0057e733bccb4700104afb1b0 .gitattributes README.md slinkier/model.safetensors spindlier/model.safetensors tensilier/model.safetensors --local-dir inputs/weights +``` + +| File | Size | sha256 | +|---|---|---| +| .gitattributes | 2.5 KB | `9cc1f73aa682dd96559d3671e8e09bea75ddf6be105f043e3841211c7b37ce87` | +| README.md | 24 B | `d8d7a46d41a1a37fe4f0a5f637bf55c649310185329127d8a2204632e480be17` | +| slinkier/model.safetensors | 128.1 MB | `da9fb3e3aa7d5596427c4173dfc738d8dbb2035dcfff29edff51f752e9730246` | +| spindlier/model.safetensors | 470.6 MB | `c6d88232d9258262a01aa7e6e7c77f5dda87618dca93ed30080552b52b2a8159` | +| tensilier/model.safetensors | 934.4 MB | `6a454dd0a064151946c7076d7b89c79d42a02eb41fc261083392a0349a34d86f` | + +build.sh also downloads: + +| Download | Pinned | +|---|---| +| `curl -fL --retry 3 -o "$DEPS/$NDK_ZIP" "https://dl.google.com/android/repository/$NDK_ZIP"` | yes: a checksum or a versioned link | + +## 4. Build + +``` +bash build.sh +``` + +## 5. Connect the device + +``` +adb devices +``` + +One device should be listed as `device`. With several, set `export ANDROID_SERIAL=` first. + +## 6. Deploy + +``` +bash deploy.sh /data/local/tmp/nnopt/port +``` + +## 7. Run one input by hand + +``` +adb shell 'mkdir -p /data/local/tmp/nnopt/port-repro-io' +adb push repro/inputs/input.wav /data/local/tmp/nnopt/port-repro-io/ +adb shell 'cd /data/local/tmp/nnopt/port && sh ./run.sh --audio /data/local/tmp/nnopt/port-repro-io/input.wav --out /data/local/tmp/nnopt/port-repro-io/out.json --metrics /data/local/tmp/nnopt/port-repro-io/metrics.json' +adb pull /data/local/tmp/nnopt/port-repro-io/out.json . +adb pull /data/local/tmp/nnopt/port-repro-io/metrics.json . +``` + +`out.json` is the output; `metrics.json` holds the program's own timings: `load_ms`, and per request `total_ms`. + +## 8. Measure + +``` +python3 repro/bench.py +``` + +bench.py runs nnopt's settings: 2 warm-up runs, then 5 timed runs of 3 requests each. Each run is timed on the device's own clock, and a paired shorter run checks the program's own timings, as nnopt does. `--sustained 600` adds nnopt's 10-minute sustained run. + +## 9. Check the outputs + +``` +python3 repro/bench.py --check +``` + +Runs the 13 public cases in `repro/expected/` and compares with the reference outputs of your reference code: word error rate against the expected transcripts at most 2%. + +nnopt's full check also used hidden inputs and teacher-forced comparisons; report.html has every number. + +## Expected results + +| Metric | nnopt (median) | Spread (p10 to p90) | Reproduced if within | +|---|---|---|---| +| Real-time factor (x) | 0.0762 | 0.0759 to 0.0767 | ±10% | +| Time per request (ms) | 435.7 | 434.3 to 438.6 | ±10% | +| Peak memory (MB) | 622.8 | – | ±10% (shown only) | + +Each tolerance is half of nnopt's own spread between requests, at least ±10%. Numbers land outside it when the device is warm or throttling, runs another OS build or driver, has apps or battery saver running, or is not plugged in. bench.py prints the same table for your device and writes it to `repro/results/`. + +`report/reproduce.sh` runs steps 8 and 9 in one go. diff --git a/sm8850-npu-fp16/build.sh b/sm8850-npu-fp16/build.sh new file mode 100644 index 0000000000000000000000000000000000000000..f2e8998b7cfbf07190a73c6c34d55083f5e3889e --- /dev/null +++ b/sm8850-npu-fp16/build.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash +# Builds the phone runner (src/runner.c -> moonshine_stream, arm64 Android) against the LiteRT 2.3.1 C API shipped in +# vendor/litert/2.3.1, and fetches the Qualcomm QNN 2.50.0 runtime libraries (not redistributable: fetched by version +# and sha256 from Google's Maven Central mirror). The compiled NPU models ship in models/ (made by src/export_tflite.py +# and litert-aot on an x86-64 Linux machine, see README.md); this script never exports or compiles models. +# +# Needs: bash, curl, unzip, shasum or sha256sum, python3 (only for the path hash). Fetches the Android NDK r27d into +# .deps/ (or uses $ANDROID_NDK when it is that exact release). Works on Linux x86-64 and macOS. +set -euo pipefail +cd "$(dirname "$0")" +ROOT=$PWD +NAME=moonshine-streaming-npu + +# .deps/ and build/ next to this script, or under $HOME/.cache when the folder is read-only (deploy.sh does the same) +. "$ROOT/src/paths.sh" +mkdir -p "$DEPS" "$BUILD" +[ "$DEPS" = "$ROOT/.deps" ] || echo "build.sh: folder is read-only; using $WORK_ROOT for .deps and build" + +sha_check() { # sha_check FILE SHA + local got + if command -v sha256sum >/dev/null 2>&1; then got=$(sha256sum "$1" | cut -d' ' -f1); else got=$(shasum -a 256 "$1" | cut -d' ' -f1); fi + if [ "$got" != "$2" ]; then echo "build.sh: sha256 mismatch for $1: $got (want $2)" >&2; return 1; fi +} + +# ---- Android NDK r27d +NDK_REL=r27d; NDK_REV=27.3.13750724 +case "$(uname -s)" in + Linux) NDK_ZIP=android-ndk-$NDK_REL-linux.zip; NDK_SHA=601246087a682d1944e1e16dd85bc6e49560fe8b6d61255be2829178c8ed15d9; HOST_TAG=linux-x86_64 ;; + Darwin) NDK_ZIP=android-ndk-$NDK_REL-darwin.zip; NDK_SHA=e69092f9d2bfa5d1199039980a14eb91c03cc971ab5c6968fc08a8e6b84e7bb7; HOST_TAG=darwin-x86_64 ;; + *) echo "build.sh: unsupported host $(uname -s)" >&2; exit 1 ;; +esac +if [ -n "${ANDROID_NDK:-}" ] && grep -q "Pkg.Revision = $NDK_REV" "$ANDROID_NDK/source.properties" 2>/dev/null; then + NDK=$ANDROID_NDK +else + NDK=$DEPS/android-ndk-$NDK_REL + if ! grep -q "Pkg.Revision = $NDK_REV" "$NDK/source.properties" 2>/dev/null; then + echo "build.sh: fetching Android NDK $NDK_REL" + rm -rf "$NDK" + curl -fL --retry 3 -o "$DEPS/$NDK_ZIP" "https://dl.google.com/android/repository/$NDK_ZIP" + sha_check "$DEPS/$NDK_ZIP" "$NDK_SHA" + (cd "$DEPS" && unzip -q "$NDK_ZIP" && rm "$NDK_ZIP") + chmod -R u+w "$NDK" + fi +fi +CC=$NDK/toolchains/llvm/prebuilt/$HOST_TAG/bin/clang +[ -x "$CC" ] || { echo "build.sh: no clang at $CC" >&2; exit 1; } + +# ---- QNN runtime 2.50.0 (QAIRT 2.50.0.260828), the release the models were compiled with +QNN_VER=2.50.0 +QNN_AAR=qnn-runtime-$QNN_VER.aar +QNN_SHA=b507656e4031d8aa6a7ab0fecf725b941096737ad7440ad7ea288f7c9cc9d743 +QNN_DIR=$DEPS/qnn-runtime-$QNN_VER +if [ ! -f "$QNN_DIR/.ok" ]; then + echo "build.sh: fetching qnn-runtime $QNN_VER" + rm -rf "$QNN_DIR"; mkdir -p "$QNN_DIR" + curl -fL --retry 3 -o "$DEPS/$QNN_AAR" \ + "https://storage.googleapis.com/maven-central/maven2/com/qualcomm/qti/qnn-runtime/$QNN_VER/$QNN_AAR" + sha_check "$DEPS/$QNN_AAR" "$QNN_SHA" + (cd "$QNN_DIR" && unzip -q -o "$DEPS/$QNN_AAR" jni/arm64-v8a/libQnnHtp.so jni/arm64-v8a/libQnnSystem.so \ + jni/arm64-v8a/libQnnHtpV81Stub.so jni/arm64-v8a/libQnnHtpV81Skel.so LICENSE.pdf && chmod -R u+w .) + rm "$DEPS/$QNN_AAR" + touch "$QNN_DIR/.ok" +fi + +# ---- the runner +LRT=$ROOT/vendor/litert/2.3.1 +(cd "$LRT" && if command -v sha256sum >/dev/null 2>&1; then sha256sum -c --quiet SHA256SUMS; else shasum -a 256 -c --quiet SHA256SUMS; fi) +"$CC" --target=aarch64-linux-android31 -O2 -std=c11 -Wall -Wno-unused-function \ + -I"$LRT/include" "$ROOT/src/runner.c" -L"$LRT" -lLiteRt -lm -o "$BUILD/moonshine_stream" + +# ---- the phone folder, flat (deploy.sh pushes it as is, with models/) +STAGE=$BUILD/stage +rm -rf "$STAGE"; mkdir -p "$STAGE/dsp" +cp "$BUILD/moonshine_stream" "$LRT/libLiteRt.so" "$LRT/libLiteRtDispatch_Qualcomm.so" "$STAGE/" +cp "$QNN_DIR/jni/arm64-v8a/libQnnHtp.so" "$QNN_DIR/jni/arm64-v8a/libQnnSystem.so" \ + "$QNN_DIR/jni/arm64-v8a/libQnnHtpV81Stub.so" "$STAGE/" +cp "$QNN_DIR/jni/arm64-v8a/libQnnHtpV81Skel.so" "$STAGE/dsp/" +cp "$ROOT/src/run.sh" "$ROOT/src/port.json" "$STAGE/" +echo "build.sh: built $BUILD/moonshine_stream; phone folder staged in $STAGE (models from $ROOT/models)" diff --git a/sm8850-npu-fp16/build/moonshine_stream b/sm8850-npu-fp16/build/moonshine_stream new file mode 100644 index 0000000000000000000000000000000000000000..908b508ef39b363937f327ac0ee9a720af99b735 Binary files /dev/null and b/sm8850-npu-fp16/build/moonshine_stream differ diff --git a/sm8850-npu-fp16/build/stage/libLiteRt.so b/sm8850-npu-fp16/build/stage/libLiteRt.so new file mode 100644 index 0000000000000000000000000000000000000000..31d35401746a2e7e5c130fe2c4276311fc1a33e6 --- /dev/null +++ b/sm8850-npu-fp16/build/stage/libLiteRt.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9ad1a5072b09087bddeb3d7be22854350191b21239136b78ebee2120443c7305 +size 5475936 diff --git a/sm8850-npu-fp16/build/stage/libLiteRtDispatch_Qualcomm.so b/sm8850-npu-fp16/build/stage/libLiteRtDispatch_Qualcomm.so new file mode 100644 index 0000000000000000000000000000000000000000..fcc0062c3c57104d574bb2629f04ea4f9e12ce58 --- /dev/null +++ b/sm8850-npu-fp16/build/stage/libLiteRtDispatch_Qualcomm.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab6a581ef26d83f60d03ff4ce2436d9a75b7d0c0b276357787a865e5e9dd4b7d +size 445712 diff --git a/sm8850-npu-fp16/build/stage/moonshine_stream b/sm8850-npu-fp16/build/stage/moonshine_stream new file mode 100644 index 0000000000000000000000000000000000000000..908b508ef39b363937f327ac0ee9a720af99b735 Binary files /dev/null and b/sm8850-npu-fp16/build/stage/moonshine_stream differ diff --git a/sm8850-npu-fp16/build/stage/port.json b/sm8850-npu-fp16/build/stage/port.json new file mode 100644 index 0000000000000000000000000000000000000000..0daa24a3f85c1c9a56c19e5364e6e6ab369feb95 --- /dev/null +++ b/sm8850-npu-fp16/build/stage/port.json @@ -0,0 +1,15 @@ +{ + "contract": 1, + "model_type": "speech_to_text", + "model": "Moonshine v2 Streaming Medium (moonshine-ai/moonshine-streaming, tensilier checkpoint)", + "runtime": "LiteRT 2.3.1, Qualcomm dispatch, QNN 2.50.0", + "litert_version": "2.3.1", + "backend": "litert-qnn", + "soc": "SM8850", + "htp_arch": "v81", + "qairt_version": "2.50.0", + "precision": "fp16", + "cpu_fallback": false, + "graphs": ["enc16_Qualcomm_SM8850_apply_plugin.tflite", "dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "dec1536h_Qualcomm_SM8850_apply_plugin.tflite", "dec4096h_Qualcomm_SM8850_apply_plugin.tflite"] +} diff --git a/sm8850-npu-fp16/build/stage/run.sh b/sm8850-npu-fp16/build/stage/run.sh new file mode 100644 index 0000000000000000000000000000000000000000..8f919a1e8ec478e7b62d314b7bd5b466b1326098 --- /dev/null +++ b/sm8850-npu-fp16/build/stage/run.sh @@ -0,0 +1,6 @@ +# Moonshine v2 Streaming Medium on the Hexagon NPU (LiteRT 2.3.1, QNN 2.50, SM8850). +# sh ./run.sh --audio IN.wav --out OUT.json [--metrics M.json] [--repeat R] [--partial-every SEC] [--realtime] +cd "$(dirname "$0")" || exit 1 +export LD_LIBRARY_PATH="$PWD:/system/lib64:/vendor/lib64" +export ADSP_LIBRARY_PATH="$PWD/dsp;$PWD;/vendor/lib/rfsa/adsp;/vendor/dsp/cdsp;/system/lib/rfsa/adsp;/vendor/dsp" +exec ./moonshine_stream "$@" diff --git a/sm8850-npu-fp16/demo/demo.json b/sm8850-npu-fp16/demo/demo.json new file mode 100644 index 0000000000000000000000000000000000000000..47ddff3b6e45d896335fc1730f3fe5e33ddbc908 --- /dev/null +++ b/sm8850-npu-fp16/demo/demo.json @@ -0,0 +1,32 @@ +{ + "input": { + "text": "5.9 s LibriSpeech utterance (public case p002), streamed in 320 ms chunks at real-time pace", + "files": [ + "demo/input.wav" + ] + }, + "source": "chosen by the agent: the model card has no example input; a public LibriSpeech test utterance is typical English read speech", + "output": { + "text": "Mister Quilter is the apostle of the middle classes, and we are glad to welcome his gospel.", + "files": [ + "demo/output.json", + "demo/metrics.json" + ] + }, + "seconds": 6.44, + "device": "Samsung Galaxy S26+ (SM8850, Hexagon v81 NPU)", + "command": "sh ./run.sh --audio /data/local/tmp/nnopt/demo_in.wav --out /data/local/tmp/nnopt/demo_out.json --metrics /data/local/tmp/nnopt/demo_metrics.json --realtime", + "notes": "--realtime waits for each chunk's live arrival time; partials: 1.28s: Mister Quilp.; 2.24s: Mr. Quilter is the apostle.; 3.2s: Mister Quilter is the apostle of the middle class.; 4.16s: Mister Quilter is the apostle of the middle classes, and we are glad.; 5.12s: Mister Quilter is the apostle of the middle classes, and we are glad to welcome his. First partial at 1.28 s of audio, final transcript 155 ms after the audio ended, encoder 5.86 ms per 320 ms chunk.", + "runs": [ + { + "mode": "transcribe", + "inputs": { + "audio": "demo/input.wav" + }, + "outputs": { + "text": "Mister Quilter is the apostle of the middle classes, and we are glad to welcome his gospel." + }, + "metrics": "demo/metrics.json" + } + ] +} \ No newline at end of file diff --git a/sm8850-npu-fp16/demo/input.wav b/sm8850-npu-fp16/demo/input.wav new file mode 100644 index 0000000000000000000000000000000000000000..19cf600b6b72d52eee0a22af8a3ba41d71389081 --- /dev/null +++ b/sm8850-npu-fp16/demo/input.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:799f78ed4beb4de7ceae3a809262d4ce242394342ccd1d58cef7d49dbc2def46 +size 187404 diff --git a/sm8850-npu-fp16/demo/metrics.json b/sm8850-npu-fp16/demo/metrics.json new file mode 100644 index 0000000000000000000000000000000000000000..d19b24308bf4fadd7467717c8aeffff03207cfd3 --- /dev/null +++ b/sm8850-npu-fp16/demo/metrics.json @@ -0,0 +1 @@ +{"load_ms": 431.5, "runs": [{"total_ms": 6010.33, "ttft_ms": 1332.01, "first_partial_ms": 1332.01, "first_partial_audio_s": 1.28, "new_tokens": 25, "audio_s": 5.855, "rtf": 1.0265, "chunks": 20, "chunk_ms_median": 5.864, "final_decode_ms": 144.29, "decode_ms_per_token": 5.772, "partials": 5, "partial_decode_ms": 451.00, "end_latency_ms": 155.33, "realtime": true, "chunk_ms": [12.290, 5.841, 6.303, 5.632, 6.344, 5.573, 5.888, 5.838, 6.334, 5.522, 6.307, 5.799, 6.020, 6.220, 5.995, 5.636, 6.306, 5.662, 5.633, 4.503], "chunk_latency_ms": [12.290, 5.841, 6.303, 51.363, 6.345, 5.573, 71.101, 5.838, 6.334, 94.590, 6.308, 5.799, 124.134, 6.221, 5.996, 139.344, 6.307, 5.662, 5.633, 4.504]}], "peak_mem_mb": 619.7} diff --git a/sm8850-npu-fp16/demo/output.json b/sm8850-npu-fp16/demo/output.json new file mode 100644 index 0000000000000000000000000000000000000000..ee76354224eae7940b6aab6085a3d428b163a847 --- /dev/null +++ b/sm8850-npu-fp16/demo/output.json @@ -0,0 +1 @@ +{"text": "Mister Quilter is the apostle of the middle classes, and we are glad to welcome his gospel.", "partials": [{"audio_s": 1.28, "text": "Mister Quilp."}, {"audio_s": 2.24, "text": "Mr. Quilter is the apostle."}, {"audio_s": 3.20, "text": "Mister Quilter is the apostle of the middle class."}, {"audio_s": 4.16, "text": "Mister Quilter is the apostle of the middle classes, and we are glad."}, {"audio_s": 5.12, "text": "Mister Quilter is the apostle of the middle classes, and we are glad to welcome his."}]} diff --git a/sm8850-npu-fp16/deploy.sh b/sm8850-npu-fp16/deploy.sh new file mode 100644 index 0000000000000000000000000000000000000000..e11712a8c3afcd24d99c8d772847ca6227d5fec8 --- /dev/null +++ b/sm8850-npu-fp16/deploy.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# bash deploy.sh DEST: pushes the built phone folder (build.sh's stage) and the compiled models to DEST on the phone +# over adb (ANDROID_SERIAL selects the phone) and leaves DEST/run.sh and DEST/port.json. +set -euo pipefail +cd "$(dirname "$0")" +ROOT=$PWD +NAME=moonshine-streaming-npu +DEST=${1:?usage: bash deploy.sh DEST} +. "$ROOT/src/paths.sh" +STAGE=$BUILD/stage +[ -x "$STAGE/moonshine_stream" ] || { echo "deploy.sh: run build.sh first ($STAGE is missing)" >&2; exit 1; } +soc=$(adb shell getprop ro.soc.model | tr -d '\r') +[ "$soc" = "SM8850" ] || echo "deploy.sh: warning: the models are compiled for SM8850, this phone is '$soc'" >&2 +adb shell "mkdir -p '$DEST/dsp'" +adb push --sync "$STAGE/." "$DEST/" >/dev/null +for f in "$ROOT"/models/*.tflite "$ROOT"/models/vocab.bin; do + adb push --sync "$f" "$DEST/" >/dev/null +done +adb shell "chmod 755 '$DEST/moonshine_stream'" +echo "deploy.sh: installed into $DEST:" +adb shell "ls -l '$DEST' '$DEST/dsp'" diff --git a/sm8850-npu-fp16/fetch.sh b/sm8850-npu-fp16/fetch.sh new file mode 100644 index 0000000000000000000000000000000000000000..0320aae4baf2f6f55f72f41776490047204ea89f --- /dev/null +++ b/sm8850-npu-fp16/fetch.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# Run once after downloading this folder: bash fetch.sh +# Gets Qualcomm's QNN runtime (not redistributable) into build/stage/, where deploy.sh expects it. +set -euo pipefail +cd "$(dirname "$0")" +REPO=nnopt-dev/moonshine-streaming-LiteRT + +# The repository's manifest first (Hugging Face counts a download when config.json is requested). +curl -fsSL "https://huggingface.co/$REPO/resolve/main/config.json" -o ../config.json + +sha256_of() { if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | cut -d" " -f1; else shasum -a 256 "$1" | cut -d" " -f1; fi; } +get() { # get URL FILE SHA256: download once, check the sha256 + if [ -f "$2" ] && [ "$(sha256_of "$2")" = "$3" ]; then return 0; fi + mkdir -p "$(dirname "$2")" + curl -fL --retry 3 -o "$2.part" "$1" + [ "$(sha256_of "$2.part")" = "$3" ] || { echo "fetch.sh: sha256 mismatch for $1" >&2; rm -f "$2.part"; exit 1; } + mv "$2.part" "$2" +} +git_at() { # git_at URL COMMIT DIR: the exact commit, shallow + if [ "$(git -C "$3" rev-parse HEAD 2>/dev/null || true)" = "$2" ]; then return 0; fi + rm -rf "$3"; mkdir -p "$3" + git -C "$3" init -q && git -C "$3" remote add origin "$1" + git -C "$3" fetch -q --depth 1 origin "$2" && git -C "$3" -c advice.detachedHead=false checkout -q FETCH_HEAD +} + +# Qualcomm's QNN runtime: its license forbids redistribution, so it is not in this repository. It comes from +# Maven Central (Google's mirror), pinned by version and sha256, the same file build.sh uses. +QNN_VER=2.50.0 +QNN_SHA=b507656e4031d8aa6a7ab0fecf725b941096737ad7440ad7ea288f7c9cc9d743 +get "https://storage.googleapis.com/maven-central/maven2/com/qualcomm/qti/qnn-runtime/$QNN_VER/qnn-runtime-$QNN_VER.aar" \ + ".deps/qnn-runtime-$QNN_VER.aar" "$QNN_SHA" + +rm -rf ".deps/qnn-runtime-$QNN_VER" && mkdir -p ".deps/qnn-runtime-$QNN_VER" build/stage/dsp +(cd ".deps/qnn-runtime-$QNN_VER" && unzip -q -o "../qnn-runtime-$QNN_VER.aar" jni/arm64-v8a/libQnnHtp.so jni/arm64-v8a/libQnnSystem.so \ + jni/arm64-v8a/libQnnHtpV81Stub.so jni/arm64-v8a/libQnnHtpV81Skel.so LICENSE.pdf && chmod -R u+w .) && touch ".deps/qnn-runtime-$QNN_VER/.ok" +Q=".deps/qnn-runtime-$QNN_VER/jni/arm64-v8a" +cp "$Q/libQnnHtp.so" "$Q/libQnnSystem.so" "$Q/libQnnHtpV81Stub.so" build/stage/ && cp "$Q/libQnnHtpV81Skel.so" build/stage/dsp/ +chmod +x build/stage/moonshine_stream build/moonshine_stream +echo "fetch.sh: done. Next: bash deploy.sh /data/local/tmp/moonshine" diff --git a/sm8850-npu-fp16/models/dec1536h_Qualcomm_SM8850_apply_plugin.tflite b/sm8850-npu-fp16/models/dec1536h_Qualcomm_SM8850_apply_plugin.tflite new file mode 100644 index 0000000000000000000000000000000000000000..2a7288c53b7681ce19a40454d9fc64d9f0e69e7a --- /dev/null +++ b/sm8850-npu-fp16/models/dec1536h_Qualcomm_SM8850_apply_plugin.tflite @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a28fad21faf2097c7141316fb1417260338c4de8737e7f79890e4f32e5d5cc8b +size 336700512 diff --git a/sm8850-npu-fp16/models/dec4096h_Qualcomm_SM8850_apply_plugin.tflite b/sm8850-npu-fp16/models/dec4096h_Qualcomm_SM8850_apply_plugin.tflite new file mode 100644 index 0000000000000000000000000000000000000000..6708e9e9509c2b6934eba30f139f6c0eb1ae5e6a --- /dev/null +++ b/sm8850-npu-fp16/models/dec4096h_Qualcomm_SM8850_apply_plugin.tflite @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6f23a91a62d214af113ee469001b6cc82741e34ca7dadec8af6fb61a38e0e7c +size 337212512 diff --git a/sm8850-npu-fp16/models/dec512h_Qualcomm_SM8850_apply_plugin.tflite b/sm8850-npu-fp16/models/dec512h_Qualcomm_SM8850_apply_plugin.tflite new file mode 100644 index 0000000000000000000000000000000000000000..d1f24ca97446fb14be1bf93e43bf4bbe8acef77f --- /dev/null +++ b/sm8850-npu-fp16/models/dec512h_Qualcomm_SM8850_apply_plugin.tflite @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b1b4993c19de245475f04f8f404a5de7e0b564eae9342c9f8ef0e0e75c48222 +size 336467040 diff --git a/sm8850-npu-fp16/models/enc16_Qualcomm_SM8850_apply_plugin.tflite b/sm8850-npu-fp16/models/enc16_Qualcomm_SM8850_apply_plugin.tflite new file mode 100644 index 0000000000000000000000000000000000000000..d3fd579507c5f0662372c6bdaf2f6d229602303b --- /dev/null +++ b/sm8850-npu-fp16/models/enc16_Qualcomm_SM8850_apply_plugin.tflite @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a8010fb0397243d2d67c4c84f8f76ff85d6f94cf35467c3b8157f556e2563d3b +size 256416888 diff --git a/sm8850-npu-fp16/models/vocab.bin b/sm8850-npu-fp16/models/vocab.bin new file mode 100644 index 0000000000000000000000000000000000000000..05d4d9c7b16b71a4596d00c79823392b9e0ac8f9 --- /dev/null +++ b/sm8850-npu-fp16/models/vocab.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b3e9c217d081a41c249dd4bf991da435d339ecc139360f2b149dbdaef2a3359 +size 282467 diff --git a/sm8850-npu-fp16/report.html b/sm8850-npu-fp16/report.html new file mode 100644 index 0000000000000000000000000000000000000000..d464ed59b427c048d1add420f56dfaf818a07e9a --- /dev/null +++ b/sm8850-npu-fp16/report.html @@ -0,0 +1,431 @@ + + +nnopt report · moonshine-ai/moonshine-streaming + + +
nnopt verification report · Speech to text +

moonshine-ai/moonshine-streaming on galaxy-s26-plus

+

Job NN-466F3D · 2026-11-03 21:51 UTC · +nnopt-verify 0.1.0 · reference bundle c7d954ce39edc45e

+
CorrectnessPASSoriginal precision policy
Speed targetno target
RuntimePASSLiteRT and QNN and the Hexagon NPU, as asked
DecodingPASSone token per pass, no speculative decoding
Real-time factor0.076 xwarm, median
Peak memory622.8 MBprocess tree
Load time285.8 ms

Correctness

+

The port ran on 19 inputs (6 hidden, generated fresh for this job and never shown to the +porting agent) and was compared with the reference outputs captured from your code. Thresholds are for the +original precision policy.

+
CheckValueThresholdResult
All cases ran
19/19 cases produced valid output
1.00>= 1.00✓ PASS
WER vs reference transcripts
port transcripts vs reference transcripts
0.000<= 0.020✓ PASS
WER change vs true transcripts
WER vs truth: port 0.082, reference 0.082
0.000<= 0.010✓ PASS
Per-case results (19 cases)
CaseSplitWER vs refPort transcript
p000public · builtin0.000The quick brown fox jumps over the lazy dog near the river bank.
p001public · builtin0.000Please call me back when you get home this evening.
p002public · customer0.000Mister Quilter is the apostle of the middle classes, and we are glad to welcome his gospel.
p003public · customer0.000Nor is Mister Quilter's manner less interesting than his matter.
p004public · customer0.000He tells us that at this festive season of the year, with Christmas and roast beef looming before us, similes drawn from eating and its results occur most readi
p005public · customer0.000Linnell's pictures are a sort of up guards and atom paintings and Mason's exquisite idylls are as national as a jingo poem. Mr. Burkitt fosters landscapes smile
p006public · customer0.000He laments most bitterly the divorce that has been made between decorative art and what we usually call pictures. Makes the customary appeal to the last judgmen
p007public · customer0.000By Harry Quilter, M. A.
p008public · customer0.000He doesn't work at all.
p009public · customer0.000Having returned to the royal cavern, Calico first pounded the gong, and then sat in the throne, wearing Ruggedo's discarded ruby crown, and holding in his hand
p010public · customer0.000The cardona's chest still dripping blood, the ache of his overstrained eyes, even the soaring arena around him with thousands of spectators, were trivialities n
p011public · customer0.000A red-haired mountain of a man with an apparently inexhaustible store of energy.
p012public · customer0.000Breathing deeply, Breon softly spoke the auto-hypnotic phrases that triggered the process.
h000hidden · generated0.000My brother cleaned the lantern and gave it to Dalai.
h001hidden · generated0.000The hidden market in Accra opens at 5:00 in the morning.
h002hidden · generated0.000When said, the weather in Dauphereza was busy all week.
h003hidden · generated0.000Nobody expected the ancient camera to sell for so much money.
h004hidden · generated0.000There are 16 boats waiting in the harbor tonight.
h005hidden · generated0.000Anna and Bruno met for coffee near the Musum in Marrakech.

Runtime

+

Asked for LiteRT; every model graph on the Hexagon NPU, no GPU or CPU fallback (tokenizer and glue code on CPU are fine). Clean build, the port's own code and build log: uses LiteRT and QNN; runs on the Hexagon NPU: the kit's own run on the phone loaded the HTP, every shipped NPU graph is all DISPATCH_OP, CPU fallback disabled.

+
  • src/runner.c:95: if (LiteRtCreateModelFromFile(env, path, &g->model) != kLiteRtStatusOk) DIE("cannot load model %s", path);
  • src/export_tflite.py:47: from ai_edge_litert.interpreter import Interpreter
  • src/aot_compile.py:8: from ai_edge_litert.aot import aot_compile as aot_lib
  • build log: build.sh: fetching qnn-runtime 2.50.0
  • the kit's run on the phone: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so
  • the kit's run on the phone: fully accelerated 3/4 · Skel V81 loaded · user PD ✓
  • npu-graphs: 4 of 4 NPU graphs all-DISPATCH · 0 CPU ops · SM8850 · QAIRT 2.50.0
  • NOTES.md: Successfully opened file /data/local/tmp/nnopt/port/dsp/./libQnnHtpV81Skel.so

NPU

NPU graphs

4 of 4 NPU graphs all-DISPATCH · 0 CPU ops · SM8850 · QAIRT 2.50.0

graphruns onDISPATCH_OPCPU opsSoCQAIRTprecisionsize
dec1536hnpu10SM88502.50.0fp16321 MB
dec4096hnpu10SM88502.50.0fp16322 MB
dec512hnpu10SM88502.50.0fp16321 MB
enc16npu10SM88502.50.0fp16245 MB
output
$ nnopt-verify npu-graphs port/models --soc SM8850
+graph     ops             SoC     prec  size  ok
+dec1536h  1 sig · 1 DISP  SM8850  fp16  321M  ✓
+dec4096h  1 sig · 1 DISP  SM8850  fp16  322M  ✓
+dec512h   1 sig · 1 DISP  SM8850  fp16  321M  ✓
+enc16     1 sig · 1 DISP  SM8850  fp16  245M  ✓
+4 of 4 NPU graphs all-DISPATCH · 0 CPU ops · SM8850 · QAIRT 2.50.0

NPU on the device

fully accelerated 3/4 · Skel V81 loaded · user PD ✓

output
$ adb logcat -c; <the kit's runs>; logcat -d -v time | grep -E 'Skel\.so|user PD|fully accelerated|IsNonCpuFullyAccelerated|Replacing [0-9]+ out of|Partitioned subgraph|per graph ms|QnnDsp|LiteRt|litert|DISPATCH' | tail -n 400
+ode(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+11-03 13:42:44.739 I/moonshine_stream(28412): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10
+11-03 13:42:44.751 I/moonshine_stream(28412): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb4000073a9e43960 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty
+11-03 13:42:46.038 I/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token
+11-03 13:42:46.066 I/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N
+11-03 13:42:46.070 E/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)
+11-03 13:42:46.077 D/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192       fopen:16us, fstat:2us, read:6158us,       rpc_alloc:187us, mmap:411us fd 0x12 error_code 0x0
+11-03 13:42:46.077 I/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so
+11-03 13:42:46.118 I/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb400007100e49870 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 29625 us, load time 50132 us), refs 1
+11-03 13:42:46.134 I/tflite  (28512): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+11-03 13:42:46.227 I/tflite  (28512): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+11-03 13:42:46.813 I/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10
+11-03 13:42:46.824 I/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb400007100e49870 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty
+11-03 13:42:48.146 I/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token
+11-03 13:42:48.176 I/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N
+11-03 13:42:48.180 E/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)
+11-03 13:42:48.186 D/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192       fopen:14us, fstat:2us, read:5335us,       rpc_alloc:161us, mmap:384us fd 0x12 error_code 0x0
+11-03 13:42:48.186 I/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so
+11-03 13:42:48.230 I/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb400007103849af0 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 31685 us, load time 52442 us), refs 1
+11-03 13:42:48.246 I/tflite  (28613): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+11-03 13:42:48.339 I/tflite  (28613): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+11-03 13:42:48.889 I/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10
+11-03 13:42:48.901 I/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb400007103849af0 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty
+11-03 13:42:50.178 I/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token
+11-03 13:42:50.207 I/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N
+11-03 13:42:50.211 E/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)
+11-03 13:42:50.218 D/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192       fopen:42us, fstat:1us, read:5476us,       rpc_alloc:236us, mmap:408us fd 0x12 error_code 0x0
+11-03 13:42:50.218 I/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so
+11-03 13:42:50.261 I/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb4000077bc044140 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 30966 us, load time 51711 us), refs 1
+11-03 13:42:50.278 I/tflite  (28698): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+11-03 13:42:50.373 I/tflite  (28698): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+11-03 13:42:50.888 I/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10
+11-03 13:42:50.900 I/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb4000077bc044140 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty
+11-03 13:42:52.098 I/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token
+11-03 13:42:52.123 I/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N
+11-03 13:42:52.128 E/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)
+11-03 13:42:52.138 D/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192       fopen:27us, fstat:3us, read:8845us,       rpc_alloc:321us, mmap:402us fd 0x12 error_code 0x0
+11-03 13:42:52.138 I/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so
+11-03 13:42:52.181 I/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb4000074e62415a0 (remote 0x2ce7a0) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 27399 us, load time 56153 us), refs 1
+11-03 13:42:52.200 I/tflite  (28786): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+11-03 13:42:52.287 I/tflite  (28786): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+11-03 13:42:52.816 I/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2ce7a0
+11-03 13:42:52.827 I/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb4000074e62415a0 remote handle 0x2ce7a0 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty
+
+# the kit's runs (stdout and stderr), proof lines
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite
+LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).
+VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).

benchmark_model (Google LiteRT 2.3.1)

4 of 4 timed · 4 at 100% NPU

graphsignatureavg msmin msmax ms% on the NPU
dec1536h6.6896.6027.248100.0
dec4096h8.78.6348.898100.0
dec512h5.5795.5145.979100.0
enc164.3374.2854.481100.0
output
$ /data/local/tmp/nnopt-verify/npu-bench/benchmark_model --graph=/data/local/tmp/nnopt/port/dec1536h_Qualcomm_SM8850_apply_plugin.tflite --use_npu=true --use_gpu=false --qualcomm_htp_performance_mode=burst --dispatch_library_path=/data/local/tmp/nnopt-verify/npu-bench --num_runs=20 --warmup_runs=3  (+3 more)
+dec1536h: avg 6.689 ms · min 6.602 · max 7.248 · 100.0% NPU
+dec4096h: avg 8.7 ms · min 8.634 · max 8.898 · 100.0% NPU
+dec512h: avg 5.579 ms · min 5.514 · max 5.979 · 100.0% NPU
+enc16: avg 4.337 ms · min 4.285 · max 4.481 · 100.0% NPU
+
+$ /data/local/tmp/nnopt-verify/npu-bench/benchmark_model --graph=/data/local/tmp/nnopt/port/dec1536h_Qualcomm_SM8850_apply_plugin.tflite --use_npu=true --use_gpu=false --qualcomm_htp_performance_mode=burst --dispatch_library_path=/data/local/tmp/nnopt-verify/npu-bench --num_runs=20 --warmup_runs=3
+exit 0
+ [benchmark_litert_model.h:94] Model initialization: 182.51 ms
+INFO: [benchmark_litert_model.h:96] Warmup (first):       10.71 ms
+INFO: [benchmark_litert_model.h:98] Warmup (avg):         6.74 ms (75 runs)
+INFO: [benchmark_litert_model.h:100] Inference (avg):      6.69 ms (150 runs)
+INFO: [benchmark_litert_model.h:104] Inference (min):      6.60 ms
+INFO: [benchmark_litert_model.h:106] Inference (max):      7.25 ms
+INFO: [benchmark_litert_model.h:108] Inference (std):      0.07
+INFO: [benchmark_litert_model.h:115] Throughput:           8994.25 MB/s
+INFO: [benchmark_litert_model.h:124] 
+Memory Usage:
+INFO: [benchmark_litert_model.h:126] Init footprint:       331.59 MB
+INFO: [benchmark_litert_model.h:128] Overall footprint:    357.92 MB
+INFO: [benchmark_litert_model.h:135] Peak memory usage not available. (peak_mem_mb <= 0)
+INFO: [benchmark_litert_model.h:138] ======================================
+
+INFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb400007bf7e04380, name=CpuAccelerator
+INFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb400007bf7e040e0, name=NpuAccelerator
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+1896549000.0ms [  INFO ]  Free context with QnnGraphTransformerAdapter1896556000.0ms [  INFO ]  QnnGraphTransformer context freed successfully     0.0ms [  INFO ]  QnnDsp <I> QnnContext_free started. context = 0x1
+     0.0ms [WARNING]  QnnDsp <W> m_CFBCallbackInfoObj is not initialized, return emptyList
+     0.0ms [  INFO ]  QnnDsp <I> Number of existing contexts: 0, graphs: 0
+     0.0ms [  INFO ]  QnnDsp <I> QnnContext_free done successfully.
+     0.0ms [  INFO ]  QnnDsp <I> Exiting thread
+
+$ /data/local/tmp/nnopt-verify/npu-bench/benchmark_model --graph=/data/local/tmp/nnopt/port/dec4096h_Qualcomm_SM8850_apply_plugin.tflite --use_npu=true --use_gpu=false --qualcomm_htp_performance_mode=burst --dispatch_library_path=/data/local/tmp/nnopt-verify/npu-bench --num_runs=20 --warmup_runs=3
+exit 0
+[benchmark_litert_model.h:94] Model initialization: 182.78 ms
+INFO: [benchmark_litert_model.h:96] Warmup (first):       12.71 ms
+INFO: [benchmark_litert_model.h:98] Warmup (avg):         8.77 ms (58 runs)
+INFO: [benchmark_litert_model.h:100] Inference (avg):      8.70 ms (115 runs)
+INFO: [benchmark_litert_model.h:104] Inference (min):      8.63 ms
+INFO: [benchmark_litert_model.h:106] Inference (max):      8.90 ms
+INFO: [benchmark_litert_model.h:108] Inference (std):      0.03
+INFO: [benchmark_litert_model.h:115] Throughput:           18230.55 MB/s
+INFO: [benchmark_litert_model.h:124] 
+Memory Usage:
+INFO: [benchmark_litert_model.h:126] Init footprint:       331.96 MB
+INFO: [benchmark_litert_model.h:128] Overall footprint:    402.01 MB
+INFO: [benchmark_litert_model.h:135] Peak memory usage not available. (peak_mem_mb <= 0)
+INFO: [benchmark_litert_model.h:138] ======================================
+
+INFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb400006f6da05a10, name=CpuAccelerator
+INFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb400006f6da05cb0, name=NpuAccelerator
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+2234137000.0ms [  INFO ]  Free context with QnnGraphTransformerAdapter2234150000.0ms [  INFO ]  QnnGraphTransformer context freed successfully     0.0ms [  INFO ]  QnnDsp <I> QnnContext_free started. context = 0x1
+     0.0ms [WARNING]  QnnDsp <W> m_CFBCallbackInfoObj is not initialized, return emptyList
+     0.0ms [  INFO ]  QnnDsp <I> Number of existing contexts: 0, graphs: 0
+     0.0ms [  INFO ]  QnnDsp <I> QnnContext_free done successfully.
+     0.0ms [  INFO ]  QnnDsp <I> Exiting thread
+
+$ /data/local/tmp/nnopt-verify/npu-bench/benchmark_model --graph=/data/local/tmp/nnopt/port/dec512h_Qualcomm_SM8850_apply_plugin.tflite --use_npu=true --use_gpu=false --qualcomm_htp_performance_mode=burst --dispatch_library_path=/data/local/tmp/nnopt-verify/npu-bench --num_runs=20 --warmup_runs=3
+exit 0
+: [benchmark_litert_model.h:94] Model initialization: 178.11 ms
+INFO: [benchmark_litert_model.h:96] Warmup (first):       9.50 ms
+INFO: [benchmark_litert_model.h:98] Warmup (avg):         5.62 ms (89 runs)
+INFO: [benchmark_litert_model.h:100] Inference (avg):      5.58 ms (180 runs)
+INFO: [benchmark_litert_model.h:104] Inference (min):      5.51 ms
+INFO: [benchmark_litert_model.h:106] Inference (max):      5.98 ms
+INFO: [benchmark_litert_model.h:108] Inference (std):      0.07
+INFO: [benchmark_litert_model.h:115] Throughput:           3627.14 MB/s
+INFO: [benchmark_litert_model.h:124] 
+Memory Usage:
+INFO: [benchmark_litert_model.h:126] Init footprint:       331.20 MB
+INFO: [benchmark_litert_model.h:128] Overall footprint:    339.95 MB
+INFO: [benchmark_litert_model.h:135] Peak memory usage not available. (peak_mem_mb <= 0)
+INFO: [benchmark_litert_model.h:138] ======================================
+
+INFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb400006e4ee0ad20, name=CpuAccelerator
+INFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb400006e4ee09cf0, name=NpuAccelerator
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+1758580000.0ms [  INFO ]  Free context with QnnGraphTransformerAdapter1758593000.0ms [  INFO ]  QnnGraphTransformer context freed successfully     0.0ms [  INFO ]  QnnDsp <I> QnnContext_free started. context = 0x1
+     0.0ms [WARNING]  QnnDsp <W> m_CFBCallbackInfoObj is not initialized, return emptyList
+     0.0ms [  INFO ]  QnnDsp <I> Number of existing contexts: 0, graphs: 0
+     0.0ms [  INFO ]  QnnDsp <I> QnnContext_free done successfully.
+     0.0ms [  INFO ]  QnnDsp <I> Exiting thread
+
+$ /data/local/tmp/nnopt-verify/npu-bench/benchmark_model --graph=/data/local/tmp/nnopt/port/enc16_Qualcomm_SM8850_apply_plugin.tflite --use_npu=true --use_gpu=false --qualcomm_htp_performance_mode=burst --dispatch_library_path=/data/local/tmp/nnopt-verify/npu-bench --num_runs=20 --warmup_runs=3
+exit 0
+.h:126] Init footprint:       254.62 MB
+INFO: [benchmark_litert_model.h:128] Overall footprint:    255.24 MB
+INFO: [benchmark_litert_model.h:135] Peak memory usage not available. (peak_mem_mb <= 0)
+INFO: [benchmark_litert_model.h:138] ======================================
+
+INFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb4000072d9406230, name=CpuAccelerator
+INFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb4000072d9405ac0, name=NpuAccelerator
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister started
+     0.0ms [  INFO ]  QnnDsp <I> QnnMem_deRegister done. status 0x0
+1674846000.0ms [  INFO ]  Free context with QnnGraphTransformerAdapter1674855000.0ms [  INFO ]  QnnGraphTransformer context freed successfully     0.0ms [  INFO ]  QnnDsp <I> QnnContext_free started. context = 0x1
+     0.0ms [WARNING]  QnnDsp <W> m_CFBCallbackInfoObj is not initialized, return emptyList
+     0.0ms [  INFO ]  QnnDsp <I> Number of existing contexts: 0, graphs: 0
+     0.0ms [  INFO ]  QnnDsp <I> QnnContext_free done successfully.
+     0.0ms [  INFO ]  QnnDsp <I> Exiting thread

Speed and memory

+

2 warm-up runs, then 5 timed runs of 3 requests each (the first +request of each run is cold). Timed on the device's own clock.

+
Metric (warm requests)Medianp10p90n
Real-time factor0.076 x0.076 x0.077 x10
Request time435.7 ms434.3 ms438.6 ms10
Decode speed40.31 tok/s40.08 tok/s40.42 tok/s10
Time to first token38.59 ms38.34 ms39.08 ms10
new_tokens17.0017.0017.0010
Request time (cold)441.1 ms440.8 ms450.0 ms5
Load time285.8 ms266.6 ms294.6 ms5
Process wall time1701 ms1675 ms1709 ms5
Peak RSS (process tree)622.8 MB
Peak VmHWM (process tree)622.8 MB
Peak memory (self-reported)621.5 MB

External cross-check (paired --repeat 3 vs 1, 5 pairs, device clock): Request time: 440.8 ms; Real-time factor: 0.077 x. Graded values are capped by it.

Decode, % of memory roofline
23.2% of 174.0 tok/s
Bytes per decoded token
0.402 GB: half of the 0.402 B parameters taken as the decoder (the model facts give no decoder size)
Specs used
69.93 GB/s, 18325 GFLOP/s
Figures
NPU figures; measured by lab/npu probe (NN-174CC0) on 2026-10-31: fp16 weight stream 69.93 GB/s (bw_l24), fp16 matmul 18.325 TFLOPS, int8 matmul 29.023 TOPS; LiteRT 2.3.1 + Qualcomm dispatch, QAIRT 2.50, burst

Environment and reproducibility

os
android
gpu
Adreno 840
soc
Snapdragon 8 Elite Gen 5
brand
Samsung
device
Samsung Galaxy S26+
ram_gb
12
android
16
gpu_apis
['OpenCL', 'Vulkan']
released
2026-02
roofline
{'npu': {'job': 'NN-174CC0', 'source': 'measured by lab/npu probe (NN-174CC0) on 2026-10-31: fp16 weight stream 69.93 GB/s (bw_l24), fp16 matmul 18.325 TFLOPS, int8 matmul 29.023 TOPS; LiteRT 2.3.1 + Qualcomm dispatch, QAIRT 2.50, burst', 'measured': True, 'measured_at': '2026-10-31', 'measured_by': 'probe', 'peak_int8_tops': 29.023, 'peak_fp16_tflops': 18.325, 'mem_bandwidth_gbps': 69.93, 'mem_bandwidth_int8_gbps': 70.46}, 'spec': {'source': 'spec-sheet estimate, not yet measured: LPDDR5X-10667 64-bit; Adreno 840 compute is a rough estimate', 'peak_int8_tops': 6.0, 'peak_fp16_tflops': 6.0, 'mem_bandwidth_gbps': 85.3}, 'source': 'measured on the device by NN-A61C46 on 2026-11-03: GPU read 72.6 GB/s (OpenCL read_v4)', 'measured': True, 'device_best': {'cpu_job': 'NN-DA0137', 'gpu_job': 'NN-DA0137', 'cpu_read_gbps': 74.03, 'gpu_read_gbps': 73.18, 'cpu_measured_at': '2026-10-23T04:46:29+00:00', 'gpu_measured_at': '2026-10-23T04:46:29+00:00'}, 'measured_at': '2026-11-03', 'measured_by': 'device', 'device_probe': {'job': 'NN-A61C46', 'measured_at': '2026-11-03T03:40:37+00:00', 'cpu_read_gbps': 60.38, 'gpu_read_gbps': 72.6}, 'peak_int8_tops': 6.0, 'peak_fp16_tflops': 6.0, 'mem_bandwidth_gbps': 72.6}
model_id
m2q
version_id
36
name
Samsung Galaxy S26+
processor
npu
executor
adb
reference python
3.12.3
reference numpy
2.5.4
reference nnopt_verify
0.1.0
reference platform
Linux-7.0.0-1014-gcp-x86_64-with-glibc2.39

REPRO.md, next to this report, lists the tools, the model and every step to get these numbers on your own device; reproduce.sh runs the measurement. results.csv and results.json hold every number in this report.

Generated by nnopt-verify 0.1.0. Correctness is graded on all inputs; speed figures are medians of warm requests unless marked cold.
diff --git a/sm8850-npu-fp16/report/reproduce.sh b/sm8850-npu-fp16/report/reproduce.sh new file mode 100644 index 0000000000000000000000000000000000000000..b39856a0f2eedca9ad9b0f4b16e220abf455b3f5 --- /dev/null +++ b/sm8850-npu-fp16/report/reproduce.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# Reproduce nnopt's numbers on your own device (REPRO.md). Build and deploy first (REPRO.md, steps 4 to 6). +# Needs python3, and adb (Android; ANDROID_SERIAL with several phones) or ssh (SSH_TARGET=user@host). +here=$(cd "$(dirname "$0")" && pwd) +root=$here; [ -d "$root/repro" ] || root=$(dirname "$here") +cd "$root" || exit 2 +if [ ! -f repro/bench.py ]; then echo "no repro/ folder next to REPRO.md"; exit 2; fi +rc=0 +python3 repro/bench.py "$@" || rc=$? +python3 repro/bench.py --check "$@" || rc=$? +exit $rc diff --git a/sm8850-npu-fp16/report/results.csv b/sm8850-npu-fp16/report/results.csv new file mode 100644 index 0000000000000000000000000000000000000000..94167f3ec4008020280a79cf3875cd234032eb91 --- /dev/null +++ b/sm8850-npu-fp16/report/results.csv @@ -0,0 +1,80 @@ +section,name,value,unit_or_op,threshold,passed +grade,correctness,True,,,True +grade,speed_target_met,,,, +check,cases_completed,1.0,>=,1.0,True +check,wer_vs_reference,0.0,<=,0.02,True +check,wer_delta_vs_truth,0.0,<=,0.01,True +check_metric,wer_vs_reference,0.0,,, +check_metric,wer_port_vs_truth,0.08235,,, +check_metric,wer_reference_vs_truth,0.08235,,, +check_metric,wer_delta_vs_truth,0.0,,, +check_metric,cases_with_truth,8,,, +bench,real_time_factor.median,0.0761763,x,, +bench,real_time_factor.p10,0.0759334,x,, +bench,real_time_factor.p90,0.0766807,x,, +bench,real_time_factor.min,0.0759114,x,, +bench,real_time_factor.max,0.0766964,x,, +bench,real_time_factor.n,10,x,, +bench,latency_ms.median,435.695,ms,, +bench,latency_ms.p10,434.306,ms,, +bench,latency_ms.p90,438.58,ms,, +bench,latency_ms.min,434.18,ms,, +bench,latency_ms.max,438.67,ms,, +bench,latency_ms.n,10,ms,, +bench,tokens_per_s.median,40.3124,tok/s,, +bench,tokens_per_s.p10,40.0784,tok/s,, +bench,tokens_per_s.p90,40.4153,tok/s,, +bench,tokens_per_s.min,39.999,tok/s,, +bench,tokens_per_s.max,40.4337,tok/s,, +bench,tokens_per_s.n,10,tok/s,, +bench,ttft_ms.median,38.595,ms,, +bench,ttft_ms.p10,38.342,ms,, +bench,ttft_ms.p90,39.08,ms,, +bench,ttft_ms.min,38.27,ms,, +bench,ttft_ms.max,39.44,ms,, +bench,ttft_ms.n,10,ms,, +bench,prompt_tokens.n,0,,, +bench,new_tokens.median,17.0,,, +bench,new_tokens.p10,17.0,,, +bench,new_tokens.p90,17.0,,, +bench,new_tokens.min,17.0,,, +bench,new_tokens.max,17.0,,, +bench,new_tokens.n,10,,, +bench,cold_latency_ms.median,441.09,ms,, +bench,cold_latency_ms.p10,440.832,ms,, +bench,cold_latency_ms.p90,449.974,ms,, +bench,cold_latency_ms.min,440.7,ms,, +bench,cold_latency_ms.max,454.63,ms,, +bench,cold_latency_ms.n,5,ms,, +bench,load_ms.median,285.8,ms,, +bench,load_ms.p10,266.6,ms,, +bench,load_ms.p90,294.58,ms,, +bench,load_ms.min,263.8,ms,, +bench,load_ms.max,296.5,ms,, +bench,load_ms.n,5,ms,, +bench,wall_ms.median,1701.05,ms,, +bench,wall_ms.p10,1674.92,ms,, +bench,wall_ms.p90,1709.2,ms,, +bench,wall_ms.min,1674.61,ms,, +bench,wall_ms.max,1711.91,ms,, +bench,wall_ms.n,5,ms,, +bench,peak_rss_mb,622.8,MB,, +bench,peak_hwm_mb,622.8,MB,, +bench,self_reported_peak_mem_mb,621.5,MB,, +graded,real_time_factor,0.0761763,x,, +graded,latency_ms,435.695,ms,, +graded,tokens_per_s,40.3124,tok/s,, +graded,ttft_ms,38.595,ms,, +graded,new_tokens,17.0,,, +graded,cold_latency_ms,441.09,ms,, +graded,load_ms,285.8,ms,, +graded,wall_ms,1701.05,ms,, +graded,peak_mem_mb,622.8,MB,, +roofline,mem_bandwidth_gbps,69.93,,, +roofline,peak_gflops,18325.0,,, +roofline,figures,"{'processor': 'npu', 'figures': 'npu', 'source': 'measured by lab/npu probe (NN-174CC0) on 2026-10-31: fp16 weight stream 69.93 GB/s (bw_l24), fp16 matmul 18.325 TFLOPS, int8 matmul 29.023 TOPS; LiteRT 2.3.1 + Qualcomm dispatch, QAIRT 2.50, burst'}",,, +roofline,decode_bytes_per_token,401900000.0,,, +roofline,decode_bytes_basis,half of the 0.402 B parameters taken as the decoder (the model facts give no decoder size),,, +roofline,decode_bound_tokens_per_s,174.0,,, +roofline,decode_pct_of_roofline,23.17,,, +roofline,decode_plausibility_cap,2923.0,,, diff --git a/sm8850-npu-fp16/report/results.json b/sm8850-npu-fp16/report/results.json new file mode 100644 index 0000000000000000000000000000000000000000..e45a8aca86ac38035e2e55ea3b15352e435e1d44 --- /dev/null +++ b/sm8850-npu-fp16/report/results.json @@ -0,0 +1,2154 @@ +{ + "kit_version": "0.1.0", + "job": { + "job_id": "NN-466F3D", + "kind": "port", + "model": "moonshine-ai/moonshine-streaming", + "environment": "galaxy-s26-plus", + "outcome": "passed", + "failure_reason": null, + "fingerprint": { + "name": "Samsung Galaxy S26+", + "soc": "Snapdragon 8 Elite Gen 5", + "gpu": "Adreno 840", + "os": "Android", + "phone": "the phone the agent session used" + }, + "backend": { + "requested": "LiteRT; every model graph on the Hexagon NPU, no GPU or CPU fallback (tokenizer and glue code on CPU are fine)", + "required": [ + "LiteRT", + "QNN", + "the Hexagon NPU" + ], + "avoided": [], + "passed": true, + "reason": "uses LiteRT and QNN; runs on the Hexagon NPU: the kit's own run on the phone loaded the HTP, every shipped NPU graph is all DISPATCH_OP, CPU fallback disabled", + "evidence": { + "LiteRT": [ + "src/runner.c:95: if (LiteRtCreateModelFromFile(env, path, &g->model) != kLiteRtStatusOk) DIE(\"cannot load model %s\", path);", + "src/export_tflite.py:47: from ai_edge_litert.interpreter import Interpreter", + "src/aot_compile.py:8: from ai_edge_litert.aot import aot_compile as aot_lib" + ], + "QNN": [ + "build log: build.sh: fetching qnn-runtime 2.50.0" + ], + "the Hexagon NPU": [ + "the kit's run on the phone: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "the kit's run on the phone: fully accelerated 3/4 \u00b7 Skel V81 loaded \u00b7 user PD \u2713", + "npu-graphs: 4 of 4 NPU graphs all-DISPATCH \u00b7 0 CPU ops \u00b7 SM8850 \u00b7 QAIRT 2.50.0", + "NOTES.md: Successfully opened file /data/local/tmp/nnopt/port/dsp/./libQnnHtpV81Skel.so", + "NOTES.md: Unsigned:Y", + "NOTES.md: LiteRT fully accelerated on the NPU (8 models)", + "port.json: \"cpu_fallback\": false" + ] + }, + "npu": { + "all_on_npu": false, + "passed": true, + "problems": [], + "reason": "runs on the Hexagon NPU: the kit's own run on the phone loaded the HTP, every shipped NPU graph is all DISPATCH_OP, CPU fallback disabled", + "evidence": [ + "the kit's run on the phone: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "the kit's run on the phone: fully accelerated 3/4 \u00b7 Skel V81 loaded \u00b7 user PD \u2713", + "npu-graphs: 4 of 4 NPU graphs all-DISPATCH \u00b7 0 CPU ops \u00b7 SM8850 \u00b7 QAIRT 2.50.0", + "NOTES.md: Successfully opened file /data/local/tmp/nnopt/port/dsp/./libQnnHtpV81Skel.so", + "NOTES.md: Unsigned:Y", + "NOTES.md: LiteRT fully accelerated on the NPU (8 models)", + "port.json: \"cpu_fallback\": false" + ] + } + }, + "decoding": { + "allowed": false, + "passed": true, + "evidence": [], + "reason": "one token per pass through the model: no speculative decoding in the port's code" + }, + "npu": { + "graphs": { + "ts": 1793742126.0, + "source": "kit", + "command": "nnopt-verify npu-graphs port/models --soc SM8850", + "output": "graph ops SoC prec size ok\ndec1536h 1 sig \u00b7 1 DISP SM8850 fp16 321M \u2713\ndec4096h 1 sig \u00b7 1 DISP SM8850 fp16 322M \u2713\ndec512h 1 sig \u00b7 1 DISP SM8850 fp16 321M \u2713\nenc16 1 sig \u00b7 1 DISP SM8850 fp16 245M \u2713\n4 of 4 NPU graphs all-DISPATCH \u00b7 0 CPU ops \u00b7 SM8850 \u00b7 QAIRT 2.50.0", + "summary": "4 of 4 NPU graphs all-DISPATCH \u00b7 0 CPU ops \u00b7 SM8850 \u00b7 QAIRT 2.50.0", + "result": { + "tool": "nnopt-verify npu-graphs", + "version": 1, + "soc_expected": "SM8850", + "all_on_npu": false, + "files": [ + { + "path": "models/dec1536h_Qualcomm_SM8850_apply_plugin.tflite", + "name": "dec1536h", + "size": 336700512, + "class": "npu", + "signatures": [ + { + "name": "serving_default", + "subgraph": 0 + } + ], + "subgraphs": [ + { + "index": 0, + "name": "main", + "ops": { + "DISPATCH_OP": 1 + }, + "n_ops": 1, + "all_dispatch": true + } + ], + "ops": { + "DISPATCH_OP": 1 + }, + "n_ops": 1, + "dispatch": 1, + "cpu_ops": {}, + "vendor": "Qualcomm", + "soc": "SM8850", + "soc_source": "stamp", + "htp_arch": "81", + "qairt": "2.50.0", + "qairt_build": "260828221209", + "soc_in_name": "SM8850", + "dtypes": { + "fp32": 5, + "fp16": 4, + "int32": 2 + }, + "io_dtypes": { + "fp32": 5, + "fp16": 4, + "int32": 2 + }, + "const_bytes": {}, + "description": null, + "precision": "fp16", + "precision_basis": "htp float" + }, + { + "path": "models/dec4096h_Qualcomm_SM8850_apply_plugin.tflite", + "name": "dec4096h", + "size": 337212512, + "class": "npu", + "signatures": [ + { + "name": "serving_default", + "subgraph": 0 + } + ], + "subgraphs": [ + { + "index": 0, + "name": "main", + "ops": { + "DISPATCH_OP": 1 + }, + "n_ops": 1, + "all_dispatch": true + } + ], + "ops": { + "DISPATCH_OP": 1 + }, + "n_ops": 1, + "dispatch": 1, + "cpu_ops": {}, + "vendor": "Qualcomm", + "soc": "SM8850", + "soc_source": "stamp", + "htp_arch": "81", + "qairt": "2.50.0", + "qairt_build": "260828221209", + "soc_in_name": "SM8850", + "dtypes": { + "fp32": 5, + "fp16": 4, + "int32": 2 + }, + "io_dtypes": { + "fp32": 5, + "fp16": 4, + "int32": 2 + }, + "const_bytes": {}, + "description": null, + "precision": "fp16", + "precision_basis": "htp float" + }, + { + "path": "models/dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "name": "dec512h", + "size": 336467040, + "class": "npu", + "signatures": [ + { + "name": "serving_default", + "subgraph": 0 + } + ], + "subgraphs": [ + { + "index": 0, + "name": "main", + "ops": { + "DISPATCH_OP": 1 + }, + "n_ops": 1, + "all_dispatch": true + } + ], + "ops": { + "DISPATCH_OP": 1 + }, + "n_ops": 1, + "dispatch": 1, + "cpu_ops": {}, + "vendor": "Qualcomm", + "soc": "SM8850", + "soc_source": "stamp", + "htp_arch": "81", + "qairt": "2.50.0", + "qairt_build": "260828221209", + "soc_in_name": "SM8850", + "dtypes": { + "fp32": 5, + "fp16": 4, + "int32": 2 + }, + "io_dtypes": { + "fp32": 5, + "fp16": 4, + "int32": 2 + }, + "const_bytes": {}, + "description": null, + "precision": "fp16", + "precision_basis": "htp float" + }, + { + "path": "models/enc16_Qualcomm_SM8850_apply_plugin.tflite", + "name": "enc16", + "size": 256416888, + "class": "npu", + "signatures": [ + { + "name": "serving_default", + "subgraph": 0 + } + ], + "subgraphs": [ + { + "index": 0, + "name": "main", + "ops": { + "DISPATCH_OP": 1 + }, + "n_ops": 1, + "all_dispatch": true + } + ], + "ops": { + "DISPATCH_OP": 1 + }, + "n_ops": 1, + "dispatch": 1, + "cpu_ops": {}, + "vendor": "Qualcomm", + "soc": "SM8850", + "soc_source": "stamp", + "htp_arch": "81", + "qairt": "2.50.0", + "qairt_build": "260828221209", + "soc_in_name": "SM8850", + "dtypes": { + "fp32": 15, + "int32": 1 + }, + "io_dtypes": { + "fp32": 15, + "int32": 1 + }, + "const_bytes": {}, + "description": null, + "precision": "fp16", + "precision_basis": "htp float" + } + ], + "summary": { + "files": 4, + "npu": 4, + "mixed": 0, + "cpu": 0, + "errors": 0, + "npu_graphs": 4, + "cpu_ops_in_npu_graphs": 0, + "socs": [ + "SM8850" + ], + "qairt": [ + "2.50.0" + ], + "bytes": 1266796952 + }, + "problems": [], + "passed": true + } + }, + "device": { + "ts": 1793742181.6, + "source": "kit", + "command": "adb logcat -c; ; logcat -d -v time | grep -E 'Skel\\.so|user PD|fully accelerated|IsNonCpuFullyAccelerated|Replacing [0-9]+ out of|Partitioned subgraph|per graph ms|QnnDsp|LiteRt|litert|DISPATCH' | tail -n 400", + "output": "$ logcat -d -v time | grep -E 'Skel\\.so|user PD|fully accelerated|IsNonCpuFullyAccelerated|Replacing [0-9]+ out of|Partitioned subgraph|per graph ms|QnnDsp|LiteRt|litert|DISPATCH' | tail -n 400\n11-03 13:42:02.887 I/moonshine_stream(26638): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:02.911 I/moonshine_stream(26638): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:02.914 E/moonshine_stream(26638): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:02.919 D/moonshine_stream(26638): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:12us, fstat:0us, read:4040us, rpc_alloc:140us, mmap:368us fd 0x12 error_code 0x0\n11-03 13:42:02.919 I/moonshine_stream(26638): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:02.955 I/moonshine_stream(26638): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb400007b270457d0 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 25612 us, load time 42918 us), refs 1\n11-03 13:42:02.971 I/tflite (26638): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:03.025 I/tflite (26638): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:03.580 I/moonshine_stream(26638): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:03.590 I/moonshine_stream(26638): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb400007b270457d0 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:04.580 I/moonshine_stream(26743): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:04.604 I/moonshine_stream(26743): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:04.608 E/moonshine_stream(26743): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:04.613 D/moonshine_stream(26743): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:11us, fstat:2us, read:4319us, rpc_alloc:145us, mmap:368us fd 0x12 error_code 0x0\n11-03 13:42:04.613 I/moonshine_stream(26743): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:04.656 I/moonshine_stream(26743): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb400006f0a241be0 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 25306 us, load time 50571 us), refs 1\n11-03 13:42:04.673 I/tflite (26743): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:04.725 I/tflite (26743): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:05.105 I/moonshine_stream(26743): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:05.119 I/moonshine_stream(26743): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb400006f0a241be0 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:06.149 I/moonshine_stream(26825): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:06.175 I/moonshine_stream(26825): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:06.179 E/moonshine_stream(26825): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:06.186 D/moonshine_stream(26825): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:19us, fstat:2us, read:5932us, rpc_alloc:504us, mmap:328us fd 0x12 error_code 0x0\n11-03 13:42:06.186 I/moonshine_stream(26825): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:06.225 I/moonshine_stream(26825): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb400006fbae450a0 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 27866 us, load time 47743 us), refs 1\n11-03 13:42:06.242 I/tflite (26825): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:06.297 I/tflite (26825): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:07.038 I/moonshine_stream(26825): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:07.049 I/moonshine_stream(26825): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb400006fbae450a0 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:08.590 I/moonshine_stream(26925): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:08.617 I/moonshine_stream(26925): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:08.621 E/moonshine_stream(26925): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:08.626 D/moonshine_stream(26925): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:11us, fstat:1us, read:4272us, rpc_alloc:338us, mmap:338us fd 0x12 error_code 0x0\n11-03 13:42:08.626 I/moonshine_stream(26925): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:08.667 I/moonshine_stream(26925): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb40000795aa3e7d0 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 29114 us, load time 48121 us), refs 1\n11-03 13:42:08.685 I/tflite (26925): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:08.745 I/tflite (26925): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:09.282 I/moonshine_stream(26925): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:09.293 I/moonshine_stream(26925): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb40000795aa3e7d0 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:10.380 I/moonshine_stream(27024): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:10.410 I/moonshine_stream(27024): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:10.414 E/moonshine_stream(27024): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:10.420 D/moonshine_stream(27024): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:10us, fstat:2us, read:5850us, rpc_alloc:261us, mmap:382us fd 0x12 error_code 0x0\n11-03 13:42:10.420 I/moonshine_stream(27024): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:10.463 I/moonshine_stream(27024): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb4000073fe04a910 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 31372 us, load time 51521 us), refs 1\n11-03 13:42:10.482 I/tflite (27024): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:10.540 I/tflite (27024): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:12.441 I/moonshine_stream(27024): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:12.451 I/moonshine_stream(27024): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb4000073fe04a910 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:13.693 I/moonshine_stream(27185): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:13.719 I/moonshine_stream(27185): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:13.723 E/moonshine_stream(27185): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:13.729 D/moonshine_stream(27185): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:17us, fstat:2us, read:5070us, rpc_alloc:172us, mmap:381us fd 0x12 error_code 0x0\n11-03 13:42:13.729 I/moonshine_stream(27185): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:13.772 I/moonshine_stream(27185): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb400007ac1a43050 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 27646 us, load time 51258 us), refs 1\n11-03 13:42:13.790 I/tflite (27185): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:13.858 I/tflite (27185): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:19.286 I/moonshine_stream(27185): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:19.302 I/moonshine_stream(27185): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb400007ac1a43050 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:20.482 I/moonshine_stream(27418): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:20.509 I/moonshine_stream(27418): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:20.514 E/moonshine_stream(27418): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:20.523 D/moonshine_stream(27418): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:26us, fstat:3us, read:8099us, rpc_alloc:327us, mmap:549us fd 0x12 error_code 0x0\n11-03 13:42:20.523 I/moonshine_stream(27418): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:20.563 I/moonshine_stream(27418): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb400007b0a049410 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 29078 us, load time 52550 us), refs 1\n11-03 13:42:20.581 I/tflite (27418): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:20.648 I/tflite (27418): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:24.019 I/moonshine_stream(27418): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:24.030 I/moonshine_stream(27418): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb400007b0a049410 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:25.225 I/moonshine_stream(27615): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:25.252 I/moonshine_stream(27615): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:25.257 E/moonshine_stream(27615): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:25.266 D/moonshine_stream(27615): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:29us, fstat:3us, read:8185us, rpc_alloc:255us, mmap:399us fd 0x12 error_code 0x0\n11-03 13:42:25.266 I/moonshine_stream(27615): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:25.309 I/moonshine_stream(27615): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb400006ea9c3fcd0 (remote 0x2ce7a0) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 28590 us, load time 54980 us), refs 1\n11-03 13:42:25.327 I/tflite (27615): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:25.405 I/tflite (27615): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:25.761 I/moonshine_stream(27615): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2ce7a0\n11-03 13:42:25.772 I/moonshine_stream(27615): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb400006ea9c3fcd0 remote handle 0x2ce7a0 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:26.861 I/moonshine_stream(27690): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:26.887 I/moonshine_stream(27690): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:26.891 E/moonshine_stream(27690): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:26.896 D/moonshine_stream(27690): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:12us, fstat:1us, read:4696us, rpc_alloc:271us, mmap:376us fd 0x12 error_code 0x0\n11-03 13:42:26.896 I/moonshine_stream(27690): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:26.937 I/moonshine_stream(27690): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb4000071ea842190 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 27933 us, load time 48567 us), refs 1\n11-03 13:42:26.954 I/tflite (27690): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:27.031 I/tflite (27690): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:27.311 I/moonshine_stream(27690): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:27.321 I/moonshine_stream(27690): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb4000071ea842190 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:28.472 I/moonshine_stream(27763): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:28.498 I/moonshine_stream(27763): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:28.504 E/moonshine_stream(27763): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:28.512 D/moonshine_stream(27763): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:23us, fstat:3us, read:7818us, rpc_alloc:229us, mmap:372us fd 0x12 error_code 0x0\n11-03 13:42:28.512 I/moonshine_stream(27763): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:28.553 I/moonshine_stream(27763): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb400007a9f043fb0 (remote 0x2ce7a0) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 28472 us, load time 52494 us), refs 1\n11-03 13:42:28.570 I/tflite (27763): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:28.653 I/tflite (27763): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:31.360 I/moonshine_stream(27763): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2ce7a0\n11-03 13:42:31.370 I/moonshine_stream(27763): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb400007a9f043fb0 remote handle 0x2ce7a0 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:32.675 I/moonshine_stream(27940): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:32.702 I/moonshine_stream(27940): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:32.706 E/moonshine_stream(27940): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:32.712 D/moonshine_stream(27940): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:29us, fstat:1us, read:4753us, rpc_alloc:205us, mmap:370us fd 0x12 error_code 0x0\n11-03 13:42:32.712 I/moonshine_stream(27940): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:32.755 I/moonshine_stream(27940): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb40000714b83df10 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 29503 us, load time 50641 us), refs 1\n11-03 13:42:32.773 I/tflite (27940): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:32.859 I/tflite (27940): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:35.339 I/moonshine_stream(27940): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:35.359 I/moonshine_stream(27940): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb40000714b83df10 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:36.924 I/moonshine_stream(28120): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:36.949 I/moonshine_stream(28120): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:36.953 E/moonshine_stream(28120): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:36.958 D/moonshine_stream(28120): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:16us, fstat:2us, read:5126us, rpc_alloc:235us, mmap:376us fd 0x12 error_code 0x0\n11-03 13:42:36.958 I/moonshine_stream(28120): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:37.000 I/moonshine_stream(28120): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb40000722104ac30 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 26544 us, load time 49610 us), refs 1\n11-03 13:42:37.017 I/tflite (28120): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:37.107 I/tflite (28120): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:37.887 I/moonshine_stream(28120): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:37.898 I/moonshine_stream(28120): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb40000722104ac30 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:39.346 I/moonshine_stream(28211): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:39.373 I/moonshine_stream(28211): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:39.378 E/moonshine_stream(28211): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:39.388 D/moonshine_stream(28211): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:27us, fstat:4us, read:9221us, rpc_alloc:266us, mmap:388us fd 0x12 error_code 0x0\n11-03 13:42:39.388 I/moonshine_stream(28211): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:39.432 I/moonshine_stream(28211): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb4000077d7649370 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 28874 us, load time 57167 us), refs 1\n11-03 13:42:39.449 I/tflite (28211): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:39.544 I/tflite (28211): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:40.556 I/moonshine_stream(28211): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:40.567 I/moonshine_stream(28211): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb4000077d7649370 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:41.906 I/moonshine_stream(28324): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:41.936 I/moonshine_stream(28324): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:41.940 E/moonshine_stream(28324): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:41.946 D/moonshine_stream(28324): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:30us, fstat:2us, read:5680us, rpc_alloc:149us, mmap:385us fd 0x12 error_code 0x0\n11-03 13:42:41.946 I/moonshine_stream(28324): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:41.991 I/moonshine_stream(28324): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb400007bf703f460 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 31826 us, load time 53220 us), refs 1\n11-03 13:42:42.007 I/tflite (28324): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:42.100 I/tflite (28324): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:42.616 I/moonshine_stream(28324): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:42.628 I/moonshine_stream(28324): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb400007bf703f460 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:43.926 I/moonshine_stream(28412): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:43.954 I/moonshine_stream(28412): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:43.958 E/moonshine_stream(28412): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:43.965 D/moonshine_stream(28412): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:13us, fstat:2us, read:5633us, rpc_alloc:187us, mmap:402us fd 0x12 error_code 0x0\n11-03 13:42:43.965 I/moonshine_stream(28412): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:44.007 I/moonshine_stream(28412): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb4000073a9e43960 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 30092 us, load time 50481 us), refs 1\n11-03 13:42:44.023 I/tflite (28412): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:44.114 I/tflite (28412): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:44.739 I/moonshine_stream(28412): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:44.751 I/moonshine_stream(28412): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb4000073a9e43960 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:46.038 I/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:46.066 I/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:46.070 E/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:46.077 D/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:16us, fstat:2us, read:6158us, rpc_alloc:187us, mmap:411us fd 0x12 error_code 0x0\n11-03 13:42:46.077 I/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:46.118 I/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb400007100e49870 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 29625 us, load time 50132 us), refs 1\n11-03 13:42:46.134 I/tflite (28512): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:46.227 I/tflite (28512): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:46.813 I/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:46.824 I/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb400007100e49870 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:48.146 I/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:48.176 I/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:48.180 E/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:48.186 D/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:14us, fstat:2us, read:5335us, rpc_alloc:161us, mmap:384us fd 0x12 error_code 0x0\n11-03 13:42:48.186 I/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:48.230 I/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb400007103849af0 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 31685 us, load time 52442 us), refs 1\n11-03 13:42:48.246 I/tflite (28613): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:48.339 I/tflite (28613): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:48.889 I/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:48.901 I/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb400007103849af0 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:50.178 I/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:50.207 I/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:50.211 E/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:50.218 D/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:42us, fstat:1us, read:5476us, rpc_alloc:236us, mmap:408us fd 0x12 error_code 0x0\n11-03 13:42:50.218 I/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:50.261 I/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb4000077bc044140 (remote 0x2cea10) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 30966 us, load time 51711 us), refs 1\n11-03 13:42:50.278 I/tflite (28698): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:50.373 I/tflite (28698): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:50.888 I/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2cea10\n11-03 13:42:50.900 I/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb4000077bc044140 remote handle 0x2cea10 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n11-03 13:42:52.098 I/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3365: WARNING: get_handle_priority_from_uri: libQnnHtpV81Skel.so lib opened handle without priority token\n11-03 13:42:52.123 I/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N\n11-03 13:42:52.128 E/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:377: Error 0x2: apps_std_fopen_fd failed for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/cdsp/./libQnnHtpV81Skel.so (No such file or directory)\n11-03 13:42:52.138 D/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:369: apps_std_fopen_fd done for /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so with fsize:19708192 fopen:27us, fstat:3us, read:8845us, rpc_alloc:321us, mmap:402us fd 0x12 error_code 0x0\n11-03 13:42:52.138 I/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so\n11-03 13:42:52.181 I/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3471: remote_handle64_open: opened handle 0xb4000074e62415a0 (remote 0x2ce7a0) for file:///libQnnHtpV81Skel.so?qnn_2_50_0_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 100000 (spawn time 27399 us, load time 56153 us), refs 1\n11-03 13:42:52.200 I/tflite (28786): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:52.287 I/tflite (28786): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\n11-03 13:42:52.816 I/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3240: libQnnHtpV81Skel.so, handle 0x2ce7a0\n11-03 13:42:52.827 I/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:3610: remote_handle64_close: closed handle 0xb4000074e62415a0 remote handle 0x2ce7a0 name libQnnHtpV81Skel.so, refs 0, domain 100000, open_refs 0, non-domain handle list is empty\n\n# the kit's runs (stdout and stderr), proof lines\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite\nLiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).\nVERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "summary": "fully accelerated 3/4 \u00b7 Skel V81 loaded \u00b7 user PD \u2713", + "result": { + "proof": { + "skel": "/data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "skel_arch": "81", + "skel_loaded": true, + "user_pd": true, + "unsigned_pd": true, + "fully": { + "model=enc16_Qualcomm_SM8850_apply_plugin.tflite": true, + "model=dec512h_Qualcomm_SM8850_apply_plugin.tflite": true, + "model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite": true + }, + "fully_lines": [ + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite" + ], + "replacing": [ + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + }, + { + "n": 1, + "of": 1, + "delegate": "DispatchDelegate", + "subgraph": null, + "npu": true + } + ], + "partitioned": [], + "per_graph_ms": {}, + "lines": [ + "11-03 13:42:13.719 I/moonshine_stream(27185): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N", + "11-03 13:42:13.729 I/moonshine_stream(27185): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "11-03 13:42:13.790 I/tflite (27185): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:13.858 I/tflite (27185): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:20.509 I/moonshine_stream(27418): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N", + "11-03 13:42:20.523 I/moonshine_stream(27418): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "11-03 13:42:20.581 I/tflite (27418): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:20.648 I/tflite (27418): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:25.252 I/moonshine_stream(27615): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N", + "11-03 13:42:25.266 I/moonshine_stream(27615): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "11-03 13:42:25.327 I/tflite (27615): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:25.405 I/tflite (27615): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:26.887 I/moonshine_stream(27690): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N", + "11-03 13:42:26.896 I/moonshine_stream(27690): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "11-03 13:42:26.954 I/tflite (27690): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:27.031 I/tflite (27690): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:28.498 I/moonshine_stream(27763): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N", + "11-03 13:42:28.512 I/moonshine_stream(27763): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "11-03 13:42:28.570 I/tflite (27763): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:28.653 I/tflite (27763): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:32.702 I/moonshine_stream(27940): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N", + "11-03 13:42:32.712 I/moonshine_stream(27940): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "11-03 13:42:32.773 I/tflite (27940): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:32.859 I/tflite (27940): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:36.949 I/moonshine_stream(28120): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N", + "11-03 13:42:36.958 I/moonshine_stream(28120): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "11-03 13:42:37.017 I/tflite (28120): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:37.107 I/tflite (28120): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:39.373 I/moonshine_stream(28211): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N", + "11-03 13:42:39.388 I/moonshine_stream(28211): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "11-03 13:42:39.449 I/tflite (28211): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:39.544 I/tflite (28211): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:41.936 I/moonshine_stream(28324): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N", + "11-03 13:42:41.946 I/moonshine_stream(28324): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "11-03 13:42:42.007 I/tflite (28324): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:42.100 I/tflite (28324): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:43.954 I/moonshine_stream(28412): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N", + "11-03 13:42:43.965 I/moonshine_stream(28412): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "11-03 13:42:44.023 I/tflite (28412): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:44.114 I/tflite (28412): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:46.066 I/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N", + "11-03 13:42:46.077 I/moonshine_stream(28512): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "11-03 13:42:46.134 I/tflite (28512): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:46.227 I/tflite (28512): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:48.176 I/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N", + "11-03 13:42:48.186 I/moonshine_stream(28613): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "11-03 13:42:48.246 I/tflite (28613): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:48.339 I/tflite (28613): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:50.207 I/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N", + "11-03 13:42:50.218 I/moonshine_stream(28698): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "11-03 13:42:50.278 I/tflite (28698): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:50.373 I/tflite (28698): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:52.123 I/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/fastrpc_apps_user.c:6284: Created user PD on domain 100000, dbg_trace 0x0, enabled attr=> RPC timeout:10000, Dbg Mode:Y, CRC:N, Unsigned:Y, Signed:N, Adapt QOS:N, PD dump: (Config:N, Dbg:N), Perf: (Kernel:N, DSP:N), Iregion:N, QTF:N, UAF:N userPD initmem len:0x500000, Log pkt: N", + "11-03 13:42:52.138 I/moonshine_stream(28786): vendor/qcom/proprietary/adsprpc/src/apps_std_imp.c:1236: Successfully opened file /data/local/tmp/nnopt-verify/check-27033ada/port/dsp/./libQnnHtpV81Skel.so", + "11-03 13:42:52.200 I/tflite (28786): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "11-03 13:42:52.287 I/tflite (28786): Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=enc16_Qualcomm_SM8850_apply_plugin.tflite", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "VERBOSE: Replacing 1 out of 1 node(s) with delegate (DispatchDelegate) node, yielding 1 partitions for subgraph 0 (main).", + "LiteRT fully accelerated on the NPU: yes (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=dec1536h_Qualcomm_SM8850_apply_plugin.tflite" + ] + }, + "verdict": { + "passed": true, + "problems": [], + "summary": "fully accelerated 3/4 \u00b7 Skel V81 loaded \u00b7 user PD \u2713", + "fully": "3/4" + }, + "per_graph_ms": {} + } + }, + "benchmark": { + "ts": 1793742680.9, + "source": "kit", + "command": "/data/local/tmp/nnopt-verify/npu-bench/benchmark_model --graph=/data/local/tmp/nnopt/port/dec1536h_Qualcomm_SM8850_apply_plugin.tflite --use_npu=true --use_gpu=false --qualcomm_htp_performance_mode=burst --dispatch_library_path=/data/local/tmp/nnopt-verify/npu-bench --num_runs=20 --warmup_runs=3 (+3 more)", + "output": "dec1536h: avg 6.689 ms \u00b7 min 6.602 \u00b7 max 7.248 \u00b7 100.0% NPU\ndec4096h: avg 8.7 ms \u00b7 min 8.634 \u00b7 max 8.898 \u00b7 100.0% NPU\ndec512h: avg 5.579 ms \u00b7 min 5.514 \u00b7 max 5.979 \u00b7 100.0% NPU\nenc16: avg 4.337 ms \u00b7 min 4.285 \u00b7 max 4.481 \u00b7 100.0% NPU\n\n$ /data/local/tmp/nnopt-verify/npu-bench/benchmark_model --graph=/data/local/tmp/nnopt/port/dec1536h_Qualcomm_SM8850_apply_plugin.tflite --use_npu=true --use_gpu=false --qualcomm_htp_performance_mode=burst --dispatch_library_path=/data/local/tmp/nnopt-verify/npu-bench --num_runs=20 --warmup_runs=3\nexit 0\n [benchmark_litert_model.h:94] Model initialization: 182.51 ms\nINFO: [benchmark_litert_model.h:96] Warmup (first): 10.71 ms\nINFO: [benchmark_litert_model.h:98] Warmup (avg): 6.74 ms (75 runs)\nINFO: [benchmark_litert_model.h:100] Inference (avg): 6.69 ms (150 runs)\nINFO: [benchmark_litert_model.h:104] Inference (min): 6.60 ms\nINFO: [benchmark_litert_model.h:106] Inference (max): 7.25 ms\nINFO: [benchmark_litert_model.h:108] Inference (std): 0.07\nINFO: [benchmark_litert_model.h:115] Throughput: 8994.25 MB/s\nINFO: [benchmark_litert_model.h:124] \nMemory Usage:\nINFO: [benchmark_litert_model.h:126] Init footprint: 331.59 MB\nINFO: [benchmark_litert_model.h:128] Overall footprint: 357.92 MB\nINFO: [benchmark_litert_model.h:135] Peak memory usage not available. (peak_mem_mb <= 0)\nINFO: [benchmark_litert_model.h:138] ======================================\n\nINFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb400007bf7e04380, name=CpuAccelerator\nINFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb400007bf7e040e0, name=NpuAccelerator\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n1896549000.0ms [ INFO ] Free context with QnnGraphTransformerAdapter1896556000.0ms [ INFO ] QnnGraphTransformer context freed successfully 0.0ms [ INFO ] QnnDsp QnnContext_free started. context = 0x1\n 0.0ms [WARNING] QnnDsp m_CFBCallbackInfoObj is not initialized, return emptyList\n 0.0ms [ INFO ] QnnDsp Number of existing contexts: 0, graphs: 0\n 0.0ms [ INFO ] QnnDsp QnnContext_free done successfully.\n 0.0ms [ INFO ] QnnDsp Exiting thread\n\n$ /data/local/tmp/nnopt-verify/npu-bench/benchmark_model --graph=/data/local/tmp/nnopt/port/dec4096h_Qualcomm_SM8850_apply_plugin.tflite --use_npu=true --use_gpu=false --qualcomm_htp_performance_mode=burst --dispatch_library_path=/data/local/tmp/nnopt-verify/npu-bench --num_runs=20 --warmup_runs=3\nexit 0\n[benchmark_litert_model.h:94] Model initialization: 182.78 ms\nINFO: [benchmark_litert_model.h:96] Warmup (first): 12.71 ms\nINFO: [benchmark_litert_model.h:98] Warmup (avg): 8.77 ms (58 runs)\nINFO: [benchmark_litert_model.h:100] Inference (avg): 8.70 ms (115 runs)\nINFO: [benchmark_litert_model.h:104] Inference (min): 8.63 ms\nINFO: [benchmark_litert_model.h:106] Inference (max): 8.90 ms\nINFO: [benchmark_litert_model.h:108] Inference (std): 0.03\nINFO: [benchmark_litert_model.h:115] Throughput: 18230.55 MB/s\nINFO: [benchmark_litert_model.h:124] \nMemory Usage:\nINFO: [benchmark_litert_model.h:126] Init footprint: 331.96 MB\nINFO: [benchmark_litert_model.h:128] Overall footprint: 402.01 MB\nINFO: [benchmark_litert_model.h:135] Peak memory usage not available. (peak_mem_mb <= 0)\nINFO: [benchmark_litert_model.h:138] ======================================\n\nINFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb400006f6da05a10, name=CpuAccelerator\nINFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb400006f6da05cb0, name=NpuAccelerator\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n2234137000.0ms [ INFO ] Free context with QnnGraphTransformerAdapter2234150000.0ms [ INFO ] QnnGraphTransformer context freed successfully 0.0ms [ INFO ] QnnDsp QnnContext_free started. context = 0x1\n 0.0ms [WARNING] QnnDsp m_CFBCallbackInfoObj is not initialized, return emptyList\n 0.0ms [ INFO ] QnnDsp Number of existing contexts: 0, graphs: 0\n 0.0ms [ INFO ] QnnDsp QnnContext_free done successfully.\n 0.0ms [ INFO ] QnnDsp Exiting thread\n\n$ /data/local/tmp/nnopt-verify/npu-bench/benchmark_model --graph=/data/local/tmp/nnopt/port/dec512h_Qualcomm_SM8850_apply_plugin.tflite --use_npu=true --use_gpu=false --qualcomm_htp_performance_mode=burst --dispatch_library_path=/data/local/tmp/nnopt-verify/npu-bench --num_runs=20 --warmup_runs=3\nexit 0\n: [benchmark_litert_model.h:94] Model initialization: 178.11 ms\nINFO: [benchmark_litert_model.h:96] Warmup (first): 9.50 ms\nINFO: [benchmark_litert_model.h:98] Warmup (avg): 5.62 ms (89 runs)\nINFO: [benchmark_litert_model.h:100] Inference (avg): 5.58 ms (180 runs)\nINFO: [benchmark_litert_model.h:104] Inference (min): 5.51 ms\nINFO: [benchmark_litert_model.h:106] Inference (max): 5.98 ms\nINFO: [benchmark_litert_model.h:108] Inference (std): 0.07\nINFO: [benchmark_litert_model.h:115] Throughput: 3627.14 MB/s\nINFO: [benchmark_litert_model.h:124] \nMemory Usage:\nINFO: [benchmark_litert_model.h:126] Init footprint: 331.20 MB\nINFO: [benchmark_litert_model.h:128] Overall footprint: 339.95 MB\nINFO: [benchmark_litert_model.h:135] Peak memory usage not available. (peak_mem_mb <= 0)\nINFO: [benchmark_litert_model.h:138] ======================================\n\nINFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb400006e4ee0ad20, name=CpuAccelerator\nINFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb400006e4ee09cf0, name=NpuAccelerator\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n1758580000.0ms [ INFO ] Free context with QnnGraphTransformerAdapter1758593000.0ms [ INFO ] QnnGraphTransformer context freed successfully 0.0ms [ INFO ] QnnDsp QnnContext_free started. context = 0x1\n 0.0ms [WARNING] QnnDsp m_CFBCallbackInfoObj is not initialized, return emptyList\n 0.0ms [ INFO ] QnnDsp Number of existing contexts: 0, graphs: 0\n 0.0ms [ INFO ] QnnDsp QnnContext_free done successfully.\n 0.0ms [ INFO ] QnnDsp Exiting thread\n\n$ /data/local/tmp/nnopt-verify/npu-bench/benchmark_model --graph=/data/local/tmp/nnopt/port/enc16_Qualcomm_SM8850_apply_plugin.tflite --use_npu=true --use_gpu=false --qualcomm_htp_performance_mode=burst --dispatch_library_path=/data/local/tmp/nnopt-verify/npu-bench --num_runs=20 --warmup_runs=3\nexit 0\n.h:126] Init footprint: 254.62 MB\nINFO: [benchmark_litert_model.h:128] Overall footprint: 255.24 MB\nINFO: [benchmark_litert_model.h:135] Peak memory usage not available. (peak_mem_mb <= 0)\nINFO: [benchmark_litert_model.h:138] ======================================\n\nINFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb4000072d9406230, name=CpuAccelerator\nINFO: [accelerator_registry.cc:43] DestroyAccelerator: ptr=0xb4000072d9405ac0, name=NpuAccelerator\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister started\n 0.0ms [ INFO ] QnnDsp QnnMem_deRegister done. status 0x0\n1674846000.0ms [ INFO ] Free context with QnnGraphTransformerAdapter1674855000.0ms [ INFO ] QnnGraphTransformer context freed successfully 0.0ms [ INFO ] QnnDsp QnnContext_free started. context = 0x1\n 0.0ms [WARNING] QnnDsp m_CFBCallbackInfoObj is not initialized, return emptyList\n 0.0ms [ INFO ] QnnDsp Number of existing contexts: 0, graphs: 0\n 0.0ms [ INFO ] QnnDsp QnnContext_free done successfully.\n 0.0ms [ INFO ] QnnDsp Exiting thread", + "summary": "4 of 4 timed \u00b7 4 at 100% NPU", + "result": { + "litert": "2.3.1", + "kit_dir": "/data/local/tmp/nnopt-verify/npu-bench", + "runs": [ + { + "avg_ms": 6.689, + "min_ms": 6.602, + "max_ms": 7.248, + "count": 150, + "init_ms": null, + "npu_pct": 100.0, + "partitions": [ + "1 of 1 nodes -> DispatchDelegate" + ], + "errors": [ + "0.0ms [WARNING] QnnDsp setInferenceBufferForHtpExtensionSkel: not supported for DeviceId 0 coreId 0 pdId 0", + "0.0ms [WARNING] QnnDsp setInferenceBufferForHtpExtensionSkel not supported on this platform" + ], + "graph": "dec1536h", + "signature": null, + "exit": 0 + }, + { + "avg_ms": 8.7, + "min_ms": 8.634, + "max_ms": 8.898, + "count": 115, + "init_ms": null, + "npu_pct": 100.0, + "partitions": [ + "1 of 1 nodes -> DispatchDelegate" + ], + "errors": [ + "0.0ms [WARNING] QnnDsp setInferenceBufferForHtpExtensionSkel: not supported for DeviceId 0 coreId 0 pdId 0", + "0.0ms [WARNING] QnnDsp setInferenceBufferForHtpExtensionSkel not supported on this platform" + ], + "graph": "dec4096h", + "signature": null, + "exit": 0 + }, + { + "avg_ms": 5.579, + "min_ms": 5.514, + "max_ms": 5.979, + "count": 180, + "init_ms": null, + "npu_pct": 100.0, + "partitions": [ + "1 of 1 nodes -> DispatchDelegate" + ], + "errors": [ + "0.0ms [WARNING] QnnDsp setInferenceBufferForHtpExtensionSkel: not supported for DeviceId 0 coreId 0 pdId 0", + "0.0ms [WARNING] QnnDsp setInferenceBufferForHtpExtensionSkel not supported on this platform" + ], + "graph": "dec512h", + "signature": null, + "exit": 0 + }, + { + "avg_ms": 4.337, + "min_ms": 4.285, + "max_ms": 4.481, + "count": 231, + "init_ms": null, + "npu_pct": 100.0, + "partitions": [ + "1 of 1 nodes -> DispatchDelegate" + ], + "errors": [ + "0.0ms [WARNING] QnnDsp setInferenceBufferForHtpExtensionSkel: not supported for DeviceId 0 coreId 0 pdId 0", + "0.0ms [WARNING] QnnDsp setInferenceBufferForHtpExtensionSkel not supported on this platform" + ], + "graph": "enc16", + "signature": null, + "exit": 0 + } + ], + "problems": [], + "skipped": [], + "gaps": [], + "flags": [ + "--use_npu=true", + "--use_gpu=false", + "--qualcomm_htp_performance_mode=burst" + ] + } + } + } + }, + "grade": { + "correctness": true, + "speed_target_met": null, + "details": { + "kit_version": "0.1.0", + "bundle_digest": "c7d954ce39edc45e6fd42110f3535d1626753842f9616a1fe42086102692da2d", + "model_type": "speech_to_text", + "precision": "original", + "split": "all", + "final": true, + "correctness": { + "passed": true, + "failed_checks": [], + "flags": [], + "metrics": { + "wer_vs_reference": 0.0, + "wer_port_vs_truth": 0.08235, + "wer_reference_vs_truth": 0.08235, + "wer_delta_vs_truth": 0.0, + "cases_with_truth": 8 + }, + "errors": [] + }, + "benchmark": { + "tokens_per_s": 40.3124, + "ttft_ms": 38.595, + "real_time_factor": 0.0761763, + "latency_ms": 435.695, + "load_ms": 285.8, + "peak_mem_mb": 622.8, + "flags": [] + } + } + }, + "check": { + "kind": "check", + "model_type": "speech_to_text", + "precision": "original", + "split": "all", + "bundle_digest": "c7d954ce39edc45e6fd42110f3535d1626753842f9616a1fe42086102692da2d", + "port": { + "dir": "/data/local/tmp/nnopt/port", + "port_json": { + "contract": 1, + "model_type": "speech_to_text", + "model": "Moonshine v2 Streaming Medium (moonshine-ai/moonshine-streaming, tensilier checkpoint)", + "runtime": "LiteRT 2.3.1, Qualcomm dispatch, QNN 2.50.0", + "litert_version": "2.3.1", + "backend": "litert-qnn", + "soc": "SM8850", + "htp_arch": "v81", + "qairt_version": "2.50.0", + "precision": "fp16", + "cpu_fallback": false, + "graphs": [ + "enc16_Qualcomm_SM8850_apply_plugin.tflite", + "dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "dec1536h_Qualcomm_SM8850_apply_plugin.tflite", + "dec4096h_Qualcomm_SM8850_apply_plugin.tflite" + ] + }, + "tree_sha256": "70dbc157c9231bfb7a3fdff3f0963b20ca125cd5b6b02f49c6b3c7e787c95bf1", + "external_sha256": {} + }, + "executor": { + "executor": "adb", + "os": "android" + }, + "thresholds": { + "wer_vs_reference_max": 0.02, + "wer_delta_vs_truth_max": 0.01 + }, + "checks": [ + { + "name": "cases_completed", + "value": 1.0, + "op": ">=", + "threshold": 1.0, + "passed": true, + "detail": "19/19 cases produced valid output" + }, + { + "name": "wer_vs_reference", + "value": 0.0, + "op": "<=", + "threshold": 0.02, + "passed": true, + "detail": "port transcripts vs reference transcripts" + }, + { + "name": "wer_delta_vs_truth", + "value": 0.0, + "op": "<=", + "threshold": 0.01, + "passed": true, + "detail": "WER vs truth: port 0.082, reference 0.082" + } + ], + "metrics": { + "wer_vs_reference": 0.0, + "wer_port_vs_truth": 0.08235, + "wer_reference_vs_truth": 0.08235, + "wer_delta_vs_truth": 0.0, + "cases_with_truth": 8 + }, + "cases": [ + { + "id": "p000", + "split": "public", + "origin": "builtin", + "transcribe": { + "rc": 0, + "wall_ms": 792.1, + "peak_rss_mb": 621.0 + }, + "port_text": "The quick brown fox jumps over the lazy dog near the river bank.", + "ref_text": "The quick brown fox jumps over the lazy dog near the river bank.", + "wer_vs_reference": 0.0, + "truth": "The quick brown fox jumps over the lazy dog near the river bank." + }, + { + "id": "p001", + "split": "public", + "origin": "builtin", + "transcribe": { + "rc": 0, + "wall_ms": 627.0, + "peak_rss_mb": 620.6 + }, + "port_text": "Please call me back when you get home this evening.", + "ref_text": "Please call me back when you get home this evening.", + "wer_vs_reference": 0.0, + "truth": "Please call me back when you get home this evening." + }, + { + "id": "p002", + "split": "public", + "origin": "customer", + "transcribe": { + "rc": 0, + "wall_ms": 989.2, + "peak_rss_mb": 621.1 + }, + "port_text": "Mister Quilter is the apostle of the middle classes, and we are glad to welcome his gospel.", + "ref_text": "Mister Quilter is the apostle of the middle classes, and we are glad to welcome his gospel.", + "wer_vs_reference": 0.0 + }, + { + "id": "p003", + "split": "public", + "origin": "customer", + "transcribe": { + "rc": 0, + "wall_ms": 806.7, + "peak_rss_mb": 621.0 + }, + "port_text": "Nor is Mister Quilter's manner less interesting than his matter.", + "ref_text": "Nor is Mister Quilter's manner less interesting than his matter.", + "wer_vs_reference": 0.0 + }, + { + "id": "p004", + "split": "public", + "origin": "customer", + "transcribe": { + "rc": 0, + "wall_ms": 2177.0, + "peak_rss_mb": 621.8 + }, + "port_text": "He tells us that at this festive season of the year, with Christmas and roast beef looming before us, similes drawn from eating and its results occur most readily to the mind.", + "ref_text": "He tells us that at this festive season of the year, with Christmas and roast beef looming before us, similes drawn from eating and its results occur most readily to the mind.", + "wer_vs_reference": 0.0 + }, + { + "id": "p005", + "split": "public", + "origin": "customer", + "transcribe": { + "rc": 0, + "wall_ms": 5744.0, + "peak_rss_mb": 622.6 + }, + "port_text": "Linnell's pictures are a sort of up guards and atom paintings and Mason's exquisite idylls are as national as a jingo poem. Mr. Burkitt fosters landscapes smile at one much in the same way that Mr. Carker used to flash his teeth. And Mr. John Collier gives his sitter a cheerful slap in the back before he says like a shampoo in a Turkish bath, \"Next man,", + "ref_text": "Linnell's pictures are a sort of up guards and atom paintings and Mason's exquisite idylls are as national as a jingo poem. Mr. Burkitt fosters landscapes smile at one much in the same way that Mr. Carker used to flash his teeth. And Mr. John Collier gives his sitter a cheerful slap in the back before he says like a shampoo in a Turkish bath, \"Next man,", + "wer_vs_reference": 0.0 + }, + { + "id": "p006", + "split": "public", + "origin": "customer", + "transcribe": { + "rc": 0, + "wall_ms": 3679.0, + "peak_rss_mb": 622.1 + }, + "port_text": "He laments most bitterly the divorce that has been made between decorative art and what we usually call pictures. Makes the customary appeal to the last judgment, and reminds us that in the great days of art, Michelangelo was the furnishing upholsterer.", + "ref_text": "He laments most bitterly the divorce that has been made between decorative art and what we usually call pictures. Makes the customary appeal to the last judgment, and reminds us that in the great days of art, Michelangelo was the furnishing upholsterer.", + "wer_vs_reference": 0.0 + }, + { + "id": "p007", + "split": "public", + "origin": "customer", + "transcribe": { + "rc": 0, + "wall_ms": 680.5, + "peak_rss_mb": 620.9 + }, + "port_text": "By Harry Quilter, M. A.", + "ref_text": "By Harry Quilter, M. A.", + "wer_vs_reference": 0.0 + }, + { + "id": "p008", + "split": "public", + "origin": "customer", + "transcribe": { + "rc": 0, + "wall_ms": 597.0, + "peak_rss_mb": 620.7 + }, + "port_text": "He doesn't work at all.", + "ref_text": "He doesn't work at all.", + "wer_vs_reference": 0.0 + }, + { + "id": "p009", + "split": "public", + "origin": "customer", + "transcribe": { + "rc": 0, + "wall_ms": 3059.0, + "peak_rss_mb": 622.0 + }, + "port_text": "Having returned to the royal cavern, Calico first pounded the gong, and then sat in the throne, wearing Ruggedo's discarded ruby crown, and holding in his hand the sceptre which Ruggedo had so often thrown at his head.", + "ref_text": "Having returned to the royal cavern, Calico first pounded the gong, and then sat in the throne, wearing Ruggedo's discarded ruby crown, and holding in his hand the sceptre which Ruggedo had so often thrown at his head.", + "wer_vs_reference": 0.0 + }, + { + "id": "p010", + "split": "public", + "origin": "customer", + "transcribe": { + "rc": 0, + "wall_ms": 2841.0, + "peak_rss_mb": 621.9 + }, + "port_text": "The cardona's chest still dripping blood, the ache of his overstrained eyes, even the soaring arena around him with thousands of spectators, were trivialities not worth thinking about.", + "ref_text": "The cardona's chest still dripping blood, the ache of his overstrained eyes, even the soaring arena around him with thousands of spectators, were trivialities not worth thinking about.", + "wer_vs_reference": 0.0 + }, + { + "id": "p011", + "split": "public", + "origin": "customer", + "transcribe": { + "rc": 0, + "wall_ms": 1137.0, + "peak_rss_mb": 621.0 + }, + "port_text": "A red-haired mountain of a man with an apparently inexhaustible store of energy.", + "ref_text": "A red-haired mountain of a man with an apparently inexhaustible store of energy.", + "wer_vs_reference": 0.0 + }, + { + "id": "p012", + "split": "public", + "origin": "customer", + "transcribe": { + "rc": 0, + "wall_ms": 1410.0, + "peak_rss_mb": 620.8 + }, + "port_text": "Breathing deeply, Breon softly spoke the auto-hypnotic phrases that triggered the process.", + "ref_text": "Breathing deeply, Breon softly spoke the auto-hypnotic phrases that triggered the process.", + "wer_vs_reference": 0.0 + }, + { + "id": "h000", + "split": "hidden", + "origin": "generated", + "transcribe": { + "rc": 0, + "wall_ms": 893.0, + "peak_rss_mb": 621.0 + }, + "port_text": "My brother cleaned the lantern and gave it to Dalai.", + "ref_text": "My brother cleaned the lantern and gave it to Dalai.", + "wer_vs_reference": 0.0, + "truth": "My brother cleaned the lantern and gave it to Dalia." + }, + { + "id": "h001", + "split": "hidden", + "origin": "generated", + "transcribe": { + "rc": 0, + "wall_ms": 1003.0, + "peak_rss_mb": 621.1 + }, + "port_text": "The hidden market in Accra opens at 5:00 in the morning.", + "ref_text": "The hidden market in Accra opens at 5:00 in the morning.", + "wer_vs_reference": 0.0, + "truth": "The hidden market in Accra opens at five in the morning." + }, + { + "id": "h002", + "split": "hidden", + "origin": "generated", + "transcribe": { + "rc": 0, + "wall_ms": 957.3, + "peak_rss_mb": 620.5 + }, + "port_text": "When said, the weather in Dauphereza was busy all week.", + "ref_text": "When said, the weather in Dauphereza was busy all week.", + "wer_vs_reference": 0.0, + "truth": "Wen said the weather in Valparaiso was busy all week." + }, + { + "id": "h003", + "split": "hidden", + "origin": "generated", + "transcribe": { + "rc": 0, + "wall_ms": 926.1, + "peak_rss_mb": 620.8 + }, + "port_text": "Nobody expected the ancient camera to sell for so much money.", + "ref_text": "Nobody expected the ancient camera to sell for so much money.", + "wer_vs_reference": 0.0, + "truth": "Nobody expected the ancient camera to sell for so much money." + }, + { + "id": "h004", + "split": "hidden", + "origin": "generated", + "transcribe": { + "rc": 0, + "wall_ms": 894.9, + "peak_rss_mb": 621.3 + }, + "port_text": "There are 16 boats waiting in the harbor tonight.", + "ref_text": "There are 16 boats waiting in the harbor tonight.", + "wer_vs_reference": 0.0, + "truth": "There are sixteen boats waiting in the harbor tonight." + }, + { + "id": "h005", + "split": "hidden", + "origin": "generated", + "transcribe": { + "rc": 0, + "wall_ms": 886.4, + "peak_rss_mb": 620.5 + }, + "port_text": "Anna and Bruno met for coffee near the Musum in Marrakech.", + "ref_text": "Anna and Bruno met for coffee near the Musum in Marrakech.", + "wer_vs_reference": 0.0, + "truth": "Hana and Bruno met for coffee near the museum in Marrakesh." + } + ], + "flags": [], + "errors": [], + "passed": true, + "started_at": "2026-11-03T21:42:06Z", + "processor": null, + "seconds": 54.52, + "samples": "/out/samples/samples.json" + }, + "bench": { + "kind": "bench", + "model_type": "speech_to_text", + "bundle_digest": "c7d954ce39edc45e6fd42110f3535d1626753842f9616a1fe42086102692da2d", + "case": "p000", + "port": { + "dir": "/data/local/tmp/nnopt/port", + "port_json": { + "contract": 1, + "model_type": "speech_to_text", + "model": "Moonshine v2 Streaming Medium (moonshine-ai/moonshine-streaming, tensilier checkpoint)", + "runtime": "LiteRT 2.3.1, Qualcomm dispatch, QNN 2.50.0", + "litert_version": "2.3.1", + "backend": "litert-qnn", + "soc": "SM8850", + "htp_arch": "v81", + "qairt_version": "2.50.0", + "precision": "fp16", + "cpu_fallback": false, + "graphs": [ + "enc16_Qualcomm_SM8850_apply_plugin.tflite", + "dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "dec1536h_Qualcomm_SM8850_apply_plugin.tflite", + "dec4096h_Qualcomm_SM8850_apply_plugin.tflite" + ] + }, + "tree_sha256": "70dbc157c9231bfb7a3fdff3f0963b20ca125cd5b6b02f49c6b3c7e787c95bf1", + "external_sha256": {} + }, + "executor": { + "executor": "adb", + "os": "android" + }, + "environment": { + "os": "Android", + "gpu": "Adreno 840", + "soc": "Snapdragon 8 Elite Gen 5", + "brand": "Samsung", + "device": "Samsung Galaxy S26+", + "ram_gb": 12, + "android": "16", + "gpu_apis": [ + "OpenCL", + "Vulkan" + ], + "released": "2026-02", + "roofline": { + "npu": { + "job": "NN-174CC0", + "source": "measured by lab/npu probe (NN-174CC0) on 2026-10-31: fp16 weight stream 69.93 GB/s (bw_l24), fp16 matmul 18.325 TFLOPS, int8 matmul 29.023 TOPS; LiteRT 2.3.1 + Qualcomm dispatch, QAIRT 2.50, burst", + "measured": true, + "measured_at": "2026-10-31", + "measured_by": "probe", + "peak_int8_tops": 29.023, + "peak_fp16_tflops": 18.325, + "mem_bandwidth_gbps": 69.93, + "mem_bandwidth_int8_gbps": 70.46 + }, + "spec": { + "source": "spec-sheet estimate, not yet measured: LPDDR5X-10667 64-bit; Adreno 840 compute is a rough estimate", + "peak_int8_tops": 6.0, + "peak_fp16_tflops": 6.0, + "mem_bandwidth_gbps": 85.3 + }, + "source": "measured on the device by NN-A61C46 on 2026-11-03: GPU read 72.6 GB/s (OpenCL read_v4)", + "measured": true, + "device_best": { + "cpu_job": "NN-DA0137", + "gpu_job": "NN-DA0137", + "cpu_read_gbps": 74.03, + "gpu_read_gbps": 73.18, + "cpu_measured_at": "2026-10-23T04:46:29+00:00", + "gpu_measured_at": "2026-10-23T04:46:29+00:00" + }, + "measured_at": "2026-11-03", + "measured_by": "device", + "device_probe": { + "job": "NN-A61C46", + "measured_at": "2026-11-03T03:40:37+00:00", + "cpu_read_gbps": 60.38, + "gpu_read_gbps": 72.6 + }, + "peak_int8_tops": 6.0, + "peak_fp16_tflops": 6.0, + "mem_bandwidth_gbps": 72.6 + }, + "model_id": "m2q", + "version_id": "36", + "name": "Samsung Galaxy S26+", + "processor": "npu" + }, + "model_facts": { + "params": 401858735, + "source": "nnopt scoping" + }, + "config": { + "warmup": 2, + "runs": 5, + "repeat": 3, + "max_new_tokens": 128, + "external_check": true, + "sustained_s": 0.0, + "sustained_repeat": 10, + "sample_interval_s": 2.0, + "mem_interval_ms": 200, + "timeout_s": 1800.0, + "case": null, + "prompt_tokens": null, + "batch": 1, + "external_min_s": 2.0, + "external_max_repeat": 500, + "resolution": null, + "seconds": 10.0, + "time_budget_s": 6134.9, + "adapt": true, + "cool_wait_s": 600.0, + "rest_s": 3.0 + }, + "precision": "original", + "flags": [], + "errors": [], + "method": { + "warmup": 2, + "runs": 5, + "repeat": 3, + "adapted": false, + "first_run_s": 0.9, + "time_budget_s": 6135, + "estimate_s": 342 + }, + "started_at": "2026-11-03T21:43:01Z", + "cooldown": { + "waited_s": 319.9, + "start": { + "temp_c": 47.7, + "capped": [ + "policy0 1785/3628 MHz", + "policy6 1747/4742 MHz" + ], + "limits": { + "policy0": 1785600, + "policy6": 1747200 + }, + "status": 1 + }, + "end": { + "temp_c": 39.5, + "capped": [ + "policy0 3187/3628 MHz", + "policy6 3398/4742 MHz" + ], + "limits": { + "policy0": 3187200, + "policy6": 3398400 + }, + "status": 0 + }, + "why": "plateau" + }, + "timed_telemetry": { + "samples": 141, + "seconds": 159.7, + "max_temp_c": { + "min": 105.0, + "max": 105.0, + "mean": 105.0 + }, + "gpu_temp_c": { + "min": 37.8, + "max": 47.5, + "mean": 39.59 + }, + "cpu_temp_c": { + "min": 105.0, + "max": 105.0, + "mean": 105.0 + }, + "gpu_mhz": null, + "cpu_mhz_max": { + "min": 883.2, + "max": 3398.0, + "mean": 1363.0 + }, + "gpu_busy_pct": { + "min": 0.0, + "max": 0.0, + "mean": 0.0 + }, + "power_w": null, + "power_source": null, + "ram_used_mb": null + }, + "cpu_caps": { + "runs": 5, + "capped": 0, + "waited_s": 119.4, + "caps": [] + }, + "runs": [ + { + "wall_ms": 1711.91, + "load_ms": 285.8, + "peak_rss_mb": 621.0, + "peak_hwm_mb": 621.2, + "self_peak_mem_mb": 619.7, + "requests": [ + { + "total_ms": 454.63, + "latency_ms": 454.63, + "real_time_factor": 0.07948684886300306, + "ttft_ms": 45.02, + "new_tokens": 17, + "prompt_tokens": null, + "tokens_per_s": 39.06154634896609 + }, + { + "total_ms": 438.57, + "latency_ms": 438.57, + "real_time_factor": 0.07667894178969108, + "ttft_ms": 39.44, + "new_tokens": 17, + "prompt_tokens": null, + "tokens_per_s": 40.08718963746148 + }, + { + "total_ms": 435.79, + "latency_ms": 435.79, + "real_time_factor": 0.07619289062756111, + "ttft_ms": 39.04, + "new_tokens": 17, + "prompt_tokens": null, + "tokens_per_s": 40.327662255828606 + } + ], + "cpu": { + "temp_c": 40.3, + "capped": [], + "waited_s": 0.0 + } + }, + { + "wall_ms": 1675.38, + "load_ms": 270.8, + "peak_rss_mb": 621.0, + "peak_hwm_mb": 621.0, + "self_peak_mem_mb": 619.6, + "requests": [ + { + "total_ms": 440.7, + "latency_ms": 440.7, + "real_time_factor": 0.07705134789592735, + "ttft_ms": 45.12, + "new_tokens": 17, + "prompt_tokens": null, + "tokens_per_s": 40.44693867232924 + }, + { + "total_ms": 435.33, + "latency_ms": 435.33, + "real_time_factor": 0.07611246489569787, + "ttft_ms": 38.84, + "new_tokens": 17, + "prompt_tokens": null, + "tokens_per_s": 40.35410729148276 + }, + { + "total_ms": 435.76, + "latency_ms": 435.76, + "real_time_factor": 0.07618764547113524, + "ttft_ms": 38.56, + "new_tokens": 17, + "prompt_tokens": null, + "tokens_per_s": 40.28197381671702 + } + ], + "cpu": { + "temp_c": 39.9, + "capped": [], + "waited_s": 35.6 + } + }, + { + "wall_ms": 1701.05, + "load_ms": 291.7, + "peak_rss_mb": 621.0, + "peak_hwm_mb": 621.0, + "self_peak_mem_mb": 619.6, + "requests": [ + { + "total_ms": 441.03, + "latency_ms": 441.03, + "real_time_factor": 0.07710904461661183, + "ttft_ms": 45.11, + "new_tokens": 17, + "prompt_tokens": null, + "tokens_per_s": 40.41220448575471 + }, + { + "total_ms": 434.32, + "latency_ms": 434.32, + "real_time_factor": 0.07593587796269381, + "ttft_ms": 38.61, + "new_tokens": 17, + "prompt_tokens": null, + "tokens_per_s": 40.43365090596649 + }, + { + "total_ms": 435.1, + "latency_ms": 435.1, + "real_time_factor": 0.07607225202976627, + "ttft_ms": 38.35, + "new_tokens": 17, + "prompt_tokens": null, + "tokens_per_s": 40.327662255828606 + } + ], + "cpu": { + "temp_c": 39.9, + "capped": [], + "waited_s": 24.3 + } + }, + { + "wall_ms": 1705.14, + "load_ms": 296.5, + "peak_rss_mb": 620.9, + "peak_hwm_mb": 620.9, + "self_peak_mem_mb": 619.5, + "requests": [ + { + "total_ms": 441.09, + "latency_ms": 441.09, + "real_time_factor": 0.07711953492946357, + "ttft_ms": 45.11, + "new_tokens": 17, + "prompt_tokens": null, + "tokens_per_s": 40.40608111520785 + }, + { + "total_ms": 434.18, + "latency_ms": 434.18, + "real_time_factor": 0.07591140056603979, + "ttft_ms": 38.27, + "new_tokens": 17, + "prompt_tokens": null, + "tokens_per_s": 40.41322522795584 + }, + { + "total_ms": 435.79, + "latency_ms": 435.79, + "real_time_factor": 0.07619289062756111, + "ttft_ms": 38.46, + "new_tokens": 17, + "prompt_tokens": null, + "tokens_per_s": 40.26879420129363 + } + ], + "cpu": { + "temp_c": 39.1, + "capped": [], + "waited_s": 23.8 + } + }, + { + "wall_ms": 1674.61, + "load_ms": 263.8, + "peak_rss_mb": 622.8, + "peak_hwm_mb": 622.8, + "self_peak_mem_mb": 621.5, + "requests": [ + { + "total_ms": 442.99, + "latency_ms": 442.99, + "real_time_factor": 0.07745172816976822, + "ttft_ms": 45.47, + "new_tokens": 17, + "prompt_tokens": null, + "tokens_per_s": 40.249547192594086 + }, + { + "total_ms": 438.67, + "latency_ms": 438.67, + "real_time_factor": 0.07669642564444396, + "ttft_ms": 38.66, + "new_tokens": 17, + "prompt_tokens": null, + "tokens_per_s": 39.999000024999376 + }, + { + "total_ms": 435.63, + "latency_ms": 435.63, + "real_time_factor": 0.0761649164599565, + "ttft_ms": 38.58, + "new_tokens": 17, + "prompt_tokens": null, + "tokens_per_s": 40.29719178944717 + } + ], + "cpu": { + "temp_c": 39.9, + "capped": [], + "waited_s": 35.7 + } + } + ], + "summary": { + "real_time_factor": { + "n": 10, + "median": 0.0761763, + "mean": 0.0762146, + "min": 0.0759114, + "max": 0.0766964, + "p10": 0.0759334, + "p90": 0.0766807 + }, + "latency_ms": { + "n": 10, + "median": 435.695, + "mean": 435.914, + "min": 434.18, + "max": 438.67, + "p10": 434.306, + "p90": 438.58 + }, + "tokens_per_s": { + "n": 10, + "median": 40.3124, + "mean": 40.279, + "min": 39.999, + "max": 40.4337, + "p10": 40.0784, + "p90": 40.4153 + }, + "ttft_ms": { + "n": 10, + "median": 38.595, + "mean": 38.681, + "min": 38.27, + "max": 39.44, + "p10": 38.342, + "p90": 39.08 + }, + "prompt_tokens": { + "n": 0, + "median": null, + "mean": null, + "min": null, + "max": null, + "p10": null, + "p90": null + }, + "new_tokens": { + "n": 10, + "median": 17.0, + "mean": 17.0, + "min": 17.0, + "max": 17.0, + "p10": 17.0, + "p90": 17.0 + }, + "cold_latency_ms": { + "n": 5, + "median": 441.09, + "mean": 444.088, + "min": 440.7, + "max": 454.63, + "p10": 440.832, + "p90": 449.974 + }, + "load_ms": { + "n": 5, + "median": 285.8, + "mean": 281.72, + "min": 263.8, + "max": 296.5, + "p10": 266.6, + "p90": 294.58 + }, + "wall_ms": { + "n": 5, + "median": 1701.05, + "mean": 1693.62, + "min": 1674.61, + "max": 1711.91, + "p10": 1674.92, + "p90": 1709.2 + }, + "peak_rss_mb": 622.8, + "peak_hwm_mb": 622.8, + "self_reported_peak_mem_mb": 621.5 + }, + "external": { + "available": true, + "method": "paired --repeat 3 vs 1", + "pairs": 5, + "latency_ms": 440.8, + "real_time_factor": 0.07707 + }, + "graded": { + "real_time_factor": 0.0761763, + "latency_ms": 435.695, + "tokens_per_s": 40.3124, + "ttft_ms": 38.595, + "new_tokens": 17.0, + "cold_latency_ms": 441.09, + "load_ms": 285.8, + "wall_ms": 1701.05, + "peak_mem_mb": 622.8 + }, + "roofline": { + "mem_bandwidth_gbps": 69.93, + "peak_gflops": 18325.0, + "figures": { + "processor": "npu", + "figures": "npu", + "source": "measured by lab/npu probe (NN-174CC0) on 2026-10-31: fp16 weight stream 69.93 GB/s (bw_l24), fp16 matmul 18.325 TFLOPS, int8 matmul 29.023 TOPS; LiteRT 2.3.1 + Qualcomm dispatch, QAIRT 2.50, burst" + }, + "decode_bytes_per_token": 401900000.0, + "decode_bytes_basis": "half of the 0.402 B parameters taken as the decoder (the model facts give no decoder size)", + "decode_bound_tokens_per_s": 174.0, + "decode_pct_of_roofline": 23.17, + "decode_plausibility_cap": 2923.0 + }, + "processor": null, + "seconds": 488.01 + }, + "reference": { + "format": "nnopt-reference-bundle", + "version": 1, + "job_id": "NN-466F3D", + "model_type": "speech_to_text", + "precision_policy": "original", + "model": { + "kind": "contract", + "program": "/work/reference_runner" + }, + "runner": { + "kind": "contract", + "program": "/work/reference_runner" + }, + "params": { + "audio": "16 kHz mono PCM16 WAV", + "hidden_audio_source": { + "model": "facebook/mms-tts-eng", + "augment": "gain, noise 20-35 dB SNR, padding" + } + }, + "tools": { + "python": "3.12.3", + "numpy": "2.5.4", + "nnopt_verify": "0.1.0", + "platform": "Linux-7.0.0-1014-gcp-x86_64-with-glibc2.39" + }, + "created_at": "2026-11-03T20:26:58Z", + "cases": [ + { + "id": "p000", + "split": "public", + "origin": "builtin", + "files": { + "input": "inputs/p000.wav", + "input_meta": "inputs/p000.json", + "output": "outputs/p000.json" + }, + "meta": { + "truth": "The quick brown fox jumps over the lazy dog near the river bank." + } + }, + { + "id": "p001", + "split": "public", + "origin": "builtin", + "files": { + "input": "inputs/p001.wav", + "input_meta": "inputs/p001.json", + "output": "outputs/p001.json" + }, + "meta": { + "truth": "Please call me back when you get home this evening." + } + }, + { + "id": "p002", + "split": "public", + "origin": "customer", + "files": { + "input": "inputs/p002.wav", + "input_meta": "inputs/p002.json", + "output": "outputs/p002.json" + }, + "meta": { + "name": "found_1272-128104-0000" + } + }, + { + "id": "p003", + "split": "public", + "origin": "customer", + "files": { + "input": "inputs/p003.wav", + "input_meta": "inputs/p003.json", + "output": "outputs/p003.json" + }, + "meta": { + "name": "found_1272-128104-0001" + } + }, + { + "id": "p004", + "split": "public", + "origin": "customer", + "files": { + "input": "inputs/p004.wav", + "input_meta": "inputs/p004.json", + "output": "outputs/p004.json" + }, + "meta": { + "name": "found_1272-128104-0002" + } + }, + { + "id": "p005", + "split": "public", + "origin": "customer", + "files": { + "input": "inputs/p005.wav", + "input_meta": "inputs/p005.json", + "output": "outputs/p005.json" + }, + "meta": { + "name": "found_1272-128104-0004" + } + }, + { + "id": "p006", + "split": "public", + "origin": "customer", + "files": { + "input": "inputs/p006.wav", + "input_meta": "inputs/p006.json", + "output": "outputs/p006.json" + }, + "meta": { + "name": "found_1272-128104-0009" + } + }, + { + "id": "p007", + "split": "public", + "origin": "customer", + "files": { + "input": "inputs/p007.wav", + "input_meta": "inputs/p007.json", + "output": "outputs/p007.json" + }, + "meta": { + "name": "found_1272-128104-0014" + } + }, + { + "id": "p008", + "split": "public", + "origin": "customer", + "files": { + "input": "inputs/p008.wav", + "input_meta": "inputs/p008.json", + "output": "outputs/p008.json" + }, + "meta": { + "name": "found_1272-135031-0009" + } + }, + { + "id": "p009", + "split": "public", + "origin": "customer", + "files": { + "input": "inputs/p009.wav", + "input_meta": "inputs/p009.json", + "output": "outputs/p009.json" + }, + "meta": { + "name": "found_1272-135031-0024" + } + }, + { + "id": "p010", + "split": "public", + "origin": "customer", + "files": { + "input": "inputs/p010.wav", + "input_meta": "inputs/p010.json", + "output": "outputs/p010.json" + }, + "meta": { + "name": "found_1272-141231-0002" + } + }, + { + "id": "p011", + "split": "public", + "origin": "customer", + "files": { + "input": "inputs/p011.wav", + "input_meta": "inputs/p011.json", + "output": "outputs/p011.json" + }, + "meta": { + "name": "found_1272-141231-0018" + } + }, + { + "id": "p012", + "split": "public", + "origin": "customer", + "files": { + "input": "inputs/p012.wav", + "input_meta": "inputs/p012.json", + "output": "outputs/p012.json" + }, + "meta": { + "name": "found_1272-141231-0026" + } + }, + { + "id": "h000", + "split": "hidden", + "origin": "generated", + "files": { + "input": "inputs/h000.wav", + "input_meta": "inputs/h000.json", + "output": "outputs/h000.json" + }, + "meta": { + "truth": "My brother cleaned the lantern and gave it to Dalia." + } + }, + { + "id": "h001", + "split": "hidden", + "origin": "generated", + "files": { + "input": "inputs/h001.wav", + "input_meta": "inputs/h001.json", + "output": "outputs/h001.json" + }, + "meta": { + "truth": "The hidden market in Accra opens at five in the morning." + } + }, + { + "id": "h002", + "split": "hidden", + "origin": "generated", + "files": { + "input": "inputs/h002.wav", + "input_meta": "inputs/h002.json", + "output": "outputs/h002.json" + }, + "meta": { + "truth": "Wen said the weather in Valparaiso was busy all week." + } + }, + { + "id": "h003", + "split": "hidden", + "origin": "generated", + "files": { + "input": "inputs/h003.wav", + "input_meta": "inputs/h003.json", + "output": "outputs/h003.json" + }, + "meta": { + "truth": "Nobody expected the ancient camera to sell for so much money." + } + }, + { + "id": "h004", + "split": "hidden", + "origin": "generated", + "files": { + "input": "inputs/h004.wav", + "input_meta": "inputs/h004.json", + "output": "outputs/h004.json" + }, + "meta": { + "truth": "There are sixteen boats waiting in the harbor tonight." + } + }, + { + "id": "h005", + "split": "hidden", + "origin": "generated", + "files": { + "input": "inputs/h005.wav", + "input_meta": "inputs/h005.json", + "output": "outputs/h005.json" + }, + "meta": { + "truth": "Hana and Bruno met for coffee near the museum in Marrakesh." + } + } + ], + "splits": { + "public": [ + "p000", + "p001", + "p002", + "p003", + "p004", + "p005", + "p006", + "p007", + "p008", + "p009", + "p010", + "p011", + "p012" + ], + "hidden": [ + "h000", + "h001", + "h002", + "h003", + "h004", + "h005" + ] + }, + "notes": [], + "determinism": { + "transcribe_repeatable": true + }, + "customer_expectations": [], + "frozen_at": "2026-11-03T20:31:06Z" + } +} diff --git a/sm8850-npu-fp16/repro/Dockerfile b/sm8850-npu-fp16/repro/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0ee20390bfd179abcc459e385b0545d9f70fae58 --- /dev/null +++ b/sm8850-npu-fp16/repro/Dockerfile @@ -0,0 +1,8 @@ +# The machine nnopt built this deliverable on from scratch (REPRO.md, Tools): a public image and these +# packages, nothing of nnopt. build.sh fetches everything else itself. Build and use it: +# docker build --platform linux/amd64 -t build-env repro +# docker run --rm --platform linux/amd64 --user "$(id -u):$(id -g)" -e HOME=/tmp -v "$PWD:/src" -w /src build-env bash build.sh +FROM ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac +ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 LC_ALL=C.UTF-8 +RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates git curl python3 python3-venv build-essential unzip xz-utils \ + && rm -rf /var/lib/apt/lists/* diff --git a/sm8850-npu-fp16/repro/bench.py b/sm8850-npu-fp16/repro/bench.py new file mode 100644 index 0000000000000000000000000000000000000000..4e5f180c5f6cbcd0b36e35d5b355117d2ac0ab6a --- /dev/null +++ b/sm8850-npu-fp16/repro/bench.py @@ -0,0 +1,729 @@ +#!/usr/bin/env python3 +"""Reproduce nnopt's numbers on your own device: the speed with nnopt's exact settings and, with --check, the outputs +on the public cases. See ../REPRO.md. + +Needs python3 (3.8 or newer, no packages), sh, and adb (Android phones) or ssh and scp (a Jetson or Mac over the +network). plan.json next to this file holds the settings nnopt measured with and nnopt's numbers to compare against. + + python3 repro/bench.py # speed, nnopt's settings, compared with nnopt's numbers + python3 repro/bench.py --check # outputs on the public cases, compared with the expected outputs + python3 repro/bench.py --deploy # run deploy.sh into --dir first + python3 repro/bench.py --sustained 600 # then run back to back for 10 minutes (throttling) + python3 repro/bench.py --plan repro/galaxy-s24/plan.json # measured on several phones: your phone's numbers + +Connection: --serial SERIAL (adb; or $ANDROID_SERIAL), --ssh USER@HOST (or $SSH_TARGET), --local (this machine). +--dir is where deploy.sh installed the program on the device (default: plan.json's device_dir). +Exit code: 0 everything within tolerance, 1 something outside it, 2 an error. +""" + +from __future__ import annotations + +import argparse +import ast +import json +import math +import os +import re +import shlex +import shutil +import statistics +import struct +import subprocess +import sys +import tempfile +import time +from array import array +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parent # the deliverable: build.sh, deploy.sh, REPRO.md +TOKEN_TYPES = ("text_to_text", "vision_language") +OUT_EXT = {"text_to_text": ".json", "speech_to_text": ".json", "text_to_speech": ".wav", "vision_detection": ".json", + "vision_language": ".json", "kernel": "", "audio_generation": ".wav"} + + +class Fail(Exception): + pass + + +# ---------------------------------------------------------------- the device + +class Device: + def __init__(self, kind: str, serial: str | None = None, target: str | None = None): + self.kind, self.serial, self.target = kind, serial, target + tool = {"adb": "adb", "ssh": "ssh", "local": "sh"}[kind] + if shutil.which(tool) is None: + raise Fail(f"{tool} is not installed or not on PATH (REPRO.md, Tools)") + if kind == "ssh" and not target: + raise Fail("--ssh USER@HOST (or SSH_TARGET) is needed for this device") + + def describe(self) -> str: + return {"adb": f"adb{' -s ' + self.serial if self.serial else ''}", "ssh": f"ssh {self.target}", + "local": "this machine"}[self.kind] + + def _adb(self) -> list[str]: + return ["adb"] + (["-s", self.serial] if self.serial else []) + + def sh(self, script: str, timeout: float = 600) -> tuple[int, str]: + argv = {"adb": self._adb() + ["shell", script], "ssh": ["ssh", "-o", "BatchMode=yes", self.target or "", script], + "local": ["sh", "-c", script]}[self.kind] + try: + p = subprocess.run(argv, capture_output=True, text=True, timeout=timeout) + except subprocess.TimeoutExpired: + return 124, f"timed out after {timeout:.0f} s" + return p.returncode, p.stdout + p.stderr + + def push(self, local: Path, remote: str) -> None: + argv = {"adb": self._adb() + ["push", str(local), remote], + "ssh": ["scp", "-q", "-r", str(local), f"{self.target}:{remote}"], + "local": ["cp", "-R", str(local), remote]}[self.kind] + p = subprocess.run(argv, capture_output=True, text=True) + if p.returncode != 0: + raise Fail(f"could not copy {local.name} to the device: {(p.stdout + p.stderr).strip()[-300:]}") + + def pull(self, remote: str, local: Path) -> bool: + argv = {"adb": self._adb() + ["pull", remote, str(local)], + "ssh": ["scp", "-q", "-r", f"{self.target}:{remote}", str(local)], + "local": ["cp", "-R", remote, str(local)]}[self.kind] + return subprocess.run(argv, capture_output=True, text=True).returncode == 0 + + +# Runs one command on the device: times it with the device's own clock and samples the memory (RSS) of its process +# tree, as nnopt does. Prints "REPRO START_NS END_NS EXIT PEAK_RSS_KB". +WRAP = r""" +d={io}; t={tag} +now() {{ v=$(date +%s%N 2>/dev/null); case "$v" in ''|*N*) perl -MTime::HiRes=time -e 'printf("%.0f\n", time()*1e9)' 2>/dev/null || echo "$(date +%s)000000000";; *) echo "$v";; esac; }} +if [ -d /system/bin ]; then o="PID,PPID,RSS"; else o="pid,ppid,rss"; fi +rm -f "$d/$t.rc" "$d/$t.end" +s=$(now) +( cd {dir} && {env}sh ./run.sh {args} > "$d/$t.log" 2>&1; r=$?; now > "$d/$t.end"; echo $r > "$d/$t.rc" ) & +root=$!; peak=0 +while [ ! -f "$d/$t.rc" ]; do + m=$(ps -A -o $o 2>/dev/null | awk -v r=$root 'NR>1 {{ p[$1]=$2; k[$1]=$3 }} END {{ s=0; for (x in p) {{ q=x; n=0; while (q != "" && q != r && n < 64) {{ q=p[q]; n++ }} if (q == r) s+=k[x] }} print s+0 }}') + [ "${{m:-0}}" -gt "$peak" ] 2>/dev/null && peak=$m + sleep 0.2 +done +echo "REPRO $s $(cat "$d/$t.end") $(cat "$d/$t.rc") $peak" +""" +_MARK = re.compile(r"^REPRO (\d+) (\d+) (-?\d+) (\d+)\s*$", re.M) + + +def q(s: str) -> str: + return shlex.quote(s) + + +class Session: + """The program deployed in `folder` on the device, inputs staged in `folder`-repro-io.""" + + def __init__(self, dev: Device, folder: str, model_type: str, tmp: Path): + self.dev, self.dir, self.mt, self.tmp = dev, folder.rstrip("/"), model_type, tmp + self.io = self.dir + "-repro-io" + self.n = 0 + rc, out = dev.sh(f"test -f {q(self.dir)}/run.sh && mkdir -p {q(self.io)} && echo ok", 60) + if "ok" not in out: + raise Fail(f"no run.sh in {self.dir} on the device: deploy first (bash deploy.sh {self.dir}, or --deploy)") + + def stage(self, local: Path) -> str: + remote = f"{self.io}/{local.name}" + self.dev.push(local, remote if local.is_file() else self.io + "/") + return remote + + def run(self, args: dict, *, repeat: int = 1, fetch_out: bool = False, timeout: float = 3600, + env: dict | None = None) -> dict: + self.n += 1 + tag = f"r{self.n}" + out = f"{self.io}/{tag}.out{OUT_EXT[self.mt]}" + met = f"{self.io}/{tag}.metrics.json" + line = command(self.mt, args, out=out, metrics=met, repeat=repeat) + exports = "".join(f"{k}={q(str(v))} " for k, v in (env or {}).items()) + rc, text = self.dev.sh(WRAP.format(io=q(self.io), tag=tag, dir=q(self.dir), args=line, env=exports), timeout) + m = _MARK.search(text) + res = {"command": "sh ./run.sh " + line, "exit": int(m.group(3)) if m else rc, "wall_ms": None, + "peak_rss_mb": None, "metrics": None, "out": None} + if m: + res["wall_ms"] = (int(m.group(2)) - int(m.group(1))) / 1e6 + res["peak_rss_mb"] = int(m.group(4)) / 1024 or None + mloc = self.tmp / f"{tag}.metrics.json" + if self.dev.pull(met, mloc) and mloc.is_file(): + try: + res["metrics"] = json.loads(mloc.read_text()) + except ValueError: + pass + if fetch_out: + oloc = self.tmp / Path(out).name + if self.dev.pull(out, oloc) and oloc.exists(): + res["out"] = oloc + if res["exit"] != 0: + _, log = self.dev.sh(f"tail -c 2000 {q(self.io)}/{tag}.log", 60) + res["log"] = log + return res + + def close(self) -> None: + self.dev.sh(f"rm -rf {q(self.io)}", 120) + + +def command(mt: str, a: dict, *, out: str, metrics: str, repeat: int = 1) -> str: + """run.sh's arguments for one request (CONTRACT.md).""" + mode = a.get("mode", "generate") + args: list[str] = [] + if mt == "audio_generation": + args = ["--text-file", q(a["input"]), "--seed", str(int(a.get("seed") or 0)), + "--seconds", f"{float(a.get('seconds') or 10):.6f}".rstrip("0").rstrip(".")] + elif mt == "vision_detection": + for im in a["images"]: + args += ["--image", q(im)] + elif mt in TOKEN_TYPES: + if mt == "vision_language": + args += ["--image", q(a["image"])] + args += ["--prompt-file", q(a["input"]), "--max-new-tokens", str(int(a["max_new_tokens"]))] + if a.get("ignore_eos"): + args.append("--ignore-eos") + elif mt == "speech_to_text": + args = ["--audio", q(a["input"])] + elif mt == "kernel": + args = ["--inputs", q(a["input"])] + else: # text_to_speech + args = ["--text-file", q(a["input"]), "--seed", str(int(a.get("seed") or 0))] + args += ["--out", q(out), "--metrics", q(metrics)] + if repeat > 1: + args += ["--repeat", str(int(repeat))] + return " ".join(args) + + +# ---------------------------------------------------------------- numbers + +def derive(mt: str, r: dict, audio_s: float | None, batch: int = 1) -> dict: + """One request's numbers from the port's metrics, as nnopt computes them.""" + t = float(r.get("total_ms") or 0) + d: dict = {"total_ms": t} + if mt == "vision_detection": + d.update(latency_ms=t, per_image_ms=t / batch, fps=batch * 1000 / t if t > 0 else None) + elif mt in TOKEN_TYPES: + ttft, n, p = float(r.get("ttft_ms") or 0), int(r.get("new_tokens") or 0), int(r.get("prompt_tokens") or 0) + dec = t - ttft + d.update(ttft_ms=ttft, tokens_per_s=(n - 1) / (dec / 1000) if dec > 0 and n > 1 else None, + prefill_tokens_per_s=p / (ttft / 1000) if ttft > 0 else None, + e2e_tokens_per_s=n / (t / 1000) if t > 0 else None) + elif mt == "speech_to_text": + d.update(latency_ms=t, real_time_factor=t / 1000 / audio_s if audio_s else None) + elif mt == "kernel": + d["latency_ms"] = t + elif mt == "audio_generation": + n, first = int(r.get("frames") or 1), float(r.get("ttfa_ms") or 0) + per = (t - first) / (n - 1) if n > 1 else t + audio_ms = 1000 * audio_s / n if audio_s else None + d.update(time_to_first_audio_ms=first, latency_ms=t, ms_per_frame=per, + real_time_factor=per / audio_ms if audio_ms else None) + else: # text_to_speech + d.update(time_to_first_audio_ms=r.get("ttfa_ms"), latency_ms=t, + real_time_factor=t / 1000 / audio_s if audio_s else None) + return d + + +def pct(values: list[float], p: float) -> float: + v = sorted(values) + if len(v) == 1: + return v[0] + k = (len(v) - 1) * p / 100 + f = math.floor(k) + return v[f] + (v[min(f + 1, len(v) - 1)] - v[f]) * (k - f) + + +def stats(values) -> dict | None: + v = [float(x) for x in values if x is not None and math.isfinite(float(x))] + if not v: + return None + return {"median": statistics.median(v), "p10": pct(v, 10), "p90": pct(v, 90), "n": len(v)} + + +def fmt(x) -> str: + if x is None: + return "–" + a = abs(x) + return f"{x:.0f}" if a >= 1000 else f"{x:.1f}" if a >= 10 else f"{x:.3g}" + + +def wav_info(path: Path) -> tuple[int, int, int, int, bytes]: + """(sample rate, channels, bits, format, data) of a RIFF WAV (PCM or float).""" + b = path.read_bytes() + if b[:4] != b"RIFF" or b[8:12] != b"WAVE": + raise Fail(f"{path.name} is not a WAV file") + i, rate, ch, bits, fmt_tag, data = 12, 0, 0, 0, 0, b"" + while i + 8 <= len(b): + cid, size = b[i:i + 4], struct.unpack("= 26: # WAVE_FORMAT_EXTENSIBLE: the real format is in the GUID + fmt_tag = struct.unpack(" float: + rate, ch, bits, _, data = wav_info(path) + return len(data) / (ch * bits // 8) / rate + + +def wav_rms(path: Path) -> float: + rate, ch, bits, tag, data = wav_info(path) + if tag == 3 and bits == 32: + a = array("f") + elif bits == 16: + a = array("h") + else: + return float("nan") + a.frombytes(data[: len(data) // a.itemsize * a.itemsize]) + if sys.byteorder == "big": + a.byteswap() + scale = 1.0 if a.typecode == "f" else 32768.0 + return math.sqrt(sum((x / scale) ** 2 for x in a) / len(a)) if len(a) else 0.0 + + +# ---------------------------------------------------------------- speed + +def speed(sess: Session, plan: dict, args: argparse.Namespace) -> dict | None: + if not plan.get("settings") or not plan.get("inputs"): + print("nnopt did not measure the speed of this deliverable (see REPRO.md)") + return None + mt, st, inp = plan["model_type"], plan["settings"], plan["inputs"] + warmup = args.warmup if args.warmup is not None else int(st["warmup"]) + runs = args.runs if args.runs is not None else int(st["runs"]) + repeat = int(st["repeat"]) + batch = int(st.get("batch") or 1) + req: dict = {"mode": plan.get("mode", "generate")} + for k in ("max_new_tokens", "ignore_eos", "seed", "seconds"): + if st.get(k) is not None: + req[k] = st[k] + staged = {k: sess.stage(HERE / v) for k, v in inp.items() if isinstance(v, str)} + if "images" in inp: + req["images"] = [sess.stage(HERE / v) for v in inp["images"]] + req.update({k: v for k, v in staged.items()}) + audio_s = None + if mt == "speech_to_text": + audio_s = wav_seconds(HERE / inp["input"]) + elif mt == "audio_generation": + audio_s = float(st.get("seconds") or 10) + rest = float(st.get("rest_s") or 0) + print(f"{warmup} warm-up run{'s' * (warmup != 1)}, {runs} timed run{'s' * (runs != 1)} of {repeat} " + f"request{'s' * (repeat != 1)} each{settings_text(mt, st)}") + for i in range(warmup): + r = sess.run(req, repeat=1, timeout=args.timeout) + _ok(r, f"warm-up {i + 1}") + print(f" warm-up {i + 1}/{warmup}: {r['wall_ms'] / 1000:.1f} s" if r["wall_ms"] else f" warm-up {i + 1} done") + timed, pairs, peak = [], [], [] + for i in range(runs): + if rest: + time.sleep(rest) + r = sess.run(req, repeat=repeat, fetch_out=(i == 0), timeout=args.timeout) + _ok(r, f"timed run {i + 1}") + met = r["metrics"] or {} + if not isinstance(met.get("runs"), list) or len(met["runs"]) != repeat: + raise Fail(f"timed run {i + 1}: the metrics file needs {repeat} entries in \"runs\" (--repeat {repeat})") + if i == 0 and mt == "text_to_speech" and r["out"]: + audio_s = wav_seconds(r["out"]) + reqs = [derive(mt, x, audio_s, batch) for x in met["runs"]] + timed.append({"wall_ms": r["wall_ms"], "load_ms": met.get("load_ms"), "requests": reqs, + "self_peak_mem_mb": met.get("peak_mem_mb")}) + if r["peak_rss_mb"]: + peak.append(r["peak_rss_mb"]) + line = f" timed run {i + 1}/{runs}: {r['wall_ms'] / 1000:.1f} s" if r["wall_ms"] else f" timed run {i + 1}" + if plan.get("external_check", True): + p_req, p_rep = paired(mt, req, repeat, plan) + pr = sess.run(p_req, repeat=p_rep, timeout=args.timeout) + if pr["exit"] == 0 and pr["wall_ms"] and r["wall_ms"]: + pairs.append(r["wall_ms"] - pr["wall_ms"]) + print(line) + warm = [x for t in timed for x in (t["requests"][1:] if len(t["requests"]) > 1 else t["requests"])] + keys = sorted({k for x in warm for k, v in x.items() if v is not None}) + summary = {k: stats(x.get(k) for x in warm) for k in keys} + summary["load_ms"] = stats(t["load_ms"] for t in timed) + graded = {k: s["median"] for k, s in summary.items() if s} + if peak: + graded["peak_mem_mb"] = max(peak) + ext = external(mt, pairs, st, repeat, batch, audio_s, plan) + if ext: + graded.update(ext_cap(mt, graded, ext)) + return {"runs": timed, "summary": summary, "graded": graded, "external": ext} + + +def settings_text(mt: str, st: dict) -> str: + bits = [] + if mt in TOKEN_TYPES: + bits.append(f"{st['max_new_tokens']} new tokens per request" + (" (--ignore-eos)" if st.get("ignore_eos") else "")) + if st.get("prompt_tokens"): + bits.append(f"a ~{st['prompt_tokens']}-token prompt") + if mt == "vision_detection" and int(st.get("batch") or 1) > 1: + bits.append(f"{st['batch']} images per request") + if st.get("resolution"): + bits.append(f"{st['resolution']} input") + if mt == "audio_generation": + bits.append(f"{st.get('seconds')} s of audio per request") + return (": " + ", ".join(bits)) if bits else "" + + +def paired(mt: str, req: dict, repeat: int, plan: dict) -> tuple[dict, int]: + """The same request with the least work (one new token; one audio frame), or at --repeat 1: the difference in + wall time is the device-clock speed, which keeps the port's own timings honest.""" + if mt in TOKEN_TYPES: + return {**req, "max_new_tokens": 1}, repeat + if mt == "audio_generation" and plan.get("frame_seconds"): + return {**req, "seconds": plan["frame_seconds"]}, repeat + return req, 1 + + +def external(mt, pairs, st, repeat, batch, audio_s, plan) -> dict | None: + if not pairs: + return None + d = statistics.median(pairs) + if d <= 0: + return None + if mt in TOKEN_TYPES: + return {"tokens_per_s": (int(st["max_new_tokens"]) - 1) * repeat / (d / 1000)} + if mt == "audio_generation": + fs = plan.get("frame_seconds") + n = (max(1, round(float(st.get("seconds") or 10) / fs)) - 1) * repeat if fs else 0 + return {"ms_per_frame": d / n, "real_time_factor": d / n / (1000 * fs)} if n > 0 else None + if repeat < 2: + return None + per = d / (repeat - 1) + out = {"latency_ms": per} + if mt == "vision_detection": + out["fps"] = batch * 1000 / per + if audio_s: + out["real_time_factor"] = per / 1000 / audio_s + return out + + +def ext_cap(mt: str, g: dict, ext: dict, tol: float = 0.15) -> dict: + """nnopt's rule: a self-reported speed more than 15% better than the device-clock measurement is replaced by it.""" + out = {} + if mt in TOKEN_TYPES and ext.get("tokens_per_s") and g.get("tokens_per_s"): + if g["tokens_per_s"] > ext["tokens_per_s"] * (1 + tol): + out["tokens_per_s"] = ext["tokens_per_s"] + elif mt == "audio_generation" and ext.get("ms_per_frame") and g.get("ms_per_frame"): + if ext["ms_per_frame"] > g["ms_per_frame"] * (1 + tol): + out.update(ms_per_frame=ext["ms_per_frame"], real_time_factor=ext.get("real_time_factor")) + elif ext.get("latency_ms") and g.get("latency_ms"): + ratio = ext["latency_ms"] / g["latency_ms"] + if ratio > 1 + tol: + for k in ("latency_ms", "real_time_factor", "time_to_first_audio_ms", "per_image_ms"): + if g.get(k) is not None: + out[k] = g[k] * ratio + if g.get("fps"): + out["fps"] = g["fps"] / ratio + return out + + +def compare(plan: dict, mine: dict) -> tuple[list[list[str]], bool]: + rows, ok = [], True + for c in plan.get("compare") or []: + got, ref, tol = mine["graded"].get(c["key"]), c.get("nnopt"), float(c.get("tolerance_pct") or 10) + if got is None or not ref: + rows.append([c["label"], fmt(got), fmt(ref), "–", "not measured"]) + continue + diff = 100 * (got - ref) / ref + within = abs(diff) <= tol + ok &= within or c.get("informational", False) + rows.append([c["label"] + (f" ({c['unit']})" if c.get("unit") else ""), fmt(got), fmt(ref), f"{diff:+.1f}%", + ("yes" if within else "NO") + f" (±{tol:g}%)"]) + return rows, ok + + +def table(head: list[str], rows: list[list[str]]) -> str: + w = [max(len(str(r[i])) for r in [head] + rows) for i in range(len(head))] + line = lambda r: " ".join(str(x).ljust(w[i]) for i, x in enumerate(r)) # noqa: E731 + return "\n".join([line(head), line(["-" * n for n in w])] + [line(r) for r in rows]) + + +def sustained(sess: Session, plan: dict, seconds: float, args: argparse.Namespace) -> dict: + mt, st, inp = plan["model_type"], plan["settings"], plan["inputs"] + key = (plan.get("compare") or [{}])[0].get("key") + req = {"mode": plan.get("mode", "generate"), **{k: st[k] for k in ("max_new_tokens", "ignore_eos", "seed", "seconds") + if st.get(k) is not None}} + req.update({k: f"{sess.io}/{Path(v).name}" for k, v in inp.items() if isinstance(v, str)}) + if "images" in inp: + req["images"] = [f"{sess.io}/{Path(v).name}" for v in inp["images"]] + audio_s = wav_seconds(HERE / inp["input"]) if mt == "speech_to_text" else ( + float(st.get("seconds") or 10) if mt == "audio_generation" else None) + series, t0 = [], time.monotonic() + print(f"sustained run: {seconds:.0f} s back to back") + while time.monotonic() - t0 < seconds: + r = sess.run(req, repeat=int(st.get("sustained_repeat") or st["repeat"]), timeout=args.timeout) + _ok(r, "sustained run") + reqs = [derive(mt, x, audio_s, int(st.get("batch") or 1)) for x in (r["metrics"] or {}).get("runs") or []] + s = stats(x.get(key) for x in reqs[1:] or reqs) + if s: + series.append((time.monotonic() - t0, s["median"])) + print(f" {series[-1][0]:5.0f} s {fmt(s['median'])}") + if len(series) < 2: + return {"series": series} + first = statistics.median(v for t, v in series if t <= series[0][0] + 60) + last = statistics.median(v for t, v in series if t >= series[-1][0] - 60) + return {"series": series, "first_minute": first, "last_minute": last, "ratio": last / first if first else None} + + +# ---------------------------------------------------------------- outputs + +def words(text: str) -> list[str]: + return re.sub(r"[^\w\s']", " ", text.lower()).split() + + +def edits(a: list, b: list) -> int: + prev = list(range(len(b) + 1)) + for i, x in enumerate(a, 1): + cur = [i] + for j, y in enumerate(b, 1): + cur.append(min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + (x != y))) + prev = cur + return prev[-1] + + +def iou(a: list, b: list) -> float: + ix = max(0.0, min(a[2], b[2]) - max(a[0], b[0])) + iy = max(0.0, min(a[3], b[3]) - max(a[1], b[1])) + inter = ix * iy + union = (a[2] - a[0]) * (a[3] - a[1]) + (b[2] - b[0]) * (b[3] - b[1]) - inter + return inter / union if union > 0 else 0.0 + + +NPY = {"f4": ("f", 4), "f8": ("d", 8), "i1": ("b", 1), "u1": ("B", 1), "i2": ("h", 2), "u2": ("H", 2), + "i4": ("i", 4), "u4": ("I", 4), "i8": ("q", 8), "u8": ("Q", 8), "b1": ("B", 1)} + + +def read_npy(path: Path) -> tuple[str, list[float]]: + """A NumPy .npy file (format 1.0/2.0, C order) as (dtype, flat values), with the standard library only.""" + b = path.read_bytes() + if b[:6] != b"\x93NUMPY": + raise Fail(f"{path.name} is not a .npy file") + hl, off = (struct.unpack("|=") + if kind == "f2": + n = len(data) // 2 + return kind, list(struct.unpack(("<" if descr[0] != ">" else ">") + "e" * n, data[:2 * n])) + if kind not in NPY: + raise Fail(f"{path.name}: dtype {descr} is not supported here") + code, size = NPY[kind] + a = array(code) + if a.itemsize != size: + raise Fail(f"{path.name}: this Python has no {size}-byte {code} type") + a.frombytes(data[: len(data) // size * size]) + if (descr[0] == ">") != (sys.byteorder == "big") and size > 1: + a.byteswap() + return kind, list(a) + + +def check(sess: Session, plan: dict, args: argparse.Namespace) -> bool: + c = plan.get("check") or {} + cases, rules, mt = c.get("cases") or [], c.get("rules") or {}, plan["model_type"] + if not cases: + print("no public cases to check outputs against") + return True + print(f"{len(cases)} public case{'s' * (len(cases) != 1)}: {c.get('what', 'expected outputs')}") + ok, rows = True, [] + tot = {"edits": 0, "words": 0, "matched": 0, "ref": 0, "ours": 0, "prefix": [], "tok": 0} + for case in cases: + base = HERE / case["dir"] + req: dict = {"mode": "generate"} + for k in ("input", "image"): + if case.get(k): + req[k] = sess.stage(base / case[k]) + if mt == "vision_detection": + req["images"] = [req.pop("input")] + exp_path = base / case["expected"] if case.get("expected") else None + exp = json.loads(exp_path.read_text()) if exp_path and exp_path.suffix == ".json" else None + if mt in TOKEN_TYPES: + req["max_new_tokens"] = max(1, len(exp["tokens"])) + if mt in ("text_to_speech", "audio_generation"): + req["seed"] = case.get("seed", 0) + if mt == "audio_generation": + req["seconds"] = case.get("seconds", 10) + r = sess.run(req, repeat=1, fetch_out=True, timeout=args.timeout) + if r["exit"] != 0 or not r["out"]: + ok = False + rows.append([case["id"], "run failed", (r.get("log") or "")[-120:].replace("\n", " ")]) + continue + if mt in TOKEN_TYPES: + got = json.loads(Path(r["out"]).read_text()) + same_prompt = got.get("prompt_tokens") == exp["prompt_tokens"] + n = 0 + for a, b in zip(got.get("tokens") or [], exp["tokens"]): + if a != b: + break + n += 1 + frac = n / max(1, len(exp["tokens"])) + tot["prefix"].append(frac) + tot["tok"] += same_prompt + rows.append([case["id"], "prompt tokens " + ("match" if same_prompt else "DIFFER"), + f"{n}/{len(exp['tokens'])} new tokens identical before the first difference"]) + elif mt == "speech_to_text": + got = json.loads(Path(r["out"]).read_text()).get("text", "") + e = edits(words(got), words(exp["text"])) + tot["edits"] += e + tot["words"] += len(words(exp["text"])) + rows.append([case["id"], f"{e} word edit{'s' * (e != 1)}", got[:60]]) + elif mt == "text_to_speech": + mine, ref = wav_seconds(Path(r["out"])), float(case["expected_seconds"]) + within = abs(mine / ref - 1) <= float(rules.get("duration_ratio_tolerance", 0.05)) + ok &= within + rows.append([case["id"], f"{mine:.2f} s of audio (expected {ref:.2f} s)", "ok" if within else "DIFFERS"]) + elif mt == "vision_detection": + got = json.loads(Path(r["out"]).read_text()) + thr, margin, need = float(rules.get("score_threshold", 0.3)), float(rules.get("score_margin", 0.05)), float( + rules.get("iou_match", 0.5)) + ref = [(b, cl) for b, s, cl in zip(exp["boxes"], exp["scores"], exp["classes"]) if s >= thr] + ours = [(b, cl) for b, s, cl in zip(got.get("boxes", []), got.get("scores", []), got.get("classes", [])) + if s >= thr - margin] + used, m = set(), 0 + for b, cl in ref: + best = max(((iou(b, ob), j) for j, (ob, oc) in enumerate(ours) if oc == cl and j not in used), + default=(0.0, -1)) + if best[0] >= need: + used.add(best[1]) + m += 1 + tot["matched"] += m + tot["ref"] += len(ref) + tot["ours"] += len([1 for b, s in zip(got.get("boxes", []), got.get("scores", [])) if s >= thr]) + rows.append([case["id"], f"{m}/{len(ref)} expected objects found", f"{len(ours)} detected"]) + elif mt == "kernel": + bad, total, worst = 0, 0, 0.0 + for t in case["outputs"]: + pulled = Path(r["out"]) / f"{t['name']}.npy" + if not pulled.is_file(): + ok = False + rows.append([case["id"], f"no {t['name']}.npy written", ""]) + continue + kind, mine = read_npy(pulled) + _, ref = read_npy(base / t["expected"]) + if len(mine) != len(ref): + ok = False + rows.append([case["id"], f"{t['name']}: {len(mine)} values, expected {len(ref)}", ""]) + continue + if kind.startswith("f"): + rt, at = (float(rules.get("fp16_rtol", 1e-2)), float(rules.get("fp16_atol_scale", 1e-2))) \ + if kind == "f2" or t.get("dtype") == "float16" else \ + (float(rules.get("fp32_rtol", 1e-4)), float(rules.get("fp32_atol_scale", 1e-4))) + rms = math.sqrt(sum(x * x for x in ref) / len(ref)) if ref else 0.0 + for a, b in zip(mine, ref): + d = abs(a - b) + worst = max(worst, d) + bad += not (d <= at * rms + rt * abs(b)) + else: + lim = float(rules.get("int8_max_abs_diff", 1) if kind in ("i1", "u1") else rules.get("int_max_abs_diff", 0)) + for a, b in zip(mine, ref): + worst = max(worst, abs(a - b)) + bad += abs(a - b) > lim + total += len(ref) + frac = bad / total if total else 0.0 + within = frac <= float(rules.get("max_mismatch_frac", 0.0)) + ok &= within + rows.append([case["id"], f"{bad} of {total} values outside tolerance", f"largest difference {worst:.3g}"]) + else: # audio_generation: free-running audio is random; length and level are what can be checked + dur, rms = wav_seconds(Path(r["out"])), wav_rms(Path(r["out"])) + want = float(case.get("seconds", 10)) + within = abs(dur - want) <= 0.05 * want + 0.1 and (math.isnan(rms) or rms >= float(rules.get("free_run_min_rms", 0.001))) + ok &= within + rows.append([case["id"], f"{dur:.2f} s of audio, RMS {rms:.3g}", "ok" if within else "DIFFERS"]) + print(table(["case", "result", ""], rows)) + if mt in TOKEN_TYPES and tot["prefix"]: + mean, need = statistics.mean(tot["prefix"]), float(rules.get("greedy_prefix_min", 0.75)) + tok_ok = tot["tok"] == len(tot["prefix"]) + ok &= tok_ok and mean >= need + print(f"prompt tokens identical on {tot['tok']}/{len(tot['prefix'])} cases (needed: all); greedy prefix " + f"{mean:.2f} (needed: {need:g} or more)") + if mt == "speech_to_text" and tot["words"]: + wer, need = tot["edits"] / tot["words"], float(rules.get("wer_vs_reference_max", 0.02)) + ok &= wer <= need + print(f"word error rate against the expected transcripts {wer:.3f} (needed: {need:g} or less)") + if mt == "vision_detection" and tot["ref"]: + rec, prec = tot["matched"] / tot["ref"], tot["matched"] / max(1, tot["ours"]) + need_r, need_p = float(rules.get("recall_min", 0.97)), float(rules.get("precision_min", 0.97)) + ok &= rec >= need_r and prec >= need_p + print(f"recall {rec:.3f} (needed {need_r:g}), precision {prec:.3f} (needed {need_p:g})") + print("outputs: " + ("REPRODUCED" if ok else "NOT reproduced")) + return ok + + +def _ok(r: dict, what: str) -> None: + if r["exit"] != 0: + raise Fail(f"{what} failed (exit {r['exit']}): {(r.get('log') or '').strip()[-800:]}\ncommand: {r['command']}") + + +# ---------------------------------------------------------------- main + +def main(argv: list[str] | None = None) -> int: + ap = argparse.ArgumentParser(description="Reproduce nnopt's numbers on your own device (REPRO.md).") + ap.add_argument("--plan", default=str(HERE / "plan.json")) + ap.add_argument("--serial", help="the phone's serial (adb devices); default $ANDROID_SERIAL") + ap.add_argument("--ssh", help="USER@HOST of a Jetson or Mac; default $SSH_TARGET") + ap.add_argument("--local", action="store_true", help="the program runs on this machine") + ap.add_argument("--dir", help="where deploy.sh installed the program on the device") + ap.add_argument("--deploy", action="store_true", help="run bash deploy.sh DIR first") + ap.add_argument("--check", action="store_true", help="check the outputs on the public cases instead of the speed") + ap.add_argument("--warmup", type=int) + ap.add_argument("--runs", type=int) + ap.add_argument("--sustained", type=float, default=0.0, help="seconds of back-to-back runs after the timed runs") + ap.add_argument("--timeout", type=float, default=3600.0, help="seconds per run") + ap.add_argument("--json", help="also write the results to this file") + a = ap.parse_args(argv) + if not Path(a.plan).is_file(): # measured on several phones: each has its own plan (repro//plan.json) + mine = sorted(p.parent.name for p in HERE.glob("*/plan.json")) + print(f"error: no {a.plan}" + (f"; nnopt measured this on several phones: pass --plan repro//plan.json " + f"for yours, one of: {', '.join(mine)}" if mine else ""), file=sys.stderr) + return 2 + plan = json.loads(Path(a.plan).read_text()) + kind = "local" if a.local else "ssh" if a.ssh else "adb" if a.serial else plan.get("connection", "adb") + serial = a.serial or (os.environ.get("ANDROID_SERIAL") if kind == "adb" else None) + target = a.ssh or (os.environ.get("SSH_TARGET") if kind == "ssh" else None) + folder = a.dir or plan["device_dir"] + try: + dev = Device(kind, serial=serial, target=target) + if a.deploy: + print(f"deploy: bash deploy.sh {folder}") + env = {**os.environ, "NNOPT_PORT_DIR": folder, **({"ANDROID_SERIAL": serial} if serial else {})} + if subprocess.run(["bash", "deploy.sh", folder], cwd=ROOT, env=env).returncode != 0: + raise Fail("deploy.sh failed") + print(f"{plan.get('title', 'nnopt reproduction')} · {dev.describe()} · {folder}") + with tempfile.TemporaryDirectory(prefix="nnopt-repro-") as tmp: + sess = Session(dev, folder, plan["model_type"], Path(tmp)) + try: + if a.check: + ok = check(sess, plan, a) + result = {"check": ok} + elif (mine := speed(sess, plan, a)) is None: + ok, result = True, {"speed": None} + else: + rows, ok = compare(plan, mine) + print() + print(table(["metric", "yours", "nnopt", "diff", "within"], rows)) + if mine["graded"].get("peak_mem_mb"): + print(f"peak memory (process tree RSS): {fmt(mine['graded']['peak_mem_mb'])} MB") + result = {"speed": mine, "compared": rows, "within": ok} + if a.sustained > 0: + result["sustained"] = s = sustained(sess, plan, a.sustained, a) + if s.get("ratio"): + print(f"sustained: last minute / first minute = {s['ratio']:.2f}") + print("speed: " + ("REPRODUCED" if ok else "NOT reproduced (see REPRO.md, Expected results)")) + finally: + sess.close() + out = Path(a.json) if a.json else HERE / "results" / time.strftime("run-%Y%m%d-%H%M%S.json") + out.parent.mkdir(parents=True, exist_ok=True) + out.write_text(json.dumps(result, indent=1, default=str) + "\n") + print(f"results: {out}") + return 0 if ok else 1 + except Fail as e: + print(f"error: {e}", file=sys.stderr) + return 2 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/sm8850-npu-fp16/repro/inputs/input.wav b/sm8850-npu-fp16/repro/inputs/input.wav new file mode 100644 index 0000000000000000000000000000000000000000..6af9386ea4cc9608dfa2d245c015dac5711247ac --- /dev/null +++ b/sm8850-npu-fp16/repro/inputs/input.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a8c61ccb33e9da830cf8f90acd76e006e4edfc569a5f0f7bd2a560aca49209e4 +size 183070 diff --git a/sm8850-npu-fp16/repro/plan.json b/sm8850-npu-fp16/repro/plan.json new file mode 100644 index 0000000000000000000000000000000000000000..ad4b554cfe170313d4c34d3ec3bb240adb951cd7 --- /dev/null +++ b/sm8850-npu-fp16/repro/plan.json @@ -0,0 +1,136 @@ +{ + "format": "nnopt-repro", + "version": 1, + "title": "moonshine-ai/moonshine-streaming on Samsung Galaxy S26+", + "kind": "port", + "model_type": "speech_to_text", + "mode": "transcribe", + "connection": "adb", + "device_dir": "/data/local/tmp/nnopt/port", + "settings": { + "warmup": 2, + "runs": 5, + "repeat": 3, + "rest_s": 3.0, + "sustained_repeat": 10 + }, + "inputs": { + "input": "inputs/input.wav" + }, + "external_check": true, + "compare": [ + { + "key": "real_time_factor", + "label": "Real-time factor", + "unit": "x", + "nnopt": 0.0761763, + "p10": 0.0759334, + "p90": 0.0766807, + "tolerance_pct": 10 + }, + { + "key": "latency_ms", + "label": "Time per request", + "unit": "ms", + "nnopt": 435.695, + "p10": 434.306, + "p90": 438.58, + "tolerance_pct": 10 + }, + { + "key": "peak_mem_mb", + "label": "Peak memory", + "unit": "MB", + "nnopt": 622.8, + "tolerance_pct": 10, + "informational": true + } + ], + "check": { + "cases": [ + { + "id": "p000", + "dir": "expected/p000", + "input": "input.wav", + "expected": "expected.json" + }, + { + "id": "p001", + "dir": "expected/p001", + "input": "input.wav", + "expected": "expected.json" + }, + { + "id": "p002", + "dir": "expected/p002", + "input": "input.wav", + "expected": "expected.json" + }, + { + "id": "p003", + "dir": "expected/p003", + "input": "input.wav", + "expected": "expected.json" + }, + { + "id": "p004", + "dir": "expected/p004", + "input": "input.wav", + "expected": "expected.json" + }, + { + "id": "p005", + "dir": "expected/p005", + "input": "input.wav", + "expected": "expected.json" + }, + { + "id": "p006", + "dir": "expected/p006", + "input": "input.wav", + "expected": "expected.json" + }, + { + "id": "p007", + "dir": "expected/p007", + "input": "input.wav", + "expected": "expected.json" + }, + { + "id": "p008", + "dir": "expected/p008", + "input": "input.wav", + "expected": "expected.json" + }, + { + "id": "p009", + "dir": "expected/p009", + "input": "input.wav", + "expected": "expected.json" + }, + { + "id": "p010", + "dir": "expected/p010", + "input": "input.wav", + "expected": "expected.json" + }, + { + "id": "p011", + "dir": "expected/p011", + "input": "input.wav", + "expected": "expected.json" + }, + { + "id": "p012", + "dir": "expected/p012", + "input": "input.wav", + "expected": "expected.json" + } + ], + "rules": { + "wer_vs_reference_max": 0.02, + "wer_delta_vs_truth_max": 0.01 + }, + "what": "the reference outputs of your reference code" + } +} diff --git a/sm8850-npu-fp16/src/aot_compile.py b/sm8850-npu-fp16/src/aot_compile.py new file mode 100644 index 0000000000000000000000000000000000000000..41b2ec2644c218eee1708f5e922461a9872fb218 --- /dev/null +++ b/sm8850-npu-fp16/src/aot_compile.py @@ -0,0 +1,35 @@ +"""Ahead-of-time compile a .tflite for the Snapdragon 8 Elite Gen 5 NPU (SM8850, HTP v81) with ai-edge-litert's AOT +API and the Qualcomm plugin (ai-edge-litert-sdk-qualcomm 2.3.0 = QAIRT 2.50). Fails unless every op went to the NPU. + + python aot_compile.py MODEL.tflite OUT_DIR -> OUT_DIR/MODEL_Qualcomm_SM8850_apply_plugin.tflite +""" +import pathlib, sys + +from ai_edge_litert.aot import aot_compile as aot_lib +from ai_edge_litert.aot.vendors.qualcomm import target as qnn_target + + +def main(model, out_dir): + res = aot_lib.aot_compile(model, output_dir=out_dir, target=[qnn_target.Target(qnn_target.SocModel.SM8850)], + keep_going=False) + report = res.compilation_report() + print(report) + outs = sorted(pathlib.Path(out_dir).glob(pathlib.Path(model).stem + "_Qualcomm_SM8850*.tflite")) + if not outs: + sys.exit("aot_compile: no compiled model written") + # all-on-NPU: the compiled model holds only DISPATCH_OP custom ops (QNN context binaries) + from ai_edge_litert import schema_py_generated as S + m = S.Model.GetRootAs(outs[-1].read_bytes(), 0) + codes = [m.OperatorCodes(i) for i in range(m.OperatorCodesLength())] + names = [c.CustomCode().decode() if c.CustomCode() else f"builtin {max(c.BuiltinCode(), c.DeprecatedBuiltinCode())}" + for c in codes] + used = [names[g.Operators(j).OpcodeIndex()] for g in (m.Subgraphs(i) for i in range(m.SubgraphsLength())) + for j in range(g.OperatorsLength())] + cpu = [n for n in used if n != "DISPATCH_OP"] + if cpu: + sys.exit(f"aot_compile: ops left off the NPU in {outs[-1]}: {cpu}") + print(f"aot_compile: {outs[-1]}: all ops DISPATCH_OP") + + +if __name__ == "__main__": + main(sys.argv[1], sys.argv[2]) diff --git a/sm8850-npu-fp16/src/convert_ckpt.py b/sm8850-npu-fp16/src/convert_ckpt.py new file mode 100644 index 0000000000000000000000000000000000000000..ee3afce0d7cec391233e0faa7e3f78c02729d618 --- /dev/null +++ b/sm8850-npu-fp16/src/convert_ckpt.py @@ -0,0 +1,51 @@ +"""Map the customer's original-format Moonshine Streaming checkpoint (tensilier = medium) +to the key layout of transformers' MoonshineStreamingForConditionalGeneration. +Weight-norm parametrizations are folded exactly as torch does (g * v / ||v||, norm over dims 1,2).""" +import re, torch +from safetensors.torch import load_file + +def convert(path): + s = {k.removeprefix("_orig_mod."): v for k, v in load_file(path).items()} + out = {} + def put(k, v): out[k] = v.contiguous() + for k, v in s.items(): + m = None + if k == "decoder.rotary.inv_freq": continue # buffer, recomputed from rope config + if k.startswith("audio_preprocessor."): + r = k[len("audio_preprocessor."):] + if ".parametrizations.weight.original" in r: + if r.endswith("original0"): + conv = r.split(".")[0] + g = v; w = s[f"audio_preprocessor.{conv}.conv.parametrizations.weight.original1"] + put(f"model.encoder.embedder.{conv}.weight", torch._weight_norm(w, g, 0)) + continue + r = r.replace("conv1.conv.", "conv1.").replace("conv2.conv.", "conv2.").replace("lin.", "linear.") + put("model.encoder.embedder." + r, v); continue + if k.startswith("adapter."): + put({"adapter.pos_embed.weight": "model.decoder.pos_emb.weight", + "adapter.proj.weight": "model.decoder.proj.weight"}[k], v); continue + if k == "encoder.final_norm.gamma": put("model.encoder.final_norm.gamma", v); continue + if k == "decoder.final_norm.gamma": put("model.decoder.norm.weight", v + 1.0); continue + if k == "decoder.embedding.weight": + put("model.decoder.embed_tokens.weight", v); put("proj_out.weight", v.clone()); continue + if (m := re.match(r"encoder\.blocks\.(\d+)\.(.*)", k)): + i, r = m.groups() + r = (re.sub(r"^attn\.", "self_attn.", r).replace("out_proj", "o_proj") + .replace("ff.project_in.0", "mlp.fc1").replace("ff.project_out", "mlp.fc2") + .replace("norm1.", "input_layernorm.").replace("norm2.", "post_attention_layernorm.")) + put(f"model.encoder.layers.{i}.{r}", v); continue + if (m := re.match(r"decoder\.self_attn_blocks\.(\d+)\.(.*)", k)): + i, r = m.groups() + r = re.sub(r"^attn\.", "self_attn.", r).replace("out_proj", "o_proj") + if r == "norm1.gamma": r, v = "input_layernorm.weight", v + 1.0 + put(f"model.decoder.layers.{i}.{r}", v); continue + if (m := re.match(r"decoder\.cross_attn_blocks\.(\d+)\.(.*)", k)): + i, r = m.groups() + r = (re.sub(r"^attn\.", "encoder_attn.", r).replace("out_proj", "o_proj") + .replace("ff.project_in.proj", "mlp.fc1").replace("ff.project_out", "mlp.fc2")) + if r.endswith("gamma"): + # decoder norms: original gamma is an offset from 1; transformers stores 1 + gamma + r, v = {"norm_q.gamma": "post_attention_layernorm.weight", "norm2.gamma": "final_layernorm.weight"}[r], v + 1.0 + put(f"model.decoder.layers.{i}.{r}", v); continue + raise KeyError(k) + return out diff --git a/sm8850-npu-fp16/src/export_requirements.txt b/sm8850-npu-fp16/src/export_requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..770d11273c6774a633eb2edb49a038528404cf37 --- /dev/null +++ b/sm8850-npu-fp16/src/export_requirements.txt @@ -0,0 +1,10 @@ +# Export + AOT toolchain the shipped models were made with (x86-64 Linux, Python 3.12). +# Top-level pins; transitive dependencies resolve normally. +--extra-index-url https://download.pytorch.org/whl/cpu +torch==2.14.1 +litert-torch==0.10.0 +ai-edge-litert==2.3.0 +ai-edge-quantizer==0.10.0 +ai-edge-litert-sdk-qualcomm==2.3.0 +tensorflow-cpu==2.21.0 +safetensors==0.8.0 diff --git a/sm8850-npu-fp16/src/export_tflite.py b/sm8850-npu-fp16/src/export_tflite.py new file mode 100644 index 0000000000000000000000000000000000000000..8b4caad19a48a6a17b3b32048f64b7bcc166c141 --- /dev/null +++ b/sm8850-npu-fp16/src/export_tflite.py @@ -0,0 +1,101 @@ +"""Export the Moonshine Streaming medium graphs to .tflite (litert-torch 0.10.0) and check each one on the CPU +(ai-edge-litert interpreter) against the torch module on real captured inputs. + + python export_tflite.py CKPT OUTDIR --graph enc16 | dec512 | dec1536 | dec4096 [--half-cache] [--cases DIR] + +Run on an x86-64 Linux machine with >= 32 GB RAM (the conversion VM: n2-highmem-16); see README.md. +""" +import argparse, os, sys, time +import numpy as np +import torch + +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import moonshine_npu as M + +DEC = {"dec512": (512, 80), "dec1536": (1536, 224), "dec4096": (4096, 544)} + + +def enc_args(C, case=None): + if case is not None: + z = np.load(case) + return tuple(torch.from_numpy(z[k]) for k in ["audio", "c1s", "c2s", "kst", "vst", "xst", "kmask", "pos"]) + return (torch.zeros(1, C * M.SAMPLES_PER_ENC), torch.zeros(4, M.ENC_D), torch.zeros(4, 2 * M.ENC_D), + torch.zeros(M.NL_ENC, M.SMAX, 640), torch.zeros(M.NL_ENC, M.SMAX, 640), + torch.zeros(len(M.LA_LAYERS), 3, M.ENC_D), torch.zeros(M.NL_ENC, M.SMAX + C), + torch.zeros(C, dtype=torch.int32)) + + +def dec_args(T, L, half, case=None): + dt = torch.float16 if half else torch.float32 + if case is not None: + z = np.load(case) + Tc, Lc = z["ck"].shape[-1], z["sk"].shape[-1] + def fit(a, axis, n, fill=0.0): + pad = [(0, 0)] * a.ndim; pad[axis] = (0, n - a.shape[axis]) + return np.pad(a, pad, constant_values=fill) + return (torch.from_numpy(z["tok"]), torch.from_numpy(z["pos"]), + torch.from_numpy(fit(z["smask"], 1, L, M.NEG)), torch.from_numpy(fit(z["cmask"], 1, T, M.NEG)), + torch.from_numpy(fit(z["sk"], 3, L)).to(dt), torch.from_numpy(fit(z["sv"], 2, L)).to(dt), + torch.from_numpy(fit(z["ck"], 3, T)).to(dt), torch.from_numpy(fit(z["cv"], 2, T)).to(dt)) + return (torch.zeros(1, dtype=torch.int32), torch.zeros(1, dtype=torch.int32), torch.zeros(1, L), + torch.zeros(1, T), torch.zeros(M.NL_DEC, M.ENC_H, M.HD, L, dtype=dt), + torch.zeros(M.NL_DEC, M.ENC_H, L, M.HD, dtype=dt), torch.zeros(M.NL_DEC, M.ENC_H, M.HD, T, dtype=dt), + torch.zeros(M.NL_DEC, M.ENC_H, T, M.HD, dtype=dt)) + + +def check(path, mod, args): + from ai_edge_litert.interpreter import Interpreter + it = Interpreter(model_path=path) + run = it.get_signature_runner() + names = sorted(it.get_signature_list()["serving_default"]["inputs"], key=lambda s: int(s.split("_")[-1])) + feed = {n: a.numpy() for n, a in zip(names, args)} + t = time.time() + out = run(**feed) + dt = time.time() - t + with torch.no_grad(): + ref = mod(*args) + onames = sorted(out.keys(), key=lambda s: int(s.split("_")[-1])) + for n, r in zip(onames, ref): + o, r = out[n].astype(np.float64).ravel(), r.double().numpy().ravel() + cos = float(o @ r / (np.linalg.norm(o) * np.linalg.norm(r) + 1e-30)) + snr = 10 * np.log10((r @ r + 1e-30) / (((o - r) ** 2).sum() + 1e-30)) + print(f" check {os.path.basename(path)} {n} shape={out[n].shape} cos={cos:.7f} snr={snr:.1f}dB " + f"maxabs={np.abs(o - r).max():.3e}", flush=True) + print(f" cpu run {dt * 1000:.0f} ms", flush=True) + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("ckpt"); ap.add_argument("outdir") + ap.add_argument("--graph", required=True) + ap.add_argument("--half-cache", action="store_true") + ap.add_argument("--cases") + a = ap.parse_args() + import litert_torch + torch.set_grad_enabled(False) + os.makedirs(a.outdir, exist_ok=True) + sd = M.load_sd(a.ckpt) + t0 = time.time() + if a.graph.startswith("enc"): + C = int(a.graph[3:]) + mod = M.EncoderChunk(sd, C).eval() + args = enc_args(C) + case = os.path.join(a.cases, f"enc{C}.npz") if a.cases else None + cargs = enc_args(C, case) if case and os.path.exists(case) else args + name = f"enc{C}" + else: + T, L = DEC[a.graph] + mod = M.DecoderStep(sd, T, L, half_cache=a.half_cache).eval() + args = dec_args(T, L, a.half_cache) + case = os.path.join(a.cases, "dec.npz") if a.cases else None + cargs = dec_args(T, L, a.half_cache, case) if case and os.path.exists(case) else args + name = a.graph + ("h" if a.half_cache else "") + del sd + path = os.path.join(a.outdir, name + ".tflite") + litert_torch.convert(mod, args).export(path) + print(f"exported {path} {os.path.getsize(path) / 1e6:.1f} MB in {time.time() - t0:.0f} s", flush=True) + check(path, mod, cargs) + + +if __name__ == "__main__": + main() diff --git a/sm8850-npu-fp16/src/host_stream.py b/sm8850-npu-fp16/src/host_stream.py new file mode 100644 index 0000000000000000000000000000000000000000..3b43d2fbde2d19dfdad9fc023c0f5c58e41f304c --- /dev/null +++ b/sm8850-npu-fp16/src/host_stream.py @@ -0,0 +1,133 @@ +"""Host (fp32 torch) model of the on-device streaming loop: the same chunking, state, masks, buckets and greedy +decode as runner.c, used to check the graphs against the reference before export and to make calibration data. + + python host_stream.py CKPT WAV [--chunk 16] [--check-hf HF_CONFIG_DIR] +""" +import argparse, json, math, os, sys, wave +import numpy as np +import torch + +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import moonshine_npu as M + +BUCKETS = [(512, 80), (1536, 224), (4096, 544)] # (T encoder frames, L decoder positions) + + +def read_wav(path): + w = wave.open(path) + assert w.getframerate() == 16000 and w.getsampwidth() == 2, "16 kHz 16-bit PCM expected" + a = np.frombuffer(w.readframes(w.getnframes()), dtype="= 0) & (f < T)] = 0.0 + out0 = k * C - M.TOTAL_LAG + pos = np.clip(out0 + np.arange(C), 0, 4095).astype(np.int32) + r = self.enc(torch.from_numpy(chunk)[None], st["c1s"], st["c2s"], st["kst"], st["vst"], st["xst"], + torch.from_numpy(km), torch.from_numpy(pos)) + st = dict(c1s=r[0], c2s=r[1], kst=r[2], vst=r[3], xst=r[4]) + for i in range(C): + f = out0 + i + if 0 <= f < T: + ck[:, f], cv[:, f], enc_out[f] = r[5][:, i], r[6][:, i], r[7][i] + if on_chunk: + on_chunk(k, (chunk, km, pos), r) + return ck, cv, enc_out + + +def greedy(decs, ck, cv, avail, max_length): + Tb, Lb = next(b for b in BUCKETS if b[0] >= avail) + dec = decs[(Tb, Lb)] + assert max_length - 1 <= Lb, "too many tokens for the bucket" + H = M.ENC_H + ckb = torch.zeros(M.NL_DEC, H, M.HD, Tb) + cvb = torch.zeros(M.NL_DEC, H, Tb, M.HD) + ckb[:, :, :, :avail] = ck[:, :avail].reshape(M.NL_DEC, avail, H, M.HD).permute(0, 2, 3, 1) + cvb[:, :, :avail] = cv[:, :avail].reshape(M.NL_DEC, avail, H, M.HD).permute(0, 2, 1, 3) + cm = torch.full((1, Tb), M.NEG); cm[0, :avail] = 0 + sk = torch.zeros(M.NL_DEC, H, M.HD, Lb); sv = torch.zeros(M.NL_DEC, H, Lb, M.HD) + toks = [1] + for i in range(max_length - 1): + sm = torch.full((1, Lb), M.NEG); sm[0, :i] = 0 + logits, kn, vn = dec(torch.tensor([toks[-1]], dtype=torch.int32), torch.tensor([i], dtype=torch.int32), + sm, cm, sk, sv, ckb, cvb) + sk[:, :, :, i] = kn; sv[:, :, i, :] = vn + t = int(torch.argmax(logits[0])) + toks.append(t) + if t == 2: + break + return toks + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("ckpt"); ap.add_argument("wav", nargs="+") + ap.add_argument("--chunk", type=int, default=16) + ap.add_argument("--check-hf") + ap.add_argument("--tokenizer") + a = ap.parse_args() + torch.set_grad_enabled(False) + sd = M.load_sd(a.ckpt) + enc = M.EncoderChunk(sd, a.chunk).eval() + decs = {b: M.DecoderStep(sd, *b).eval() for b in BUCKETS} + tok = None + if a.tokenizer: + from tokenizers import Tokenizer + tok = Tokenizer.from_file(a.tokenizer) + for wav in a.wav: + audio = read_wav(wav) + n = len(audio) + n0 = n // M.FRAME + audio = audio.copy(); audio[n0 * M.FRAME:] = 0.0 # partial last frame is masked to zero in the reference + T = enc_lengths(n) + ck, cv, enc_out = Stream(enc, a.chunk).run_encoder(audio, T) + if a.check_hf: + from transformers import MoonshineStreamingConfig, MoonshineStreamingForConditionalGeneration + cfg = MoonshineStreamingConfig.from_pretrained(a.check_hf) + hf = MoonshineStreamingForConditionalGeneration(cfg); hf.load_state_dict(sd, strict=True); hf.eval() + x = torch.from_numpy(read_wav(wav))[None] + pad = (-x.shape[1]) % 80 + am = torch.cat([torch.ones_like(x), torch.zeros(1, pad)], 1).long() + x = torch.cat([x, torch.zeros(1, pad)], 1) + ref = hf.model.encoder(x, attention_mask=am).last_hidden_state[0] + d = (ref - enc_out) + print(f"encoder vs HF: T={T} ref={tuple(ref.shape)} maxabs={d.abs().max():.3e} " + f"cos={torch.nn.functional.cosine_similarity(ref.flatten(), enc_out.flatten(), 0):.7f}") + ml = int(n * 6.5 / 16000) + toks = greedy(decs, ck, cv, T, ml) + text = tok.decode(toks, skip_special_tokens=True) if tok else "" + print(os.path.basename(wav), T, len(toks) - 1, json.dumps(text)) + + +if __name__ == "__main__": + main() diff --git a/sm8850-npu-fp16/src/make_cases.py b/sm8850-npu-fp16/src/make_cases.py new file mode 100644 index 0000000000000000000000000000000000000000..b1be5352353735016618ce5429393108d9f5b667 --- /dev/null +++ b/sm8850-npu-fp16/src/make_cases.py @@ -0,0 +1,39 @@ +"""Capture real inputs of the encoder chunk graph and the decoder step graph (p002) for export checks.""" +import sys, os, numpy as np, torch +sys.path.insert(0, sys.argv[3]) +import moonshine_npu as M, host_stream as H +torch.set_grad_enabled(False) +sd = M.load_sd(sys.argv[1]); out = sys.argv[2] +C = 16 +enc = M.EncoderChunk(sd, C).eval() +audio = H.read_wav(sys.argv[4]); n = len(audio); audio[(n // 80) * 80:] = 0 +T = H.enc_lengths(n) +saved = {} +def hook(k, inp, r): + if k == 10: saved["x"] = inp +st = H.Stream(enc, C) +# capture states going into chunk 10: rerun with hook that grabs state before +states = [] +orig = enc.forward +def fwd(*a): + states.append([t.clone() for t in a]); return orig(*a) +enc.forward = fwd +ck, cv, eo = st.run_encoder(audio, T) +a = states[10] +np.savez(os.path.join(out, "enc16.npz"), audio=a[0].numpy(), c1s=a[1].numpy(), c2s=a[2].numpy(), kst=a[3].numpy(), + vst=a[4].numpy(), xst=a[5].numpy(), kmask=a[6].numpy(), pos=a[7].numpy()) +# decoder: teacher-forced to step 6 with fp32 module at T exactly (padded later) +dec = M.DecoderStep(sd, T, 32).eval() +H.BUCKETS[:] = [(T, 32)] +toks = H.greedy({(T, 32): dec}, ck, cv, T, 8) +H_ = M.ENC_H +ckb = ck.reshape(14, T, H_, 64).permute(0, 2, 3, 1).contiguous(); cvb = cv.reshape(14, T, H_, 64).permute(0, 2, 1, 3).contiguous() +sk = torch.zeros(14, H_, 64, 32); sv = torch.zeros(14, H_, 32, 64) +for i in range(6): + sm = torch.full((1, 32), M.NEG); sm[0, :i] = 0 + lg, kn, vn = dec(torch.tensor([toks[i]], dtype=torch.int32), torch.tensor([i], dtype=torch.int32), sm, torch.zeros(1, T), sk, sv, ckb, cvb) + sk[:, :, :, i] = kn; sv[:, :, i] = vn +i = 6; sm = np.full((1, 32), M.NEG, np.float32); sm[0, :i] = 0 +np.savez(os.path.join(out, "dec.npz"), tok=np.array([toks[i]], np.int32), pos=np.array([i], np.int32), smask=sm, + cmask=np.zeros((1, T), np.float32), sk=sk.numpy(), sv=sv.numpy(), ck=ckb.numpy(), cv=cvb.numpy()) +print("toks", toks) diff --git a/sm8850-npu-fp16/src/make_vocab.py b/sm8850-npu-fp16/src/make_vocab.py new file mode 100644 index 0000000000000000000000000000000000000000..2a2735162989c9eea48feb3e5e57d762095eefa0 --- /dev/null +++ b/sm8850-npu-fp16/src/make_vocab.py @@ -0,0 +1,34 @@ +"""tokenizer.json (moonshine-ai/moonshine-streaming-medium) -> vocab.bin for runner.c's detokenizer. + + python make_vocab.py tokenizer.json vocab.bin + +vocab.bin: "MSVOCAB1", uint32 n, then per id: uint8 flags (1 = special: skipped like skip_special_tokens=True), +uint16 length, the token's bytes after the tokenizer's decoder steps that act per token (Replace U+2581 -> ' ', +ByteFallback <0xNN> -> byte). The runner joins them (Fuse) and strips one leading space (Strip start=1). +""" +import json, re, struct, sys + + +def main(src, dst, n=32768): + t = json.load(open(src, encoding="utf-8")) + dec = [d["type"] for d in t["decoder"]["decoders"]] + assert dec == ["Replace", "ByteFallback", "Fuse", "Strip"], dec + vocab = {i: s for s, i in t["model"]["vocab"].items()} + special = set() + for a in t["added_tokens"]: + vocab[a["id"]] = a["content"] + if a["special"]: + special.add(a["id"]) + out = [b"MSVOCAB1", struct.pack("", s) + b = bytes([int(m.group(1), 16)]) if m and i not in special else s.replace("▁", " ").encode("utf-8") + out.append(struct.pack(" C encoder frames (50 Hz), streaming with exact per-layer state, + plus the decoder's cross-attention K/V of those frames (adapter pos_emb + proj + k/v proj). + DecoderStep one token -> logits, self-attention KV cache and cross K/V as inputs (static T, L). + +Reference: transformers 5.22.1 models/moonshine_streaming/modeling_moonshine_streaming.py (quoted per block), +weights loaded from the customer's tensilier checkpoint with convert_ckpt.py (the reference runner's convert.py). + +Streaming encoder, exactness: layer l attends keys at distance 0..15 to the left and 0..r_l to the right +(sliding_windows (16, 4) -> r=3, (16, 0) -> r=0). With chunks of C frames, layer l's outputs lag its inputs by +r_l; it keeps the K/V of its last 15 + r_l input frames and the residual of its last r_l input frames as state. +The frontend's causal convs keep their last 4 input frames. Every encoder frame is therefore computed from +exactly the same inputs as in the full-utterance reference (keys before frame 0 or at/after the last frame are +masked by the runner through kmask). +""" +import math +import torch +import torch.nn as nn +import torch.nn.functional as F + +ENC_D, ENC_H, HD = 768, 10, 64 +DEC_D, DEC_FF = 640, 2560 +NL_ENC, NL_DEC = 14, 14 +VOCAB = 32768 +FRAME = 80 # samples per 5 ms frame +SAMPLES_PER_ENC = 320 # 4 frames -> one 50 Hz encoder frame +LOOKAHEAD = [3, 3] + [0] * 10 + [3, 3] # sliding_windows (16,4)*2, (16,0)*10, (16,4)*2: right keys q+1..q+3 +LEFT = 15 # left window 16: keys q-15..q +SMAX = LEFT + 3 # K/V state rows per layer (layers with r=0 use the last 15) +TOTAL_LAG = sum(LOOKAHEAD) # 12 frames +LA_LAYERS = [i for i, r in enumerate(LOOKAHEAD) if r > 0] +ROT = 32 # partial_rotary_factor 0.5 of head_dim 64 +NEG = -1.0e4 +RES_S = 64.0 + + +def layer_norm(x, gamma, eps=1e-5, mmin=1e-3): + """LayerNorm without bias, prescaled by the row max-abs so that fp16 never flushes the variance: + (x-mu)/sqrt(var+eps) == (xs-mus)/sqrt(var_s + eps/m^2) with xs = x/m (exact).""" + m = x.abs().amax(dim=-1, keepdim=True).clamp(min=mmin) + xs = x / m + d = xs - xs.mean(dim=-1, keepdim=True) + var = (d * d).mean(dim=-1, keepdim=True) + e = (eps ** 0.5) / m # eps/m^2 as (sqrt(eps)/m)^2: m*m and eps underflow fp16 for small m + return d * torch.rsqrt(var + e * e) * gamma + + +def asinh_fp16_safe(y): + # asinh(y) = sign(y) log(|y| + sqrt(y^2+1)); series for |y| < 0.5, where log(1+small) loses fp16 precision. + a = y.abs() + big = torch.log(a + torch.sqrt(a * a + 1.0)) + y2 = y * y + small = a * (1.0 + y2 * (-1.0 / 6.0 + y2 * (3.0 / 40.0 + y2 * (-15.0 / 336.0 + y2 * (105.0 / 3456.0))))) + r = torch.where(a < 0.5, small, big) + return torch.where(y < 0, -r, r) + + +class EncoderChunk(nn.Module): + def __init__(self, sd, C): + super().__init__() + self.C = C + g = lambda k: sd[k].float().clone() + p = "model.encoder." + self.k_comp = float(torch.exp(sd[p + "embedder.comp.log_k"].float())) + # The residual stream runs in units of 1/RES_S (exact, a power of 2): conv2, o_proj and fc2 are divided by it + # and the norms use eps/RES_S^2. In fp32 the first frames' residuals reach 3.5e4 in the lookahead layers, + # which broke the whole HTP graph (even outputs that do not depend on them); /64 keeps them near 550. + s = RES_S + self.lin = nn.Parameter(g(p + "embedder.linear.weight")) # [768, 80] + self.c1w = nn.Parameter(g(p + "embedder.conv1.weight")) # [1536, 768, 5] + self.c1b = nn.Parameter(g(p + "embedder.conv1.bias")) + self.c2w = nn.Parameter(g(p + "embedder.conv2.weight") / s) # [768, 1536, 5] + self.c2b = nn.Parameter(g(p + "embedder.conv2.bias") / s) + L = [] + for i in range(NL_ENC): + q = f"{p}layers.{i}." + L.append(nn.ParameterDict(dict( + ln1=nn.Parameter(g(q + "input_layernorm.gamma") + 1.0), # unit_offset gamma + ln2=nn.Parameter(g(q + "post_attention_layernorm.gamma") + 1.0), + wq=nn.Parameter(g(q + "self_attn.q_proj.weight")), + wk=nn.Parameter(g(q + "self_attn.k_proj.weight")), + wv=nn.Parameter(g(q + "self_attn.v_proj.weight")), + wo=nn.Parameter(g(q + "self_attn.o_proj.weight") / s), + f1w=nn.Parameter(g(q + "mlp.fc1.weight")), f1b=nn.Parameter(g(q + "mlp.fc1.bias")), + f2w=nn.Parameter(g(q + "mlp.fc2.weight") / s), f2b=nn.Parameter(g(q + "mlp.fc2.bias") / s)))) + self.layers = nn.ModuleList(L) + self.fn = nn.Parameter(g(p + "final_norm.gamma") + 1.0) + d = "model.decoder." + self.pos = nn.Parameter(g(d + "pos_emb.weight")) # [4096, 768] + self.proj = nn.Parameter(g(d + "proj.weight")) # [640, 768] + self.ck = nn.Parameter(torch.stack([g(f"{d}layers.{i}.encoder_attn.k_proj.weight") for i in range(NL_DEC)])) + self.cv = nn.Parameter(torch.stack([g(f"{d}layers.{i}.encoder_attn.v_proj.weight") for i in range(NL_DEC)])) + # band masks: query i (frame a+i) vs key j (frame a-15+j); allowed i <= j <= i+15+r + bands = [] + for r in LOOKAHEAD: + S = LEFT + r + i = torch.arange(C)[:, None] + j = torch.arange(S + C)[None, :] + ok = (j >= i) & (j <= i + LEFT + r) + bands.append(torch.where(ok, 0.0, NEG)) + for k, b in enumerate(bands): + self.register_buffer(f"band{k}", b, persistent=False) + + def forward(self, audio, c1s, c2s, kst, vst, xst, kmask, pos): + """audio [1, 320C]; c1s [4, 768] and c2s [4, 1536] conv input history; kst/vst [14, 18, 640] encoder K/V + state; xst [4, 3, 768] residual state of the lookahead layers; kmask [14, 18+C] additive key validity; + pos [C] int32 absolute encoder frame positions of the output frames (for adapter pos_emb).""" + C = self.C + # modeling_moonshine_streaming.py:297-300 + # hidden_states = self.cmvn(input_values.reshape(input_values.shape[0], -1, self.frame_len)) + # hidden_states = self.comp(hidden_states) + # hidden_states = nn.functional.silu(self.linear(hidden_states)) + x = audio.reshape(4 * C, FRAME) + c = x - x.mean(dim=-1, keepdim=True) + m = c.abs().amax(dim=-1, keepdim=True).clamp(min=1e-3) # CMVN prescaled (exact, fp16-safe) + cs = c / m + e = 1e-3 / m # 1e-6/m^2 as (1e-3/m)^2: fp16-safe + x = cs * torch.rsqrt((cs * cs).mean(dim=-1, keepdim=True) + e * e) + x = asinh_fp16_safe(self.k_comp * x) + x = F.silu(x @ self.lin.t()) # [4C, 768] + # causal conv1 (k5, s2) and conv2 (k5, s2), lines 104-117: left pad (k-1) == state of 4 frames + h = torch.cat([c1s, x], 0) # [4C+4, 768] + new_c1s = h[-4:] + h = F.conv1d(h.t().unsqueeze(0), self.c1w, self.c1b, stride=2) # [1, 1536, 2C] + h = F.silu(h)[0].t() # [2C, 1536] + h = torch.cat([c2s, h], 0) + new_c2s = h[-4:] + h = F.conv1d(h.t().unsqueeze(0), self.c2w, self.c2b, stride=2)[0].t() # [C, 768] + new_k, new_v, new_x = [], [], [] + lnr = lambda t, gm: layer_norm(t, gm, eps=1e-5 / (RES_S * RES_S), mmin=1e-3 / RES_S) + scale = HD ** -0.5 + li = 0 + for l, L in enumerate(self.layers): + r = LOOKAHEAD[l] + S = LEFT + r + # rows of h are frames kC - D[l] + i; frames outside [0, T) never reach a valid output (kmask hides them as + # keys), but their residual grows to ~3.5e4 with all keys masked and saturates fp16 on the HTP (garbage + # leaked into the first valid frames). Zero them: rowmask = 1 + kmask/1e4 is exactly 1 or 0. + h = h * (1.0 + kmask[l, SMAX:] * (-1.0 / NEG))[:, None] + # MoonshineStreamingEncoderLayer.forward, lines 261-280 (pre-norm attention, pre-norm GELU MLP) + hn = lnr(h, L["ln1"]) + k_new = hn @ L["wk"].t() # [C, 640] + v_new = hn @ L["wv"].t() + ks = torch.cat([kst[l, SMAX - S:], k_new], 0) # [S+C, 640] + vs = torch.cat([vst[l, SMAX - S:], v_new], 0) + new_k.append(torch.cat([kst[l], k_new], 0)[-SMAX:]) + new_v.append(torch.cat([vst[l], v_new], 0)[-SMAX:]) + if r > 0: # queries are the frames r back: residual from state + first C-r new rows + xin = torch.cat([xst[li], h], 0) # [r+C, 768] + new_x.append(xin[-r:]) + qsrc = torch.cat([lnr(xst[li], L["ln1"]), hn], 0)[:C] + resid = xin[:C] + li += 1 + else: + qsrc, resid = hn, h + q = (qsrc @ L["wq"].t()).reshape(C, ENC_H, HD).transpose(0, 1) # [10, C, 64] + kh = ks.reshape(S + C, ENC_H, HD).permute(1, 2, 0) # [10, 64, S+C] + vh = vs.reshape(S + C, ENC_H, HD).transpose(0, 1) # [10, S+C, 64] + sc = (q @ kh) * scale + getattr(self, f"band{l}") + kmask[l, SMAX - S:] + pr = torch.softmax(sc, dim=-1) + a = (pr @ vh).transpose(0, 1).reshape(C, ENC_H * HD) + h = resid + a @ L["wo"].t() + hn2 = lnr(h, L["ln2"]) + h = h + (F.gelu(hn2 @ L["f1w"].t() + L["f1b"]) @ L["f2w"].t() + L["f2b"]) + enc = lnr(h, self.fn) # final_norm, line 429 + # decoder adapter, lines 813-817: encoder_hidden_states += pos_emb(arange(T)); proj + e = (enc + self.pos[pos]) @ self.proj.t() # [C, 640] + ck = torch.einsum("cd,lod->lco", e, self.ck) # [14, C, 640] + cv = torch.einsum("cd,lod->lco", e, self.cv) + return (new_c1s, new_c2s, torch.stack(new_k), torch.stack(new_v), torch.stack(new_x), ck, cv, enc) + + +def rope_perm(): + """Head-dim permutation applied to q_proj and k_proj rows: the interleaved rotary pairs (0,1),(2,3).. of the + first 32 dims become (0,16),(1,17).. so the graph uses the half-split rotate; q.k is unchanged.""" + perm = list(range(0, ROT, 2)) + list(range(1, ROT, 2)) + list(range(ROT, HD)) + return torch.tensor(perm) + + +def rope_tables(L, theta=10000.0): + inv = 1.0 / (theta ** (torch.arange(0, ROT, 2, dtype=torch.float) / ROT)) # [16] + f = torch.arange(L, dtype=torch.float)[:, None] * inv[None] # [L, 16] + return torch.cat([f.cos(), f.cos()], -1), torch.cat([f.sin(), f.sin()], -1) # [L, 32] + + +class DecoderStep(nn.Module): + def __init__(self, sd, T, L, half_cache=False): + super().__init__() + self.T, self.L, self.half_cache = T, L, half_cache + g = lambda k: sd[k].float().clone() + d = "model.decoder." + perm = rope_perm() + hperm = torch.cat([h * HD + perm for h in range(ENC_H)]) + self.emb = nn.Parameter(g(d + "embed_tokens.weight")) # [32768, 640], tied proj_out + Ls = [] + for i in range(NL_DEC): + q = f"{d}layers.{i}." + Ls.append(nn.ParameterDict(dict( + ln1=nn.Parameter(g(q + "input_layernorm.weight")), + ln2=nn.Parameter(g(q + "post_attention_layernorm.weight")), + ln3=nn.Parameter(g(q + "final_layernorm.weight")), + wq=nn.Parameter(g(q + "self_attn.q_proj.weight")[hperm]), + wk=nn.Parameter(g(q + "self_attn.k_proj.weight")[hperm]), + wv=nn.Parameter(g(q + "self_attn.v_proj.weight")), + wo=nn.Parameter(g(q + "self_attn.o_proj.weight")), + cq=nn.Parameter(g(q + "encoder_attn.q_proj.weight")), + co=nn.Parameter(g(q + "encoder_attn.o_proj.weight")), + f1w=nn.Parameter(g(q + "mlp.fc1.weight")), f1b=nn.Parameter(g(q + "mlp.fc1.bias")), + f2w=nn.Parameter(g(q + "mlp.fc2.weight")), f2b=nn.Parameter(g(q + "mlp.fc2.bias"))))) + self.layers = nn.ModuleList(Ls) + self.norm = nn.Parameter(g(d + "norm.weight")) + cos, sin = rope_tables(L) + self.register_buffer("cos_t", cos, persistent=False) + self.register_buffer("sin_t", sin, persistent=False) + + def forward(self, tok, pos, smask, cmask, sk, sv, ck, cv): + """tok [1] int32; pos [1] int32; smask [1, L], cmask [1, T] additive; sk [14,10,64,L] (K transposed, + rope dims permuted), sv [14,10,L,64]; ck [14,10,64,T], cv [14,10,T,64]. + Returns logits [1, 32768], k_new [14, 10, 64], v_new [14, 10, 64] (written at slot pos by the runner).""" + if self.half_cache: + sk, sv, ck, cv = sk.float(), sv.float(), ck.float(), cv.float() + x = self.emb[tok] # [1, 640] + cos = self.cos_t[pos] # [1, 32] + sin = self.sin_t[pos] + scale = HD ** -0.5 + kn, vn = [], [] + for l, P in enumerate(self.layers): + # MoonshineStreamingDecoderLayer.forward, lines 725-755 + h = layer_norm(x, P["ln1"]) + q = (h @ P["wq"].t()).reshape(ENC_H, HD) + k = (h @ P["wk"].t()).reshape(ENC_H, HD) + v = (h @ P["wv"].t()).reshape(ENC_H, HD) + # apply_rotary_pos_emb on the first 32 (permuted) dims, half-split rotate + def rot(t): + tr, tp = t[:, :ROT], t[:, ROT:] + t1, t2 = tr[:, :ROT // 2], tr[:, ROT // 2:] + return torch.cat([tr * cos + torch.cat([-t2, t1], -1) * sin, tp], -1) + q, k = rot(q), rot(k) + kn.append(k) + vn.append(v) + s_c = (q.unsqueeze(1) @ sk[l]).squeeze(1) * scale + smask # [10, L] + s_n = (q * k).sum(-1, keepdim=True) * scale # [10, 1] (the new token itself) + s = torch.cat([s_c, s_n], -1) + p = torch.softmax(s, dim=-1) + a = (p[:, :self.L].unsqueeze(1) @ sv[l]).squeeze(1) + p[:, self.L:] * v # [10, 64] + x = x + a.reshape(1, DEC_D) @ P["wo"].t() + h = layer_norm(x, P["ln2"]) + q = (h @ P["cq"].t()).reshape(ENC_H, 1, HD) + s = (q @ ck[l]).squeeze(1) * scale + cmask # [10, T] + p = torch.softmax(s, dim=-1) + a = (p.unsqueeze(1) @ cv[l]).squeeze(1) # [10, 64] + x = x + a.reshape(1, DEC_D) @ P["co"].t() + h = layer_norm(x, P["ln3"]) + f = h @ P["f1w"].t() + P["f1b"] + hs, gate = f[:, :DEC_FF], f[:, DEC_FF:] + x = x + (F.silu(gate) * hs) @ P["f2w"].t() + P["f2b"] + x = layer_norm(x, self.norm) + logits = x @ self.emb.t() + return logits, torch.stack(kn), torch.stack(vn) + + +def load_sd(path): + import os, sys + sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) + from convert_ckpt import convert + return convert(path) diff --git a/sm8850-npu-fp16/src/paths.sh b/sm8850-npu-fp16/src/paths.sh new file mode 100644 index 0000000000000000000000000000000000000000..674076ad2958c360c206415df112cae4ca13fab6 --- /dev/null +++ b/sm8850-npu-fp16/src/paths.sh @@ -0,0 +1,12 @@ +# Sourced by build.sh and deploy.sh (with ROOT and NAME set): where .deps/ and build/ live. Next to build.sh when the +# folder is writable, else under $HOME/.cache/$NAME/. +if [ -w "$ROOT" ] || [ -w "$ROOT/build" ] 2>/dev/null; then + WORK_ROOT=$ROOT + DEPS=$ROOT/.deps + BUILD=$ROOT/build +else + _h=$(printf '%s' "$ROOT" | python3 -c 'import hashlib,sys; print(hashlib.sha256(sys.stdin.buffer.read()).hexdigest()[:12])') + WORK_ROOT=$HOME/.cache/$NAME/$_h + DEPS=$WORK_ROOT/.deps + BUILD=$WORK_ROOT/build +fi diff --git a/sm8850-npu-fp16/src/port.json b/sm8850-npu-fp16/src/port.json new file mode 100644 index 0000000000000000000000000000000000000000..0daa24a3f85c1c9a56c19e5364e6e6ab369feb95 --- /dev/null +++ b/sm8850-npu-fp16/src/port.json @@ -0,0 +1,15 @@ +{ + "contract": 1, + "model_type": "speech_to_text", + "model": "Moonshine v2 Streaming Medium (moonshine-ai/moonshine-streaming, tensilier checkpoint)", + "runtime": "LiteRT 2.3.1, Qualcomm dispatch, QNN 2.50.0", + "litert_version": "2.3.1", + "backend": "litert-qnn", + "soc": "SM8850", + "htp_arch": "v81", + "qairt_version": "2.50.0", + "precision": "fp16", + "cpu_fallback": false, + "graphs": ["enc16_Qualcomm_SM8850_apply_plugin.tflite", "dec512h_Qualcomm_SM8850_apply_plugin.tflite", + "dec1536h_Qualcomm_SM8850_apply_plugin.tflite", "dec4096h_Qualcomm_SM8850_apply_plugin.tflite"] +} diff --git a/sm8850-npu-fp16/src/run.sh b/sm8850-npu-fp16/src/run.sh new file mode 100644 index 0000000000000000000000000000000000000000..8f919a1e8ec478e7b62d314b7bd5b466b1326098 --- /dev/null +++ b/sm8850-npu-fp16/src/run.sh @@ -0,0 +1,6 @@ +# Moonshine v2 Streaming Medium on the Hexagon NPU (LiteRT 2.3.1, QNN 2.50, SM8850). +# sh ./run.sh --audio IN.wav --out OUT.json [--metrics M.json] [--repeat R] [--partial-every SEC] [--realtime] +cd "$(dirname "$0")" || exit 1 +export LD_LIBRARY_PATH="$PWD:/system/lib64:/vendor/lib64" +export ADSP_LIBRARY_PATH="$PWD/dsp;$PWD;/vendor/lib/rfsa/adsp;/vendor/dsp/cdsp;/system/lib/rfsa/adsp;/vendor/dsp" +exec ./moonshine_stream "$@" diff --git a/sm8850-npu-fp16/src/runner.c b/sm8850-npu-fp16/src/runner.c new file mode 100644 index 0000000000000000000000000000000000000000..816d94b90151697462280fec1ba64f46bd45f3a7 --- /dev/null +++ b/sm8850-npu-fp16/src/runner.c @@ -0,0 +1,680 @@ +// moonshine_stream: streaming speech to text with Moonshine v2 Streaming Medium on the Hexagon NPU (LiteRT 2.3.1 C +// API, Qualcomm dispatch, models compiled ahead of time for SM8850). Every model graph runs on the HTP; this program +// only reads the WAV, cuts it into 320 ms chunks, carries the streaming state between graph runs (memcpy), scatters +// the cross-attention K/V into the decoder's inputs, takes the argmax and detokenizes. +// +// moonshine_stream --audio IN.wav --out OUT.json [--metrics M.json] [--repeat R] [--models DIR] +// [--partial-every SEC] [--realtime] [--quiet] +// +// The host model of this loop (same chunking, masks, buckets and greedy decode) is src/host_stream.py; the graphs are +// src/moonshine_npu.py (EncoderChunk, DecoderStep) exported by src/export_tflite.py. +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "litert/c/litert_any.h" +#include "litert/c/litert_common.h" +#include "litert/c/litert_compiled_model.h" +#include "litert/c/litert_environment.h" +#include "litert/c/litert_environment_options.h" +#include "litert/c/litert_model.h" +#include "litert/c/litert_opaque_options.h" +#include "litert/c/litert_options.h" +#include "litert/c/litert_tensor_buffer.h" +#include "litert/c/litert_tensor_buffer_requirements.h" + +// moonshine_npu.py constants +#define ENC_D 768 +#define NH 10 +#define HD 64 +#define KVD 640 // NH * HD +#define NL 14 // encoder and decoder layers +#define NLA 4 // lookahead layers (0, 1, 12, 13) +#define VOCAB 32768 +#define FRAME 80 // samples per frontend frame +#define SPE 320 // samples per encoder frame (50 Hz) +#define C 16 // encoder frames per chunk (enc16 graph) +#define CHUNK (C * SPE) // 5120 samples = 320 ms +#define LEFT 15 +#define SMAX 18 +#define TOTAL_LAG 12 +#define MAXPOS 4096 +#define PART_AUDIO_PER_TOK 0.04 // s of audio between partials per decoded token (decoder 5.5-10 ms/token) +#define NEG (-1.0e4f) +#define BOS 1 +#define EOS 2 +static const int LOOKAHEAD[NL] = {3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3}; + +static const struct { int T, L; const char* file; } BUCKETS[] = { + {512, 80, "dec512h_Qualcomm_SM8850_apply_plugin.tflite"}, + {1536, 224, "dec1536h_Qualcomm_SM8850_apply_plugin.tflite"}, + {4096, 544, "dec4096h_Qualcomm_SM8850_apply_plugin.tflite"}, +}; +#define NBUCKETS 3 +static const char* ENC_FILE = "enc16_Qualcomm_SM8850_apply_plugin.tflite"; + +static double now_ms(void) { + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return ts.tv_sec * 1e3 + ts.tv_nsec / 1e6; +} + +static int g_quiet = 0; +static FILE* g_dump = NULL; // MOONSHINE_DUMP=FILE: debugging dump of the encoder output +#define LOG(...) do { if (!g_quiet) { fprintf(stderr, __VA_ARGS__); fflush(stderr); } } while (0) +#define DIE(...) do { fprintf(stderr, "moonshine_stream: " __VA_ARGS__); fprintf(stderr, "\n"); exit(1); } while (0) + +// ---------------------------------------------------------------- LiteRT graphs +#define MAXIO 16 +typedef struct { + const char* name; + LiteRtModel model; + LiteRtOptions opts; // kept alive until the compiled model is destroyed (the Qualcomm dispatch reads it) + LiteRtCompiledModel cm; + int ni, no; + LiteRtTensorBuffer in[MAXIO], out[MAXIO]; // in signature order args_0.., output_0.. + LiteRtElementType in_t[MAXIO], out_t[MAXIO]; + size_t in_n[MAXIO], out_n[MAXIO]; +} Graph; + +static int suffix(const char* s) { + const char* u = strrchr(s, '_'); + return u ? atoi(u + 1) : 0; +} + +static void graph_load(Graph* g, LiteRtEnvironment env, const char* dir, const char* file) { + char path[1024]; + snprintf(path, sizeof path, "%s/%s", dir, file); + g->name = file; + if (LiteRtCreateModelFromFile(env, path, &g->model) != kLiteRtStatusOk) DIE("cannot load model %s", path); + LiteRtCreateOptions(&g->opts); + LiteRtSetOptionsHardwareAccelerators(g->opts, kLiteRtHwAcceleratorNpu); // the NPU alone: no CPU fallback + LiteRtOpaqueOptions q = NULL; + LiteRtCreateOpaqueOptions("qualcomm", strdup("htp_performance_mode = 2\nlog_level = 1\n"), free, &q); // 2 = burst; QNN logs: errors only + if (q) LiteRtAddOpaqueOptions(g->opts, q); + LiteRtStatus s = LiteRtCreateCompiledModel(env, g->model, g->opts, &g->cm); + if (s != kLiteRtStatusOk) DIE("compiling %s on the NPU failed (status %d)", file, (int)s); + bool noncpu = false; + LiteRtCompiledModelIsNonCpuFullyAccelerated(g->cm, &noncpu); + printf("LiteRT fully accelerated on the NPU: %s (LiteRtCompiledModelIsNonCpuFullyAccelerated) model=%s\n", + noncpu ? "yes" : "no", file); + fflush(stdout); + if (!noncpu) DIE("%s is not fully on the NPU", file); + LiteRtSignature sig; + if (LiteRtGetModelSignature(g->model, 0, &sig) != kLiteRtStatusOk) DIE("%s: no signature", file); + LiteRtParamIndex ni = 0, no = 0; + LiteRtGetNumSignatureInputs(sig, &ni); + LiteRtGetNumSignatureOutputs(sig, &no); + if (ni > MAXIO || no > MAXIO) DIE("%s: too many tensors", file); + g->ni = (int)ni; + g->no = (int)no; + for (int pass = 0; pass < 2; ++pass) { + int n = pass ? g->no : g->ni; + for (int i = 0; i < n; ++i) { + const char* nm = NULL; + LiteRtTensor t; + if (pass) { + LiteRtGetSignatureOutputName(sig, i, &nm); + LiteRtGetSignatureOutputTensorByIndex(sig, i, &t); + } else { + LiteRtGetSignatureInputName(sig, i, &nm); + LiteRtGetSignatureInputTensorByIndex(sig, i, &t); + } + int k = suffix(nm ? nm : ""); // args_10 sorts before args_2 by name: order by the numeric suffix + if (k < 0 || k >= n) DIE("%s: unexpected tensor name %s", file, nm ? nm : "?"); + LiteRtRankedTensorType tt; + LiteRtGetRankedTensorType(t, &tt); + LiteRtTensorBufferRequirements req; + s = pass ? LiteRtGetCompiledModelOutputBufferRequirements(g->cm, 0, i, &req) + : LiteRtGetCompiledModelInputBufferRequirements(g->cm, 0, i, &req); + LiteRtTensorBuffer b = NULL; + if (s == kLiteRtStatusOk) s = LiteRtCreateManagedTensorBufferFromRequirements(env, &tt, req, &b); + if (s != kLiteRtStatusOk) DIE("%s: buffer for %s failed (%d)", file, nm ? nm : "?", (int)s); + size_t bytes = 0; + LiteRtGetTensorBufferPackedSize(b, &bytes); + if (pass) { + g->out[k] = b; g->out_t[k] = tt.element_type; g->out_n[k] = bytes; + } else { + g->in[k] = b; g->in_t[k] = tt.element_type; g->in_n[k] = bytes; + } + } + } +} + +static void graph_free(Graph* g) { + for (int i = 0; i < MAXIO; ++i) { + if (g->in[i]) LiteRtDestroyTensorBuffer(g->in[i]); + if (g->out[i]) LiteRtDestroyTensorBuffer(g->out[i]); + } + if (g->cm) LiteRtDestroyCompiledModel(g->cm); + if (g->opts) LiteRtDestroyOptions(g->opts); + if (g->model) LiteRtDestroyModel(g->model); + memset(g, 0, sizeof *g); +} + +static void* lock_w(LiteRtTensorBuffer b) { + void* p = NULL; + if (LiteRtLockTensorBuffer(b, &p, kLiteRtTensorBufferLockModeWrite) != kLiteRtStatusOk || !p) DIE("lock failed"); + return p; +} +static void* lock_r(LiteRtTensorBuffer b) { + void* p = NULL; + if (LiteRtLockTensorBuffer(b, &p, kLiteRtTensorBufferLockModeRead) != kLiteRtStatusOk || !p) DIE("lock failed"); + return p; +} +static void unlock(LiteRtTensorBuffer b) { LiteRtUnlockTensorBuffer(b); } + +static void graph_run(Graph* g) { + LiteRtStatus s = LiteRtRunCompiledModel(g->cm, 0, g->ni, g->in, g->no, g->out); + if (s != kLiteRtStatusOk) DIE("running %s failed (status %d)", g->name, (int)s); +} + +static void zero_input(Graph* g, int i) { + memset(lock_w(g->in[i]), 0, g->in_n[i]); + unlock(g->in[i]); +} + +// out[o] -> in[i]: state fed back by copy (never swap buffers: QNN re-registers them with the DSP on every run) +static void copy_state(Graph* g, int o, int i) { + if (g->out_n[o] != g->in_n[i]) DIE("%s: state size mismatch out %d in %d", g->name, o, i); + void* src = lock_r(g->out[o]); + void* dst = lock_w(g->in[i]); + memcpy(dst, src, g->in_n[i]); + unlock(g->in[i]); + unlock(g->out[o]); +} + +// ---------------------------------------------------------------- WAV +static float* read_wav(const char* path, int* n_out) { + FILE* f = fopen(path, "rb"); + if (!f) DIE("cannot open %s", path); + unsigned char h[12]; + if (fread(h, 1, 12, f) != 12 || memcmp(h, "RIFF", 4) || memcmp(h + 8, "WAVE", 4)) DIE("%s: not a RIFF WAVE file", path); + int fmt = 0, ch = 0, rate = 0, bits = 0; + float* a = NULL; + for (;;) { + unsigned char ck[8]; + if (fread(ck, 1, 8, f) != 8) break; + uint32_t sz = ck[4] | ck[5] << 8 | ck[6] << 16 | (uint32_t)ck[7] << 24; + if (!memcmp(ck, "fmt ", 4)) { + unsigned char b[40] = {0}; + size_t r = sz < sizeof b ? sz : sizeof b; + if (fread(b, 1, r, f) != r) DIE("%s: short fmt chunk", path); + if (sz > r) fseek(f, (long)(sz - r), SEEK_CUR); + fmt = b[0] | b[1] << 8; + ch = b[2] | b[3] << 8; + rate = b[4] | b[5] << 8 | b[6] << 16 | b[7] << 24; + bits = b[14] | b[15] << 8; + if (fmt == 0xFFFE && sz >= 26) fmt = b[24] | b[25] << 8; // WAVE_FORMAT_EXTENSIBLE subformat + } else if (!memcmp(ck, "data", 4)) { + if (!ch) DIE("%s: data before fmt", path); + if (rate != 16000) DIE("%s: %d Hz, 16000 Hz expected", path, rate); + int bps = bits / 8; + if (!((fmt == 1 && bits == 16) || (fmt == 3 && bits == 32))) DIE("%s: 16-bit PCM or 32-bit float WAV expected", path); + unsigned char* raw = malloc(sz ? sz : 1); + size_t got = fread(raw, 1, sz, f); + int n = (int)(got / (size_t)(bps * ch)); + a = malloc(sizeof(float) * (size_t)(n ? n : 1)); + for (int i = 0; i < n; ++i) { + double acc = 0; + for (int c = 0; c < ch; ++c) { + const unsigned char* p = raw + ((size_t)i * ch + c) * bps; + if (fmt == 1) acc += (int16_t)(p[0] | p[1] << 8) / 32768.0; + else { float v; memcpy(&v, p, 4); acc += v; } + } + a[i] = (float)(acc / ch); + } + free(raw); + *n_out = n; + break; + } else { + fseek(f, (long)(sz + (sz & 1)), SEEK_CUR); + } + } + fclose(f); + if (!a) DIE("%s: no data chunk", path); + return a; +} + +// ---------------------------------------------------------------- tokenizer (vocab.bin from make_vocab.py) +typedef struct { unsigned char flags; unsigned short len; const unsigned char* s; } Tok; +static Tok g_vocab[VOCAB]; +static unsigned char* g_vocab_data; + +static void load_vocab(const char* dir) { + char path[1024]; + snprintf(path, sizeof path, "%s/vocab.bin", dir); + FILE* f = fopen(path, "rb"); + if (!f) DIE("cannot open %s", path); + fseek(f, 0, SEEK_END); + long n = ftell(f); + fseek(f, 0, SEEK_SET); + g_vocab_data = malloc((size_t)n); + if (fread(g_vocab_data, 1, (size_t)n, f) != (size_t)n) DIE("short read %s", path); + fclose(f); + if (n < 12 || memcmp(g_vocab_data, "MSVOCAB1", 8)) DIE("%s: bad header", path); + uint32_t cnt; + memcpy(&cnt, g_vocab_data + 8, 4); + const unsigned char* p = g_vocab_data + 12; + for (uint32_t i = 0; i < cnt && i < VOCAB; ++i) { + g_vocab[i].flags = p[0]; + g_vocab[i].len = (unsigned short)(p[1] | p[2] << 8); + g_vocab[i].s = p + 3; + p += 3 + g_vocab[i].len; + } +} + +// Join the token bytes (special tokens skipped), strip one leading space, replace invalid UTF-8 by U+FFFD. +static char* detok(const int* toks, int n) { + size_t cap = 16; + for (int i = 0; i < n; ++i) cap += g_vocab[toks[i]].len; + unsigned char* raw = malloc(cap); + size_t m = 0; + for (int i = 0; i < n; ++i) { + const Tok* t = &g_vocab[toks[i]]; + if (t->flags & 1) continue; + memcpy(raw + m, t->s, t->len); + m += t->len; + } + size_t st = (m > 0 && raw[0] == ' ') ? 1 : 0; + char* out = malloc(3 * m + 4); + size_t o = 0; + for (size_t i = st; i < m;) { + unsigned char c = raw[i]; + int len = c < 0x80 ? 1 : (c >> 5) == 6 ? 2 : (c >> 4) == 14 ? 3 : (c >> 3) == 30 ? 4 : 0; + bool ok = len > 0 && i + len <= m; + for (int k = 1; ok && k < len; ++k) ok = (raw[i + k] & 0xC0) == 0x80; + if (ok) { + memcpy(out + o, raw + i, (size_t)len); + o += len; + i += len; + } else { + memcpy(out + o, "\xEF\xBF\xBD", 3); + o += 3; + i += 1; + } + } + out[o] = 0; + free(raw); + return out; +} + +static void json_str(FILE* f, const char* s) { + fputc('"', f); + for (; *s; ++s) { + unsigned char c = (unsigned char)*s; + if (c == '"' || c == '\\') fprintf(f, "\\%c", c); + else if (c == '\n') fputs("\\n", f); + else if (c < 0x20) fprintf(f, "\\u%04x", c); + else fputc(c, f); + } + fputc('"', f); +} + +// ---------------------------------------------------------------- the stream +typedef struct { + Graph enc, dec; + int Tb, Lb; + bool half; // decoder cache inputs in fp16 +} Engine; + +// Encoder graph I/O (EncoderChunk.forward): in 0 audio[1,5120] 1 c1s[4,768] 2 c2s[4,1536] 3 kst[14,18,640] +// 4 vst[14,18,640] 5 xst[4,3,768] 6 kmask[14,34] 7 pos[16] int32; out 0..4 the new states, 5 ck[14,16,640] +// 6 cv[14,16,640] 7 enc[16,768]. +// Decoder graph I/O (DecoderStep.forward): in 0 tok[1] 1 pos[1] int32, 2 smask[1,L] 3 cmask[1,T] fp32, +// 4 sk[14,10,64,L] 5 sv[14,10,L,64] 6 ck[14,10,64,T] 7 cv[14,10,T,64] (fp16); out 0 logits[1,32768] fp32, +// 1 knew[14,10,64] 2 vnew[14,10,64]. + +static inline void put(void* base, bool half, size_t idx, float v) { + if (half) ((__fp16*)base)[idx] = (__fp16)v; + else ((float*)base)[idx] = v; +} + +typedef struct { + int toks[1024]; + int n; + double ms; + int steps; +} Decode; + +// Greedy decode over the first `avail` encoder frames (HF generate: start from BOS, at most max_length - 1 new tokens, +// stop at EOS). host_stream.py greedy(). +static void greedy(Engine* e, int avail, int max_length, Decode* d) { + Graph* g = &e->dec; + double t0 = now_ms(); + float* cm = lock_w(g->in[3]); + for (int t = 0; t < e->Tb; ++t) cm[t] = t < avail ? 0.f : NEG; + unlock(g->in[3]); + d->toks[0] = BOS; + d->n = 1; + int steps = max_length - 1; + if (steps > e->Lb) DIE("%d decoder steps exceed the bucket's %d positions", steps, e->Lb); + for (int i = 0; i < steps; ++i) { + int32_t* tok = lock_w(g->in[0]); + tok[0] = d->toks[d->n - 1]; + unlock(g->in[0]); + int32_t* pos = lock_w(g->in[1]); + pos[0] = i; + unlock(g->in[1]); + float* sm = lock_w(g->in[2]); + for (int j = 0; j < e->Lb; ++j) sm[j] = j < i ? 0.f : NEG; + unlock(g->in[2]); + graph_run(g); + const float* kn = lock_r(g->out[1]); + const float* vn = lock_r(g->out[2]); + bool kh = g->out_t[1] == kLiteRtElementTypeFloat16; + void* sk = lock_w(g->in[4]); + void* sv = lock_w(g->in[5]); + for (int lh = 0; lh < NL * NH; ++lh) + for (int dd = 0; dd < HD; ++dd) { + float k = kh ? (float)((const __fp16*)kn)[lh * HD + dd] : kn[lh * HD + dd]; + float v = kh ? (float)((const __fp16*)vn)[lh * HD + dd] : vn[lh * HD + dd]; + put(sk, e->half, ((size_t)lh * HD + dd) * e->Lb + i, k); + put(sv, e->half, ((size_t)lh * e->Lb + i) * HD + dd, v); + } + unlock(g->in[5]); + unlock(g->in[4]); + unlock(g->out[2]); + unlock(g->out[1]); + const float* lg = lock_r(g->out[0]); + int best = 0; + for (int v = 1; v < VOCAB; ++v) + if (lg[v] > lg[best]) best = v; // ties to the lowest id + unlock(g->out[0]); + d->toks[d->n++] = best; + if (best == EOS) break; + } + d->steps = d->n - 1; + d->ms = now_ms() - t0; +} + +typedef struct { + double total_ms, first_partial_ms, first_partial_audio_s, enc_ms_sum, dec_ms, part_ms; + int chunks, new_tokens, dec_steps, partials; + double* chunk_ms; // encoder run + state copy + K/V scatter, per chunk + double* latency_ms; // --realtime: chunk arrival to its work (and partial) done + char* text; + char** ptext; + double* paudio; +} RunResult; + +static void run_stream(Engine* e, const float* audio_in, int n, double partial_every, bool realtime, RunResult* rr) { + double t_start = now_ms(); + memset(rr, 0, sizeof *rr); + rr->first_partial_ms = -1; + int n0 = n / FRAME; + int F = (n + FRAME - 1) / FRAME, n1 = (F + 1) / 2, T = (n1 + 1) / 2; + int K = (T + TOTAL_LAG + C - 1) / C; + rr->chunk_ms = calloc((size_t)K + 1, sizeof(double)); + rr->latency_ms = calloc((size_t)K + 1, sizeof(double)); + int maxp = (int)(n / 16000.0 / (partial_every > 0 ? partial_every : 1e9)) + 2; + rr->ptext = calloc((size_t)maxp, sizeof(char*)); + rr->paudio = calloc((size_t)maxp, sizeof(double)); + Graph* g = &e->enc; + for (int i = 1; i <= 5; ++i) zero_input(g, i); // fresh streaming state for every request + int D[NL]; + for (int l = 0, s = 0; l < NL; ++l) { D[l] = s; s += LOOKAHEAD[l]; } + double next_partial = partial_every > 0 ? partial_every * 16000.0 : 1e30; + Decode dec; + for (int k = 0; k < K; ++k) { + long s0 = (long)k * CHUNK; + if (realtime) { // wait until this chunk would have arrived from a live microphone + double arrive = t_start + (double)((s0 + CHUNK < n) ? s0 + CHUNK : n) / 16.0; // padding chunks arrive with the end + while (now_ms() < arrive) usleep(1000); + } + double t0 = now_ms(); + float* a = lock_w(g->in[0]); + for (int i = 0; i < CHUNK; ++i) { + long j = s0 + i; + a[i] = (j < (long)n0 * FRAME) ? audio_in[j] : 0.f; // the partial last 80-sample frame is masked to zero + } + unlock(g->in[0]); + float* km = lock_w(g->in[6]); + for (int l = 0; l < NL; ++l) { + int r = LOOKAHEAD[l]; + int av = k * C - D[l] - r; + for (int jj = 0; jj < SMAX + C; ++jj) { + int f = av - LEFT - (SMAX - LEFT - r) + jj; + km[l * (SMAX + C) + jj] = (f >= 0 && f < T) ? 0.f : NEG; + } + } + unlock(g->in[6]); + int out0 = k * C - TOTAL_LAG; + int32_t* pos = lock_w(g->in[7]); + for (int i = 0; i < C; ++i) { + int p = out0 + i; + pos[i] = p < 0 ? 0 : p >= MAXPOS ? MAXPOS - 1 : p; + } + unlock(g->in[7]); + graph_run(g); + if (g_dump) { // debugging: the encoder output rows of every chunk, appended as raw fp32 [16, 768] + fwrite(lock_r(g->out[7]), sizeof(float), (size_t)C * 768, g_dump); + unlock(g->out[7]); + } + for (int i = 0; i < 5; ++i) copy_state(g, i, i + 1); + // new cross-attention K/V rows -> decoder inputs ck[l][h][d][t], cv[l][h][t][d] + const float* ck = lock_r(g->out[5]); + const float* cv = lock_r(g->out[6]); + void* dk = lock_w(e->dec.in[6]); + void* dv = lock_w(e->dec.in[7]); + for (int i = 0; i < C; ++i) { + int f = out0 + i; + if (f < 0 || f >= T) continue; + for (int l = 0; l < NL; ++l) { + const float* kr = ck + ((size_t)l * C + i) * KVD; + const float* vr = cv + ((size_t)l * C + i) * KVD; + for (int h = 0; h < NH; ++h) + for (int dd = 0; dd < HD; ++dd) { + size_t lh = (size_t)l * NH + h; + put(dk, e->half, (lh * HD + dd) * e->Tb + f, kr[h * HD + dd]); + put(dv, e->half, (lh * e->Tb + f) * HD + dd, vr[h * HD + dd]); + } + } + } + unlock(e->dec.in[7]); + unlock(e->dec.in[6]); + unlock(g->out[6]); + unlock(g->out[5]); + double t1 = now_ms(); + rr->chunk_ms[k] = t1 - t0; + rr->enc_ms_sum += t1 - t0; + long seen = s0 + CHUNK < n ? s0 + CHUNK : n; + int avail = (k + 1) * C - TOTAL_LAG; + if (avail > T) avail = T; + if (k < K - 1 && seen < n && (double)(s0 + CHUNK) >= next_partial && avail > 0) { + greedy(e, avail, (int)(seen * 6.5 / 16000.0), &dec); + // a partial re-decodes everything heard so far: wait at least PART_AUDIO_PER_TOK s of audio per token it took, + // so partials cost at most ~25% of the audio's duration on long inputs (deterministic: counts tokens, not time) + while (next_partial <= (double)(s0 + CHUNK)) next_partial += partial_every * 16000.0; + double tok_next = (double)(s0 + CHUNK) + dec.steps * PART_AUDIO_PER_TOK * 16000.0; + if (tok_next > next_partial) next_partial = tok_next; + char* txt = detok(dec.toks, dec.n); + double tp = now_ms(); + if (rr->partials == 0) { + rr->first_partial_ms = tp - t_start; + rr->first_partial_audio_s = seen / 16000.0; + } + rr->paudio[rr->partials] = seen / 16000.0; + rr->ptext[rr->partials++] = txt; + rr->part_ms += dec.ms; + LOG("PARTIAL %6.2fs (%5.1f ms, %d tok): %s\n", seen / 16000.0, dec.ms, dec.steps, txt); + } + rr->latency_ms[k] = now_ms() - t0; + rr->chunks = k + 1; + } + int ml = (int)(n * 6.5 / 16000.0); + greedy(e, T, ml, &dec); + rr->text = detok(dec.toks, dec.n); + rr->new_tokens = dec.steps; + rr->dec_ms = dec.ms; + rr->dec_steps = dec.steps; + rr->total_ms = now_ms() - t_start; + if (rr->first_partial_ms < 0) { + rr->first_partial_ms = rr->total_ms; + rr->first_partial_audio_s = n / 16000.0; + } + LOG("FINAL %6.2fs (%5.1f ms, %d tok): %s\n", n / 16000.0, dec.ms, dec.steps, rr->text); +} + +static void free_result(RunResult* rr) { + for (int i = 0; i < rr->partials; ++i) free(rr->ptext[i]); + free(rr->ptext); + free(rr->paudio); + free(rr->chunk_ms); + free(rr->latency_ms); + free(rr->text); +} + +static int cmpd(const void* a, const void* b) { + double x = *(const double*)a, y = *(const double*)b; + return x < y ? -1 : x > y; +} +static double median(const double* v, int n) { + if (n <= 0) return 0; + double* t = malloc(sizeof(double) * (size_t)n); + memcpy(t, v, sizeof(double) * (size_t)n); + qsort(t, (size_t)n, sizeof(double), cmpd); + double m = n % 2 ? t[n / 2] : 0.5 * (t[n / 2 - 1] + t[n / 2]); + free(t); + return m; +} + +static void usage(void) { + fprintf(stderr, + "usage: moonshine_stream --audio IN.wav --out OUT.json [--metrics M.json] [--repeat R] [--models DIR]\n" + " [--partial-every SEC (default 1.0, 0 = no partials)] [--realtime] [--quiet]\n"); +} + +int main(int argc, char** argv) { + double t_proc = now_ms(); + const char *wav = NULL, *out = NULL, *metrics = NULL, *models = NULL; + int repeat = 1; + double partial_every = 1.0; + bool realtime = false; + for (int i = 1; i < argc; ++i) { + const char* a = argv[i]; + const char* v = i + 1 < argc ? argv[i + 1] : NULL; +#define TAKE(x) do { if (!v) { usage(); return 1; } x; ++i; } while (0) + if (!strcmp(a, "--audio")) TAKE(wav = v); + else if (!strcmp(a, "--out")) TAKE(out = v); + else if (!strcmp(a, "--metrics")) TAKE(metrics = v); + else if (!strcmp(a, "--repeat")) TAKE(repeat = atoi(v)); + else if (!strcmp(a, "--models")) TAKE(models = v); + else if (!strcmp(a, "--partial-every")) TAKE(partial_every = atof(v)); + else if (!strcmp(a, "--realtime")) realtime = true; + else if (!strcmp(a, "--quiet")) g_quiet = 1; + else { fprintf(stderr, "moonshine_stream: unknown argument %s\n", a); usage(); return 1; } +#undef TAKE + } + if (!wav || !out || repeat < 1) { usage(); return 1; } + char exe_dir[1024]; + ssize_t len = readlink("/proc/self/exe", exe_dir, sizeof exe_dir - 1); + exe_dir[len > 0 ? len : 0] = 0; + char* sl = strrchr(exe_dir, '/'); + if (sl) *sl = 0; else strcpy(exe_dir, "."); + if (!models) models = exe_dir; + if (!getenv("ADSP_LIBRARY_PATH")) { + char p[4096]; + snprintf(p, sizeof p, "%s/dsp;%s;/vendor/lib/rfsa/adsp;/vendor/dsp/cdsp;/system/lib/rfsa/adsp;/vendor/dsp", exe_dir, + exe_dir); + setenv("ADSP_LIBRARY_PATH", p, 1); + } + + if (getenv("MOONSHINE_DUMP")) g_dump = fopen(getenv("MOONSHINE_DUMP"), "wb"); + int n = 0; + float* audio = read_wav(wav, &n); + int F = (n + FRAME - 1) / FRAME, n1 = (F + 1) / 2, T = (n1 + 1) / 2; + int b = 0; + while (b < NBUCKETS && BUCKETS[b].T < T) ++b; + if (b == NBUCKETS) + DIE("%.1f s of audio is %d encoder frames; the model's position table and the largest bucket hold %d (81.9 s)", + n / 16000.0, T, MAXPOS); + load_vocab(models); + + LiteRtEnvironment env = NULL; + LiteRtEnvOption eo[2]; + eo[0].tag = kLiteRtEnvOptionTagDispatchLibraryDir; + eo[0].value.type = kLiteRtAnyTypeString; + eo[0].value.str_value = exe_dir; + eo[1].tag = kLiteRtEnvOptionTagMinLoggerSeverity; + eo[1].value.type = kLiteRtAnyTypeInt; + eo[1].value.int_value = 3; // errors only (1 = info: QNN logs every buffer registration) + if (LiteRtCreateEnvironment(2, eo, &env) != kLiteRtStatusOk) DIE("LiteRtCreateEnvironment failed"); + Engine e; + memset(&e, 0, sizeof e); + e.Tb = BUCKETS[b].T; + e.Lb = BUCKETS[b].L; + LOG("loading %s and %s (T=%d frames, %.2f s audio)\n", ENC_FILE, BUCKETS[b].file, T, n / 16000.0); + graph_load(&e.enc, env, models, ENC_FILE); + graph_load(&e.dec, env, models, BUCKETS[b].file); + e.half = e.dec.in_t[6] == kLiteRtElementTypeFloat16; + if (e.enc.ni != 8 || e.enc.no != 8 || e.dec.ni != 8 || e.dec.no != 3 || e.enc.out_t[5] != kLiteRtElementTypeFloat32 || + e.enc.out_t[6] != kLiteRtElementTypeFloat32 || e.dec.out_t[0] != kLiteRtElementTypeFloat32 || + e.dec.in_t[2] != kLiteRtElementTypeFloat32 || e.dec.in_t[3] != kLiteRtElementTypeFloat32 || + e.enc.in_t[0] != kLiteRtElementTypeFloat32 || e.enc.in_t[6] != kLiteRtElementTypeFloat32) + DIE("unexpected graph signature (tensor count or dtype)"); + for (int i = 0; i < e.dec.ni; ++i) zero_input(&e.dec, i); // masked cache slots must still be finite + double load_ms = now_ms() - t_proc; + LOG("ready in %.0f ms\n", load_ms); + + RunResult* runs = calloc((size_t)repeat, sizeof(RunResult)); + for (int r = 0; r < repeat; ++r) { + run_stream(&e, audio, n, partial_every, realtime, &runs[r]); + LOG("run %d: total %.1f ms, encoder %.2f ms/chunk (%d chunks), final decode %d tok in %.1f ms, partials %d in " + "%.1f ms, RTF %.3f\n", + r, runs[r].total_ms, median(runs[r].chunk_ms, runs[r].chunks), runs[r].chunks, runs[r].dec_steps, + runs[r].dec_ms, runs[r].partials, runs[r].part_ms, runs[r].total_ms / (n / 16.0)); + } + RunResult* last = &runs[repeat - 1]; + FILE* f = fopen(out, "w"); + if (!f) DIE("cannot write %s", out); + fputs("{\"text\": ", f); + json_str(f, last->text); + fputs(", \"partials\": [", f); + for (int i = 0; i < last->partials; ++i) { + fprintf(f, "%s{\"audio_s\": %.2f, \"text\": ", i ? ", " : "", last->paudio[i]); + json_str(f, last->ptext[i]); + fputc('}', f); + } + fputs("]}\n", f); + fclose(f); + if (metrics) { + struct rusage ru; + getrusage(RUSAGE_SELF, &ru); + f = fopen(metrics, "w"); + if (!f) DIE("cannot write %s", metrics); + fprintf(f, "{\"load_ms\": %.1f, \"runs\": [", load_ms); + for (int r = 0; r < repeat; ++r) { + RunResult* x = &runs[r]; + fprintf(f, + "%s{\"total_ms\": %.2f, \"ttft_ms\": %.2f, \"first_partial_ms\": %.2f, \"first_partial_audio_s\": %.2f, " + "\"new_tokens\": %d, \"audio_s\": %.3f, \"rtf\": %.4f, \"chunks\": %d, \"chunk_ms_median\": %.3f, " + "\"final_decode_ms\": %.2f, \"decode_ms_per_token\": %.3f, \"partials\": %d, \"partial_decode_ms\": %.2f, " + "\"end_latency_ms\": %.2f, \"realtime\": %s, \"chunk_ms\": [", + r ? ", " : "", x->total_ms, x->first_partial_ms, x->first_partial_ms, x->first_partial_audio_s, + x->new_tokens, n / 16000.0, x->total_ms / (n / 16.0), x->chunks, median(x->chunk_ms, x->chunks), + x->dec_ms, x->dec_steps ? x->dec_ms / x->dec_steps : 0.0, x->partials, x->part_ms, + realtime ? x->total_ms - n / 16.0 : x->total_ms, realtime ? "true" : "false"); + for (int k = 0; k < x->chunks; ++k) fprintf(f, "%s%.3f", k ? ", " : "", x->chunk_ms[k]); + fputs("], \"chunk_latency_ms\": [", f); + for (int k = 0; k < x->chunks; ++k) fprintf(f, "%s%.3f", k ? ", " : "", x->latency_ms[k]); + fputs("]}", f); + } + fprintf(f, "], \"peak_mem_mb\": %.1f}\n", ru.ru_maxrss / 1024.0); + fclose(f); + } + for (int r = 0; r < repeat; ++r) free_result(&runs[r]); + free(runs); + graph_free(&e.dec); // compiled models before their options (graph_free order), then the environment + graph_free(&e.enc); + LiteRtDestroyEnvironment(env); + free(audio); + free(g_vocab_data); + return 0; +} diff --git a/sm8850-npu-fp16/src/vm_pipeline.sh b/sm8850-npu-fp16/src/vm_pipeline.sh new file mode 100644 index 0000000000000000000000000000000000000000..c6af1914e2d713e1ad56d71b61af60c7bda38a25 --- /dev/null +++ b/sm8850-npu-fp16/src/vm_pipeline.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# Model pipeline (x86-64 Linux, Python 3.12, >= 64 GB RAM; made on a 16 vCPU / 128 GB machine): weights from Hugging +# Face -> .tflite (export_tflite.py, checked on CPU) -> AOT compile for SM8850 (aot_compile.py). Not run by build.sh: +# its outputs ship in models/. +# bash src/vm_pipeline.sh WORKDIR GRAPH... (GRAPH: enc16 dec512h dec1536h dec4096h; suffix h = fp16 cache inputs) +# CASES=DIR (optional): real graph inputs from make_cases.py, used by export_tflite.py's CPU check +set -u +SRC=$(cd "$(dirname "$0")" && pwd) +WORK=${1:?usage: bash vm_pipeline.sh WORKDIR GRAPH...}; shift +mkdir -p "$WORK" && cd "$WORK" || exit 1 +VENV=$WORK/.venv +if [ ! -f "$VENV/.ok" ]; then + python3 -m venv "$VENV" && "$VENV/bin/pip" install -q -r "$SRC/export_requirements.txt" && touch "$VENV/.ok" || exit 1 +fi +PY=$VENV/bin/python +REV=da30bae714913eb0057e733bccb4700104afb1b0 +CKPT=m/tensilier/model.safetensors +if [ ! -f "$CKPT" ]; then + mkdir -p m/tensilier + curl -fL --retry 3 -o "$CKPT" \ + "https://huggingface.co/moonshine-ai/moonshine-streaming/resolve/$REV/tensilier/model.safetensors" || exit 1 +fi +echo "6a454dd0a064151946c7076d7b89c79d42a02eb41fc261083392a0349a34d86f $CKPT" | sha256sum -c - || exit 1 +mkdir -p out aot logs +pids=() +for g in "$@"; do + case "$g" in *h) gg=${g%h}; extra=--half-cache ;; *) gg=$g; extra= ;; esac + ( /usr/bin/time -v $PY "$SRC/export_tflite.py" "$CKPT" out --graph $gg $extra ${CASES:+--cases "$CASES"} \ + > logs/exp_$g.log 2>&1 + echo "export $g rc=$?" >> logs/exp_$g.log + $PY "$SRC/aot_compile.py" out/$g.tflite aot > logs/aot_$g.log 2>&1; echo "aot $g rc=$?" >> logs/aot_$g.log ) & + pids+=($!) +done +for p in "${pids[@]}"; do wait $p; done +for g in "$@"; do echo "=== $g"; grep -E "exported|check|cpu run|rc=|Maximum resident" logs/exp_$g.log; tail -n 15 logs/aot_$g.log; done +ls -la out aot diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/LICENSE b/sm8850-npu-fp16/vendor/litert/2.3.1/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/SHA256SUMS b/sm8850-npu-fp16/vendor/litert/2.3.1/SHA256SUMS new file mode 100644 index 0000000000000000000000000000000000000000..c5d9279cfa370fe09856c2c3fb08955f105b6f55 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/SHA256SUMS @@ -0,0 +1,69 @@ +c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 ./LICENSE +c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 ./include/LICENSE +6e69a0cab0a4743d12c5c365784b0faed0d66e39f83b6abe0338e525e508e493 ./include/litert/build_common/build_config.h +1f990a6cb0e146fac26525fe790afd3ea1a57743a8a09e22b4fb3dad0ca8e56f ./include/litert/build_common/config/build_config_cpu_only.h +43957016e5f78881be3a53f57b3e2678278bd6d77d00314553bafe204d022b62 ./include/litert/build_common/config/build_config_gpu.h +6e69a0cab0a4743d12c5c365784b0faed0d66e39f83b6abe0338e525e508e493 ./include/litert/build_common/config/build_config_gpu_npu.h +69eeb0d5968d6e718f9b0510a5aa2057a5776ac825a7c12582030b5b26a593df ./include/litert/build_common/config/build_config_npu.h +5eb13c71f45711ab66c95e9189e97b34d1609e733fcaf36f92ff7a261d8fd1c5 ./include/litert/c/internal/litert_abi_header.h +41058dd791b4f2f8a5157edb6c7fbff8cda0611d515c15dad330cb2c1c736d97 ./include/litert/c/internal/litert_accelerator.h +25a681f0447a586bb323b1cea22b9c4c34e8ba02421306cb2cce031187ac9396 ./include/litert/c/internal/litert_accelerator_def.h +25ba68e1a8506de2b0abe9c369b1136a0331d343a9f310f2a4e58ddae3c505bd ./include/litert/c/internal/litert_accelerator_registration.h +dc3bc20117b8b048ebc576b418dbba8cfb9490613b9558508159c57e8acefe85 ./include/litert/c/internal/litert_compiler_context.h +4e7126626f6c598c01cd51719418e454eaa02d7888c870f71ba6660181d48323 ./include/litert/c/internal/litert_custom_tensor_buffer_handlers_def.h +3f6f33ee97719da33237d02d1de990634f55cd7a99753b529eff051f877faae0 ./include/litert/c/internal/litert_delegate_wrapper.h +b88e715bf538f6001723b087341723cfb8c6f1787e0fde03131808a43bf263f2 ./include/litert/c/internal/litert_dispatch_delegate.h +1095fec726935ef71ba701b3c8eeeb46c4566bd9d55eec701be8cb762d26b1b9 ./include/litert/c/internal/litert_external_litert_buffer_context.h +69bad1fda590ad1afa659159f9fd39cf27a823b487e071230060472165a479e3 ./include/litert/c/internal/litert_logging.h +366cfb40f43ffd4bc0646b4871abdec10081cf7eac0541e099395ff6e31cf139 ./include/litert/c/internal/litert_logging_helper.h +bbafa8fcfcf1b43333286972542635fa8cdbf916e9eb65c55575c14958d8af64 ./include/litert/c/internal/litert_logging_helper_with_compiler_context.h +4bce7433ede32b23fdd0c48ebac0fd1fba0870fd0202805cce1922df50400d2c ./include/litert/c/internal/litert_logging_helper_with_runtime_context.h +2a7a07f4c9c602bd30b992c9988c1678437b0768ff0469b1babd4f42c05c701a ./include/litert/c/internal/litert_options_helper.h +4cee98886bb0b0f506928b3df07d162a4e16b8a5ac44e6f17261eb6fa4bcc99c ./include/litert/c/internal/litert_runtime_api_export.h +943e40fc2d91c8ed94d6427d1644cb7d70c3f16d39b3a3aae813e27561ff9b84 ./include/litert/c/internal/litert_runtime_builtin.h +060c21ceb94b8bcebc467e3a0257f129a1cd3d3b0c17dca5de90381206cc9b16 ./include/litert/c/internal/litert_runtime_c_api.h +fe2ca1df2a866d9681c028a5b2e482e646a15a619e7b377d2a7739d1dd234b18 ./include/litert/c/internal/litert_runtime_context.h +b9076085c64234d90f693cd9017329652bcff605858f084771d4ddd0af37e9ca ./include/litert/c/internal/litert_scheduling_info.h +f77a5bb57d9479035c900b726a9b9a5c7eaca42fe4cc53faeb93dbcc87e4487a ./include/litert/c/internal/litert_tensor_buffer_registry.h +e10779327820f395eaad8ab6984f9f763943c07b0f17a18f3dbadd3d431f91dd ./include/litert/c/litert_any.h +9cc8fbcf1b963f2414cb5abdb26c5983b3124b53b5fbc3151efc4a4986f29ff7 ./include/litert/c/litert_builder.h +42717402ae835f2276bf85eb5666709fb0b3bcdc09b49dbdeecb0191c94a369f ./include/litert/c/litert_common.h +e613c98b5299b0c3c130c883963d29f98a6f0b2dccc66c73b8a10bdccdcac13b ./include/litert/c/litert_compiled_model.h +57f5081cb96d40ce0d63a9b31e96e5816c6847a4d11a85abfa2cbdd4759f52f7 ./include/litert/c/litert_custom_op_kernel.h +70464c92ef72b20f67ad5898148cd9bb31ae995a411e5e233fc90aab4fbd2783 ./include/litert/c/litert_custom_tensor_buffer.h +a83820ef9e68bd175db75a7ef155ce67f5bab2e7ad04e6b046affe9ee3366b3d ./include/litert/c/litert_environment.h +4e2acf5b5c78cae99fb0db40312556d348c32fd1c67f033f86e8a67968ccc995 ./include/litert/c/litert_environment_options.h +c15850184b3908ba1d9b5a53b8ef99004071208bc17d915296d5cf963247a696 ./include/litert/c/litert_event.h +7a6756dc2995d103fc632e06cb15648b24daed99297b7de37b00792d8ebced50 ./include/litert/c/litert_event_type.h +e0ecbd8d410bc8790419c2f01794a8de0b06721fd55d003cd96e8e101764fc49 ./include/litert/c/litert_gl_types.h +c16011a88f7487fa6d3e386905317cf9491d1666d5c7a7ed33e07a9f8b4cf514 ./include/litert/c/litert_layout.h +fa9f0057830c58cf7b57e0f8ccb75dd034294132f5c4c8f44b2e886e72be3a3c ./include/litert/c/litert_metrics.h +c409c985fc79b9f967890e475e28ab77c1fe7776874197a598438a7b2d916d8b ./include/litert/c/litert_model.h +01cf6ea792a7f6f55690fe7acfd8d41f5a707c8ea7cb7418f71e44c84d45757a ./include/litert/c/litert_model_types.h +9937e456e6212efe1164c9c4ca8b1abb645d0dd9220cfefe0b4eca13cb18c49e ./include/litert/c/litert_op_code.h +5c5d7ff7b25e46a939855bd381bdd2377061c7bf96cf6358f07ae78872986df2 ./include/litert/c/litert_op_options.h +33116f5f4a121b785c9b8a313c4ce065088ba322c279776c33542a19e62192c1 ./include/litert/c/litert_opaque_options.h +2cb880623b4d4eb86d242d4b246a14dd42b5fbebf297ceb9bb4012fed6a208b4 ./include/litert/c/litert_opencl_types.h +d7ff502b26c7f54574b351a5afbc247e639843bcb4270d0615d38abbde503d9a ./include/litert/c/litert_options.h +5e3e943ab23621154ee94a71b50a6fdf12504d2ca35ee10b68c948b0020604af ./include/litert/c/litert_platform_support.h +41ba3f580d6c12030053d10698d15ae47264c0f15269c21714da61ecc1156f9a ./include/litert/c/litert_profiler.h +7ed4d79a8f9b1a13188c45066452ff818319b97c70937b0e340801bd485b915c ./include/litert/c/litert_profiler_event.h +30132533f7b0aa09cc56cc28a1f3c49da547592ab8b80718cc91585142a9c568 ./include/litert/c/litert_profiler_types.h +2e45153e2d8510e2570f7965b2c46403445786b535c542f077ac9afda78b1274 ./include/litert/c/litert_tensor_buffer.h +f71921b6bd7959ad4c24808296f53a56c8c1c3677a8cbaf48d5d611e02490387 ./include/litert/c/litert_tensor_buffer_requirements.h +5fa19ae0438f270b3c09281358b9cdfad04c47782cc97582e0af582ec7888450 ./include/litert/c/litert_tensor_buffer_types.h +944030a82f2737b1436893fc5ececfef06ea8cc61580d0c93caa787a5763c011 ./include/litert/c/litert_webgpu_types.h +79e594c0662980b3b74e4d51a4d1ac533b8a6261c82bdf0d4328bc1552417967 ./include/litert/c/options/litert_arm_options.h +ce3272bdb9b6c7e7237f697d9481f099915a4ccda7483ed7508c209900fddd3d ./include/litert/c/options/litert_compiler_options.h +73e13527e760aae2884374323fa7adcd58731b4d8741f852277e738703a7617c ./include/litert/c/options/litert_cpu_options.h +56998e715d276bea00baea697940e2c7e98a5ebf2e434b910a9320aea7d57938 ./include/litert/c/options/litert_google_tensor_options.h +81467d9148ac1fb6d6ed265c39f33436e6063c9e7d3bbbf1eba8fd62d541f4af ./include/litert/c/options/litert_google_tensor_options_type.h +34071b35dda03892e926ca2a99ad985ddc2dd39c9bfbf02f620785aa6b4620bb ./include/litert/c/options/litert_gpu_options.h +54d0a38d32ae00fa406b36e6db87adfd4185f5bb1854f34d5aa1ba57d58a8081 ./include/litert/c/options/litert_intel_openvino_options.h +83c39ba75163f78c08c9108bcca3f3edccc30d382868b81f7dc58d3e35d1c8f5 ./include/litert/c/options/litert_mediatek_options.h +6da0edefa30e1dc1447b1ae60b4996085f71b1f9fb6a951c46ee39c72b7bb7e8 ./include/litert/c/options/litert_qualcomm_options.h +69e5abf6fb7ff77810573a0aea6ee1c6bdffc1aa5434a41479597eba8f3d4535 ./include/litert/c/options/litert_runtime_options.h +05526e6d4b8918d32ebaba5f4ce92e54d65cace15b8f2420802fd7b3b7c85392 ./include/litert/c/options/litert_samsung_options.h +9c6bf33ffb14cfe00a2484e246c00749cbe2b65708fb5de085f03f41c92f2424 ./include/litert/c/options/litert_webnn_options.h +9ad1a5072b09087bddeb3d7be22854350191b21239136b78ebee2120443c7305 ./libLiteRt.so +ab6a581ef26d83f60d03ff4ce2436d9a75b7d0c0b276357787a865e5e9dd4b7d ./libLiteRtDispatch_Qualcomm.so diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/LICENSE b/sm8850-npu-fp16/vendor/litert/2.3.1/include/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/build_common/build_config.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/build_common/build_config.h new file mode 100644 index 0000000000000000000000000000000000000000..0c513fcc51e4a091715006acba0d57da55cead5b --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/build_common/build_config.h @@ -0,0 +1,18 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef LITERT_BUILD_COMMON_BUILD_CONFIG_H_ +#define LITERT_BUILD_COMMON_BUILD_CONFIG_H_ + +#endif // LITERT_BUILD_COMMON_BUILD_CONFIG_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/build_common/config/build_config_cpu_only.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/build_common/config/build_config_cpu_only.h new file mode 100644 index 0000000000000000000000000000000000000000..ff94302d10c70ad6290076260bd4647339b73e3a --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/build_common/config/build_config_cpu_only.h @@ -0,0 +1,21 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef LITERT_BUILD_COMMON_BUILD_CONFIG_H_ +#define LITERT_BUILD_COMMON_BUILD_CONFIG_H_ + +#define LITERT_DISABLE_GPU +#define LITERT_DISABLE_NPU + +#endif // LITERT_BUILD_COMMON_BUILD_CONFIG_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/build_common/config/build_config_gpu.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/build_common/config/build_config_gpu.h new file mode 100644 index 0000000000000000000000000000000000000000..ab201cc19aa9e887928bb6b0a02a188bfc32de0a --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/build_common/config/build_config_gpu.h @@ -0,0 +1,20 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef LITERT_BUILD_COMMON_BUILD_CONFIG_H_ +#define LITERT_BUILD_COMMON_BUILD_CONFIG_H_ + +#define LITERT_DISABLE_NPU + +#endif // LITERT_BUILD_COMMON_BUILD_CONFIG_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/build_common/config/build_config_gpu_npu.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/build_common/config/build_config_gpu_npu.h new file mode 100644 index 0000000000000000000000000000000000000000..0c513fcc51e4a091715006acba0d57da55cead5b --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/build_common/config/build_config_gpu_npu.h @@ -0,0 +1,18 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef LITERT_BUILD_COMMON_BUILD_CONFIG_H_ +#define LITERT_BUILD_COMMON_BUILD_CONFIG_H_ + +#endif // LITERT_BUILD_COMMON_BUILD_CONFIG_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/build_common/config/build_config_npu.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/build_common/config/build_config_npu.h new file mode 100644 index 0000000000000000000000000000000000000000..6be37573b9b1dc89b0eeeee829994a62b72d7b46 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/build_common/config/build_config_npu.h @@ -0,0 +1,20 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef LITERT_BUILD_COMMON_BUILD_CONFIG_H_ +#define LITERT_BUILD_COMMON_BUILD_CONFIG_H_ + +#define LITERT_DISABLE_GPU + +#endif // LITERT_BUILD_COMMON_BUILD_CONFIG_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_abi_header.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_abi_header.h new file mode 100644 index 0000000000000000000000000000000000000000..f839ca98e19b808535a8067b201ee0671b145053 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_abi_header.h @@ -0,0 +1,79 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_ABI_HEADER_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_ABI_HEADER_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Header containing ABI version and size metadata. + * + * Must be the first member of any ABI-stable struct. + * Size: 8 bytes. Padding: 0 bytes (on 64-bit systems). + */ +typedef struct LiteRtAbiHeader { + // The physical size of the parent structure (including this header). + // Supports struct sizes up to 64KB, which is safe for C API tables. + uint16_t struct_size; + + // Bumped when introducing breaking changes or a completely new struct layout. + uint16_t major_version; + + // Bumped when adding new methods (appended) or deprecating existing ones. + uint16_t minor_version; + + // Reserved for future use (e.g., flags or compatibility metadata). + uint16_t reserved; +} LiteRtAbiHeader; + +/** + * @brief Checks if the provider's ABI version is compatible with the consumer's + * requirements. + * + * @param instance_ptr Pointer to the struct instance (e.g., + * LiteRtRuntimeContext). + * @param req_major The major version required by the consumer. + * @param req_minor The minimum minor version required by the consumer. + */ +#define LITERT_ABI_IS_COMPATIBLE(instance_ptr, req_major, req_minor) \ + ((instance_ptr)->abi_header.major_version == (req_major) && \ + (instance_ptr)->abi_header.minor_version >= (req_minor)) + +/** + * @brief Safely verifies that an API member is version-compatible, physically + * present in memory, and implemented (non-null). + * + * @param instance_ptr Pointer to the ABI-versioned struct instance. + * @param req_major The expected major version of the struct layout. + * @param api_member The name of the function pointer / member to check. + */ +#define LITERT_ABI_HAS_API(instance_ptr, req_major, api_member) \ + ((instance_ptr) != nullptr && \ + (instance_ptr)->abi_header.major_version == (req_major) && \ + (instance_ptr)->abi_header.struct_size >= \ + ((const char*)(&(instance_ptr)->api_member) + \ + sizeof((instance_ptr)->api_member) - (const char*)(instance_ptr)) && \ + (instance_ptr)->api_member != nullptr) + +#ifdef __cplusplus +} +#endif + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_ABI_HEADER_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_accelerator.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_accelerator.h new file mode 100644 index 0000000000000000000000000000000000000000..55e883217ac4f1db00a1c3570453c2c045539e8c --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_accelerator.h @@ -0,0 +1,79 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_INTERNAL_ACCELERATOR_H_ +#define ODML_LITERT_LITERT_C_LITERT_INTERNAL_ACCELERATOR_H_ + +#include +#include +#include + +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef size_t LiteRtAcceleratorId; + +// Gets the number of accelerators registered to LiteRT. +LiteRtStatus LiteRtGetNumAccelerators(LiteRtEnvironment environment, + LiteRtParamIndex* num_accelerators); + +// Gets the accelerator at given index that is registered to LiteRT. +LiteRtStatus LiteRtGetAccelerator(LiteRtEnvironment environment, + LiteRtParamIndex index, + LiteRtAccelerator* accelerator); + +// Fetches the name of the accelerator. +// +// Note: client code does not need to manage the `name` lifetime. +LiteRtStatus LiteRtGetAcceleratorName(LiteRtAcceleratorConst accelerator, + char const** name); + +// Fetches the accelerator identifier. +// +// The identifier is a runtime unique number, provided by the registrar to the +// accelerator upon registration. +LiteRtStatus LiteRtGetAcceleratorId(LiteRtAcceleratorConst accelerator, + LiteRtAcceleratorId* id); + +// Fetches the version of the accelerator implementation. +// +// Note: This is NOT the LiteRT version. It's the accelerator specific software +// implementation version. +LiteRtStatus LiteRtGetAcceleratorVersion(LiteRtAcceleratorConst accelerator, + LiteRtApiVersion* version); + +// Fetches the accelerator hardware. +// +// `supported_hardware` is a bitfield of `LiteRtHwAccelerators` values. +LiteRtStatus LiteRtGetAcceleratorHardwareSupport( + LiteRtAcceleratorConst accelerator, + LiteRtHwAcceleratorSet* supported_hardware); + +// Fetches the accelerator environment. +// +LiteRtStatus LiteRtGetAcceleratorEnvironment(LiteRtAcceleratorConst accelerator, + LiteRtEnvironment* environment); + +// Returns whether the accelerator TFLite delegate does some JIT compilation. +LiteRtStatus LiteRtIsAcceleratorDelegateResponsibleForJitCompilation( + LiteRtAcceleratorConst accelerator, bool* does_jit_compilation); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // ODML_LITERT_LITERT_C_LITERT_INTERNAL_ACCELERATOR_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_accelerator_def.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_accelerator_def.h new file mode 100644 index 0000000000000000000000000000000000000000..e408582afbea03e05c9eae116beeb9198f907f5d --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_accelerator_def.h @@ -0,0 +1,106 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_ACCELERATOR_DEF_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_ACCELERATOR_DEF_H_ + +#include + +#include "litert/c/internal/litert_abi_header.h" +#include "litert/c/internal/litert_custom_tensor_buffer_handlers_def.h" +#include "litert/c/internal/litert_runtime_context.h" +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// The version of the LiteRT accelerator definition. +// This version is used to ensure the ABI compatibility of the accelerator +// definition. Any changes to the LiteRtAcceleratorDef struct and HwMemoryInfo +// struct should be accompanied by an update to this version. +#define LITERT_ACCELERATOR_DEF_CURRENT_VERSION 1 + +// A struct that contains the data and functions that are used to define an +// accelerator. Refer litert_accelerator_registration.h for more details. +// +// Note: This struct is shared with LiteRT runtime and Accelerators. So it must +// be ABI stable. +typedef struct { + LiteRtAbiHeader abi_header; + + LiteRtStatus (*get_name)(LiteRtAcceleratorConst accelerator, + const char** name); + LiteRtStatus (*get_version)(LiteRtAcceleratorConst accelerator, + LiteRtApiVersion* version); + LiteRtStatus (*get_hardware_support)( + LiteRtAcceleratorConst accelerator, + LiteRtHwAcceleratorSet* supported_hardware); + LiteRtStatus (*is_tflite_delegate_responsible_for_jit_compilation)( + LiteRtAcceleratorConst accelerator, bool* does_jit_compilation); + LiteRtStatus (*create_delegate)(LiteRtRuntimeContext* runtime_context, + LiteRtEnvironment env, + LiteRtAcceleratorConst accelerator, + LiteRtOptions options, + LiteRtDelegateWrapper* delegate_wrapper); + + LiteRtStatus (*start_metrics_collection)( + LiteRtRuntimeContext* runtime_context, LiteRtDelegateWrapper delegate, + int detail_level); + LiteRtStatus (*stop_metrics_collection)(LiteRtRuntimeContext* runtime_context, + LiteRtDelegateWrapper delegate, + LiteRtMetrics metrics); + + LiteRtCustomTensorBufferHandlersDef buffer_handlers; +} LiteRtAcceleratorDefV1; + +// ABI compatibility check for LiteRtAcceleratorDefV1. +// +// Note: Please get review from the LiteRT ABI compatibility team when you make +// changes to this struct. +#if defined(__cplusplus) && defined(__SIZEOF_POINTER__) && \ + __SIZEOF_POINTER__ == 8 +static_assert(sizeof(LiteRtAcceleratorDefV1) == 200, + "LiteRtAcceleratorDefV1 size mismatch"); +static_assert(offsetof(LiteRtAcceleratorDefV1, abi_header) == 0, + "LiteRtAcceleratorDefV1 abi_header offset mismatch"); +static_assert(offsetof(LiteRtAcceleratorDefV1, get_name) == 8, + "LiteRtAcceleratorDefV1 get_name offset mismatch"); +static_assert(offsetof(LiteRtAcceleratorDefV1, get_version) == 16, + "LiteRtAcceleratorDefV1 get_version offset mismatch"); +static_assert(offsetof(LiteRtAcceleratorDefV1, get_hardware_support) == 24, + "LiteRtAcceleratorDefV1 get_hardware_support offset mismatch"); +static_assert( + offsetof(LiteRtAcceleratorDefV1, + is_tflite_delegate_responsible_for_jit_compilation) == 32, + "LiteRtAcceleratorDefV1 is_tflite_delegate_responsible_for_jit_compilation " + "offset mismatch"); +static_assert(offsetof(LiteRtAcceleratorDefV1, create_delegate) == 40, + "LiteRtAcceleratorDefV1 create_delegate offset mismatch"); +static_assert( + offsetof(LiteRtAcceleratorDefV1, start_metrics_collection) == 48, + "LiteRtAcceleratorDefV1 start_metrics_collection offset mismatch"); +static_assert(offsetof(LiteRtAcceleratorDefV1, stop_metrics_collection) == 56, + "LiteRtAcceleratorDefV1 stop_metrics_collection offset mismatch"); +static_assert(offsetof(LiteRtAcceleratorDefV1, buffer_handlers) == 64, + "LiteRtAcceleratorDefV1 buffer_handlers offset mismatch"); +#endif // __cplusplus + +typedef LiteRtAcceleratorDefV1 LiteRtAcceleratorDef; + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_ACCELERATOR_DEF_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_accelerator_registration.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_accelerator_registration.h new file mode 100644 index 0000000000000000000000000000000000000000..1184da18d398c30160aba81dc30c5f3afa38b547 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_accelerator_registration.h @@ -0,0 +1,124 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_INTERNAL_ACCELERATOR_REGISTRATION_H_ +#define ODML_LITERT_LITERT_C_LITERT_INTERNAL_ACCELERATOR_REGISTRATION_H_ + +#include // NOLINT + +#include "litert/c/litert_common.h" +#include "litert/c/litert_profiler_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct LiteRtRuntimeContext LiteRtRuntimeContext; + +// Creates an empty accelerator handle. +LiteRtStatus LiteRtCreateAccelerator(LiteRtAccelerator* accelerator); + +// Destroys an accelerator handle. +// +// Warning: This SHOULD NOT BE CALLED after a call to +// `LiteRtRegisterAccelerator`. +LiteRtStatus LiteRtDestroyAccelerator(LiteRtAccelerator accelerator); + +// Sets the registration data AND clean-up function, then registers the +// accelerator with the LiteRT environment. +// +// - `data` and `ReleaseData` may be null. +// +// Note: After this function returns successfully, `data` is managed by the +// LiteRT environment. `ReleaseData` is called to release its memory. +// +// Warning: In case of failure, `accelerator` is released and `data` is released +// using `ReleaseData`. +LiteRtStatus LiteRtRegisterAccelerator(LiteRtEnvironment environment, + LiteRtAccelerator accelerator, + void* data, void (*ReleaseData)(void*)); + +// Sets the function used to retrieve the accelerator name. +LiteRtStatus LiteRtSetAcceleratorGetName( + LiteRtAccelerator accelerator, + LiteRtStatus (*GetName)(LiteRtAcceleratorConst accelerator, + const char** name)); + +// Sets the function used to retrieve the accelerator implementation version. +// +// Note: This is NOT the LiteRT version. It's the accelerator specific software +// implementation version. +LiteRtStatus LiteRtSetAcceleratorGetVersion( + LiteRtAccelerator accelerator, + LiteRtStatus (*GetVersion)(LiteRtAcceleratorConst accelerator, + LiteRtApiVersion* version)); + +// Sets the function used to retrieve the accelerator hardware support. +LiteRtStatus LiteRtSetAcceleratorGetHardwareSupport( + LiteRtAccelerator accelerator, + LiteRtStatus (*GetHardwareSupport)( + LiteRtAcceleratorConst accelerator, + LiteRtHwAcceleratorSet* supported_hardware)); + +// Sets the function used to return a Delegate to apply the accelerator by the +// compiled model and its destructor. The returned Delegate object is owned by +// the compiled model. +LiteRtStatus LiteRtSetDelegateFunction( + LiteRtAccelerator accelerator, + LiteRtStatus (*CreateDelegate)(LiteRtRuntimeContext* runtime_context, + LiteRtEnvironment env, + LiteRtAcceleratorConst accelerator, + LiteRtOptions options, + LiteRtDelegateWrapper* delegate)); + +// Sets the function used to surface whether the delegate created by the +// accelerator does JIT compilation or not. +// +// This affects whether the compiled model creation will apply the accelerator +// without an explicit request in the JIT compilation options. +// +// If this isn't set, the result will be treated as `false`. +LiteRtStatus LiteRtSetIsAcceleratorDelegateResponsibleForJitCompilation( + LiteRtAccelerator accelerator, + LiteRtStatus (*IsTfLiteDelegateResponsibleForJitCompilation)( + LiteRtAcceleratorConst accelerator, bool* does_jit_compilation)); + +// Sets the function used to start collection of HW-specific metrics at a +// specific level of detail (>= 0). +LiteRtStatus LiteRtSetAcceleratorStartMetricsCollection( + LiteRtAccelerator accelerator, + LiteRtStatus (*StartMetricsCollection)( + LiteRtRuntimeContext* runtime_context, LiteRtDelegateWrapper delegate, + int detail_level)); + +// Sets the function used to stop collection of HW-specific metrics and report +// the collected metrics. +LiteRtStatus LiteRtSetAcceleratorStopMetricsCollection( + LiteRtAccelerator accelerator, + LiteRtStatus (*StopMetricsCollection)(LiteRtRuntimeContext* runtime_context, + LiteRtDelegateWrapper delegate, + LiteRtMetrics metrics)); + +// Sets the function used to retrieve the native vendor hooks. +LiteRtStatus LiteRtSetAcceleratorGetHooks( + LiteRtAccelerator accelerator, + LiteRtStatus (*GetHooks)(LiteRtRuntimeContext* runtime_context, + LiteRtDelegateWrapper delegate, LiteRtHook* hook, + void** user_data)); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // ODML_LITERT_LITERT_C_LITERT_INTERNAL_ACCELERATOR_REGISTRATION_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_compiler_context.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_compiler_context.h new file mode 100644 index 0000000000000000000000000000000000000000..90606127d4d6dd903249a1c47744e43a775f7c49 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_compiler_context.h @@ -0,0 +1,1153 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_COMPILER_CONTEXT_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_COMPILER_CONTEXT_H_ + +#include +#include + +#include + +#include "litert/c/internal/litert_abi_header.h" +#include "litert/c/litert_any.h" +#include "litert/c/litert_common.h" +#include "litert/c/litert_environment_options.h" +#include "litert/c/litert_model_types.h" +#include "litert/c/litert_op_code.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// A function table that contains LiteRT C APIs needed for Compiler Plugins. +/// +/// @note This struct is shared with LiteRT runtime and Compiler Plugins. So it +/// must be ABI stable. +// LINT.IfChange(compiler_context_table) +typedef struct LiteRtCompilerContext { + LiteRtAbiHeader abi_header; + + // Model inspection + LiteRtStatus (*get_num_model_subgraphs)(LiteRtModel model, + LiteRtParamIndex* num_subgraphs); + LiteRtStatus (*get_model_subgraph)(LiteRtModel model, + LiteRtParamIndex subgraph_index, + LiteRtSubgraph* subgraph); + + // Subgraph inspection + LiteRtStatus (*get_num_subgraph_ops)(LiteRtSubgraph subgraph, + LiteRtParamIndex* num_ops); + LiteRtStatus (*get_subgraph_op)(LiteRtSubgraph subgraph, + LiteRtParamIndex op_index, LiteRtOp* op); + LiteRtStatus (*get_num_subgraph_inputs)(LiteRtSubgraph subgraph, + LiteRtParamIndex* num_inputs); + LiteRtStatus (*get_subgraph_input)(LiteRtSubgraph subgraph, + LiteRtParamIndex input_index, + LiteRtTensor* input); + LiteRtStatus (*get_num_subgraph_outputs)(LiteRtSubgraph subgraph, + LiteRtParamIndex* num_outputs); + LiteRtStatus (*get_subgraph_output)(LiteRtSubgraph subgraph, + LiteRtParamIndex output_index, + LiteRtTensor* output); + + // Op inspection + LiteRtStatus (*get_op_code)(LiteRtOp op, LiteRtOpCode* code); + LiteRtStatus (*get_custom_code)(LiteRtOp op, const char** code); + LiteRtStatus (*get_num_op_inputs)(LiteRtOp op, LiteRtParamIndex* num_inputs); + LiteRtStatus (*get_op_input)(LiteRtOp op, LiteRtParamIndex input_index, + LiteRtTensor* input); + LiteRtStatus (*get_num_op_outputs)(LiteRtOp op, + LiteRtParamIndex* num_outputs); + LiteRtStatus (*get_op_output)(LiteRtOp op, LiteRtParamIndex output_index, + LiteRtTensor* output); + + // Tensor inspection + LiteRtStatus (*get_tensor_name)(LiteRtTensor tensor, const char** name); + LiteRtStatus (*get_tensor_index)(LiteRtTensor tensor, uint32_t* tensor_index); + LiteRtStatus (*get_tensor_type_id)(LiteRtTensor tensor, + LiteRtTensorTypeId* type_id); + LiteRtStatus (*get_ranked_tensor_type)( + LiteRtTensor tensor, LiteRtRankedTensorType* ranked_tensor_type); + LiteRtStatus (*get_unranked_tensor_type)( + LiteRtTensor tensor, LiteRtUnrankedTensorType* unranked_tensor_type); + LiteRtStatus (*get_quantization_type_id)(LiteRtTensor tensor, + LiteRtQuantizationTypeId* q_type_id); + LiteRtStatus (*get_per_tensor_quantization)( + LiteRtTensor tensor, + LiteRtQuantizationPerTensor* per_tensor_quantization); + LiteRtStatus (*get_per_channel_quantization)( + LiteRtTensor tensor, + LiteRtQuantizationPerChannel* per_channel_quantization); + LiteRtStatus (*get_num_tensor_uses)(LiteRtTensor tensor, + LiteRtParamIndex* num_uses); + LiteRtStatus (*get_tensor_use)(LiteRtTensor tensor, + LiteRtParamIndex use_index, LiteRtOp* user, + LiteRtParamIndex* user_arg_index); + LiteRtStatus (*get_tensor_defining_op)(LiteRtTensor tensor, + bool* has_defining_op, + LiteRtTensorDefiningOp* defining_op); + + // Weights + LiteRtStatus (*get_tensor_weights)(LiteRtTensor tensor, + LiteRtWeights* weights); + LiteRtStatus (*get_weights_buffer_id)(LiteRtWeights weights, + int32_t* buffer_id); + LiteRtStatus (*get_weights_bytes)(LiteRtWeights weights, const void** addr, + size_t* size); + + // Op options + LiteRtStatus (*get_shlo_composite_op_name)(LiteRtOp op, const char** name); + LiteRtStatus (*get_shlo_composite_op_decomposition_subgraph_index)( + LiteRtOp op, int32_t* decomposition_subgraph_index); + LiteRtStatus (*get_shlo_composite_op_attributes)(LiteRtOp op, + const uint8_t** attributes, + int32_t* attributes_size); + LiteRtStatus (*get_shlo_composite_op_version)(LiteRtOp op, int32_t* version); + + // Utility + LiteRtStatus (*push_op)(LiteRtOpList op_list, LiteRtOp op, + LiteRtParamIndex partition_index); + + // Options + LiteRtStatus (*get_opaque_options)(LiteRtOptions options, + LiteRtOpaqueOptions* opaque_options); + LiteRtStatus (*find_opaque_options_data)(LiteRtOpaqueOptions options, + const char* payload_identifier, + void** payload_data); + void (*destroy_options)(LiteRtOptions options); + + // Environment options + LiteRtStatus (*get_environment_options_value)( + LiteRtEnvironmentOptions options, LiteRtEnvOptionTag tag, + LiteRtAny* value); + + // StridedSlice options + LiteRtStatus (*get_strided_slice_begin_mask_option)(LiteRtOp op, + int32_t* begin_mask); + LiteRtStatus (*get_strided_slice_end_mask_option)(LiteRtOp op, + int32_t* end_mask); + LiteRtStatus (*get_strided_slice_shrink_axis_mask_option)( + LiteRtOp op, int32_t* shrink_axis_mask); + LiteRtStatus (*get_strided_slice_ellipsis_mask_option)( + LiteRtOp op, int32_t* ellipsis_mask); + LiteRtStatus (*get_strided_slice_new_axis_mask_option)( + LiteRtOp op, int32_t* new_axis_mask); + LiteRtStatus (*get_strided_slice_offset_option)(LiteRtOp op, bool* offset); + + // Sub options + LiteRtStatus (*get_sub_fused_activation_option)(LiteRtOp op, + uint32_t* fused_activation); + + // Sum options + LiteRtStatus (*get_sum_keep_dims_option)(LiteRtOp op, bool* keepdims); + + // Conv2d options + LiteRtStatus (*get_conv_2d_padding_option)(LiteRtOp op, uint32_t* padding); + LiteRtStatus (*get_conv_2d_stride_w_option)(LiteRtOp op, int32_t* stride_w); + LiteRtStatus (*get_conv_2d_stride_h_option)(LiteRtOp op, int32_t* stride_h); + LiteRtStatus (*get_conv_2d_fused_activation_option)( + LiteRtOp op, uint32_t* fused_activation_function); + LiteRtStatus (*get_conv_2d_dilation_w_option)(LiteRtOp op, + int32_t* dilation_w_factor); + LiteRtStatus (*get_conv_2d_dilation_h_option)(LiteRtOp op, + int32_t* dilation_h_factor); + + // DepthwiseConv2d options + LiteRtStatus (*get_depthwise_conv_2d_padding_option)(LiteRtOp op, + uint32_t* padding); + LiteRtStatus (*get_depthwise_conv_2d_stride_w_option)(LiteRtOp op, + int32_t* stride_w); + LiteRtStatus (*get_depthwise_conv_2d_stride_h_option)(LiteRtOp op, + int32_t* stride_h); + LiteRtStatus (*get_depthwise_conv_2d_depth_multiplier_option)( + LiteRtOp op, int32_t* depth_multiplier); + LiteRtStatus (*get_depthwise_conv_2d_fused_activation_option)( + LiteRtOp op, uint32_t* fused_activation_function); + LiteRtStatus (*get_depthwise_conv_2d_dilation_w_option)( + LiteRtOp op, int32_t* dilation_w_factor); + LiteRtStatus (*get_depthwise_conv_2d_dilation_h_option)( + LiteRtOp op, int32_t* dilation_h_factor); + + // TransposeConv options + LiteRtStatus (*get_transpose_conv_padding_option)(LiteRtOp op, + uint32_t* padding); + LiteRtStatus (*get_transpose_conv_stride_w_option)(LiteRtOp op, + int32_t* stride_w); + LiteRtStatus (*get_transpose_conv_stride_h_option)(LiteRtOp op, + int32_t* stride_h); + LiteRtStatus (*get_transpose_conv_fused_activation_option)( + LiteRtOp op, uint32_t* fused_activation_function); + + // Add options + LiteRtStatus (*get_add_fused_activation_option)(LiteRtOp op, + uint32_t* fused_activation); + + // Mul options + LiteRtStatus (*get_mul_fused_activation_option)(LiteRtOp op, + uint32_t* fused_activation); + + // Div options + LiteRtStatus (*get_div_fused_activation_option)(LiteRtOp op, + uint32_t* fused_activation); + + // FullyConnected options + LiteRtStatus (*get_fully_connected_fused_activation_option)( + LiteRtOp op, uint32_t* fused_activation); + LiteRtStatus (*get_fully_connected_weights_format_option)( + LiteRtOp op, uint32_t* weights_format); + LiteRtStatus (*get_fully_connected_keep_num_dims_option)(LiteRtOp op, + bool* keep_num_dims); + LiteRtStatus (*get_fully_connected_quantized_bias_type_option)( + LiteRtOp op, uint32_t* quantized_bias_type); + LiteRtStatus (*get_fully_connected_asymmetric_quantize_input_option)( + LiteRtOp op, bool* asymmetric_quantize_input); + + // Softmax options + LiteRtStatus (*get_softmax_beta_option)(LiteRtOp op, float* beta); + + // Concatenation options + LiteRtStatus (*get_concatenation_axis_option)(LiteRtOp op, int32_t* axis); + LiteRtStatus (*get_concatenation_fused_activation_option)( + LiteRtOp op, uint32_t* fused_activation); + + // Split options + LiteRtStatus (*get_split_num_splits_option)(LiteRtOp op, int32_t* num_splits); + + // Mean options + LiteRtStatus (*get_mean_keep_dims_option)(LiteRtOp op, bool* keepdims); + + // ReduceMax options + LiteRtStatus (*get_reduce_max_keep_dims_option)(LiteRtOp op, bool* keepdims); + + // ResizeBilinear options + LiteRtStatus (*get_resize_bilinear_align_corners_option)(LiteRtOp op, + bool* align_corners); + LiteRtStatus (*get_resize_bilinear_half_pixel_center_option)( + LiteRtOp op, bool* half_pixel_centers); + + // ResizeNearestNeighbor options + LiteRtStatus (*get_resize_nearest_neighbor_align_corners_option)( + LiteRtOp op, bool* align_corners); + LiteRtStatus (*get_resize_nearest_neighbor_half_pixel_center_option)( + LiteRtOp op, bool* half_pixel_centers); + + // BatchMatmul options + LiteRtStatus (*get_batch_matmul_adj_x_option)(LiteRtOp op, bool* adj_x); + LiteRtStatus (*get_batch_matmul_adj_y_option)(LiteRtOp op, bool* adj_y); + LiteRtStatus (*get_batch_matmul_asymmetric_quantize_input_option)( + LiteRtOp op, bool* asymmetric_quantize_input); + + // AveragePool2d options + LiteRtStatus (*get_average_pool_2d_padding_option)(LiteRtOp op, + uint32_t* padding); + LiteRtStatus (*get_average_pool_2d_stride_w_option)(LiteRtOp op, + int32_t* stride_w); + LiteRtStatus (*get_average_pool_2d_stride_h_option)(LiteRtOp op, + int32_t* stride_h); + LiteRtStatus (*get_average_pool_2d_filter_width_option)( + LiteRtOp op, int32_t* filter_width); + LiteRtStatus (*get_average_pool_2d_filter_height_option)( + LiteRtOp op, int32_t* filter_height); + LiteRtStatus (*get_average_pool_2d_fused_activation_option)( + LiteRtOp op, uint32_t* fused_activation); + + // MaxPool2d options + LiteRtStatus (*get_max_pool_2d_padding_option)(LiteRtOp op, + uint32_t* padding); + LiteRtStatus (*get_max_pool_2d_stride_w_option)(LiteRtOp op, + int32_t* stride_w); + LiteRtStatus (*get_max_pool_2d_stride_h_option)(LiteRtOp op, + int32_t* stride_h); + LiteRtStatus (*get_max_pool_2d_filter_width_option)(LiteRtOp op, + int32_t* filter_width); + LiteRtStatus (*get_max_pool_2d_filter_height_option)(LiteRtOp op, + int32_t* filter_height); + LiteRtStatus (*get_max_pool_2d_fused_activation_option)( + LiteRtOp op, uint32_t* fused_activation); + + // LeakyRelu options + LiteRtStatus (*get_leaky_relu_alpha_option)(LiteRtOp op, float* alpha); + + // Reshape options + LiteRtStatus (*get_reshape_new_shape_option)(LiteRtOp op, + const int32_t** new_shape, + int32_t* new_shape_size); + + // ReduceMin options + LiteRtStatus (*get_reduce_min_keep_dims_option)(LiteRtOp op, bool* keepdims); + + // ReduceAny options + LiteRtStatus (*get_reduce_any_keep_dims_option)(LiteRtOp op, bool* keepdims); + + // ReduceAll options + LiteRtStatus (*get_reduce_all_keep_dims_option)(LiteRtOp op, bool* keepdims); + + // Pack options + LiteRtStatus (*get_pack_axis_option)(LiteRtOp op, int32_t* axis); + LiteRtStatus (*get_pack_values_count_option)(LiteRtOp op, + int32_t* values_count); + + // OneHot options + LiteRtStatus (*get_one_hot_axis_option)(LiteRtOp op, int32_t* axis); + + // Unpack options + LiteRtStatus (*get_unpack_axis_option)(LiteRtOp op, int32_t* axis); + LiteRtStatus (*get_unpack_num_option)(LiteRtOp op, int32_t* num); + + // Gather options + LiteRtStatus (*get_gather_axis_option)(LiteRtOp op, int32_t* axis); + LiteRtStatus (*get_gather_batch_dims_option)(LiteRtOp op, + int32_t* batch_dims); + + // Conv3d options + LiteRtStatus (*get_conv_3d_padding_option)(LiteRtOp op, uint32_t* padding); + LiteRtStatus (*get_conv_3d_stride_d_option)(LiteRtOp op, int32_t* stride_d); + LiteRtStatus (*get_conv_3d_stride_w_option)(LiteRtOp op, int32_t* stride_w); + LiteRtStatus (*get_conv_3d_stride_h_option)(LiteRtOp op, int32_t* stride_h); + LiteRtStatus (*get_conv_3d_fused_activation_option)( + LiteRtOp op, uint32_t* fused_activation_function); + LiteRtStatus (*get_conv_3d_dilation_d_option)(LiteRtOp op, + int32_t* dilation_d_factor); + LiteRtStatus (*get_conv_3d_dilation_w_option)(LiteRtOp op, + int32_t* dilation_w_factor); + LiteRtStatus (*get_conv_3d_dilation_h_option)(LiteRtOp op, + int32_t* dilation_h_factor); + + // L2Pool2d options + LiteRtStatus (*get_l2_pool_2d_padding_option)(LiteRtOp op, uint32_t* padding); + LiteRtStatus (*get_l2_pool_2d_stride_w_option)(LiteRtOp op, + int32_t* stride_w); + LiteRtStatus (*get_l2_pool_2d_stride_h_option)(LiteRtOp op, + int32_t* stride_h); + LiteRtStatus (*get_l2_pool_2d_filter_width_option)(LiteRtOp op, + int32_t* filter_width); + LiteRtStatus (*get_l2_pool_2d_filter_height_option)(LiteRtOp op, + int32_t* filter_height); + LiteRtStatus (*get_l2_pool_2d_fused_activation_option)( + LiteRtOp op, uint32_t* fused_activation_function); + + // DepthToSpace options + LiteRtStatus (*get_depth_to_space_block_size_option)(LiteRtOp op, + int32_t* block_size); + + // SpaceToDepth options + LiteRtStatus (*get_space_to_depth_block_size_option)(LiteRtOp op, + int32_t* block_size); + + // CumSum options + LiteRtStatus (*get_cumsum_exclusive_option)(LiteRtOp op, bool* exclusive); + LiteRtStatus (*get_cumsum_reverse_option)(LiteRtOp op, bool* reverse); + + // Gelu options + LiteRtStatus (*get_gelu_approximate_option)(LiteRtOp op, bool* approximate); + + // MirrorPad options + LiteRtStatus (*get_mirror_pad_mode_option)(LiteRtOp op, uint32_t* mode); + + // Squeeze options + LiteRtStatus (*get_squeeze_dims_option)(LiteRtOp op, + const int32_t** squeeze_dims, + int32_t* num_squeeze_dims); + + // Op inspection + LiteRtStatus (*get_custom_options)(LiteRtOp op, + const uint8_t** custom_options, + int32_t* custom_options_size); + + LiteRtStatus (*serialize_model_with_signatures)( + LiteRtModel model, uint8_t** buf, size_t* size, size_t* offset, + bool share_weights, char** signature_keys, size_t num_signatures, + LiteRtModelSerializationOptions options); + + // Added in version 1.1.0 + // Builder (graph mutation) + LiteRtStatus (*build_tensor)( + LiteRtBuilder builder, LiteRtTensorTypeId tensor_type_id, + LiteRtRankedTensorType ranked_tensor_type, + LiteRtUnrankedTensorType unranked_tensor_type, LiteRtWeights weights, + LiteRtQuantizationTypeId quantization_type_id, + LiteRtQuantizationPerTensor per_tensor_quantization, + LiteRtQuantizationPerChannel per_channel_quantization, + LiteRtQuantizationBlockWise block_wise_quantization, const char* name, + LiteRtTensor* new_tensor); + LiteRtStatus (*build_weights)(LiteRtBuilder builder, const uint8_t* data, + LiteRtParamIndex size, LiteRtTensor tensor, + LiteRtWeights* new_weights); + LiteRtStatus (*build_op)(LiteRtBuilder builder, LiteRtOpCode op_code, + LiteRtParamIndex num_inputs, LiteRtTensor* inputs, + LiteRtParamIndex num_outputs, LiteRtTensor* outputs, + LiteRtOp* new_op); + LiteRtStatus (*erase_op)(LiteRtBuilder builder, LiteRtOp op_to_erase); + LiteRtStatus (*build_add_op_option)(LiteRtBuilder builder, LiteRtOp op, + uint32_t* fused_activation); + LiteRtStatus (*build_batch_matmul_op_option)(LiteRtBuilder builder, + LiteRtOp op, bool* adj_x, + bool* adj_y, + bool* asymmetric_quantize_input); + LiteRtStatus (*get_block_wise_quantization)( + LiteRtTensor tensor, + LiteRtQuantizationBlockWise* block_wise_quantization); + // Added in version 1.2.0 + LiteRtStatus (*build_shlo_composite_op_option)( + LiteRtBuilder builder, LiteRtOp op, const char* name, + const int32_t* decomposition_subgraph_index, const int32_t* version, + const uint8_t* attributes, LiteRtParamIndex attributes_size); + // Added in version 1.3.0 + LiteRtStatus (*build_average_pool_2d_op_option)( + LiteRtBuilder builder, LiteRtOp op, uint32_t* padding, int32_t* stride_w, + int32_t* stride_h, int32_t* filter_width, int32_t* filter_height, + uint32_t* fused_activation_function); + LiteRtStatus (*build_concatenation_op_option)(LiteRtBuilder builder, + LiteRtOp op, + uint32_t* fused_activation, + int32_t* axis); + LiteRtStatus (*build_conv_2d_op_option)(LiteRtBuilder builder, LiteRtOp op, + uint32_t* padding, int32_t* stride_w, + int32_t* stride_h, + int32_t* dilation_w_factor, + int32_t* dilation_h_factor, + uint32_t* fused_activation_function); + LiteRtStatus (*build_conv_3d_op_option)(LiteRtBuilder builder, LiteRtOp op, + uint32_t* padding, int32_t* stride_w, + int32_t* stride_h, int32_t* stride_d, + int32_t* dilation_w_factor, + int32_t* dilation_h_factor, + int32_t* dilation_d_factor, + uint32_t* fused_activation_function); + LiteRtStatus (*build_cumsum_op_option)(LiteRtBuilder builder, LiteRtOp op, + bool* exclusive, bool* reverse); + LiteRtStatus (*build_depth_to_space_op_option)(LiteRtBuilder builder, + LiteRtOp op, + int32_t* block_size); + LiteRtStatus (*build_depthwise_conv_2d_op_option)( + LiteRtBuilder builder, LiteRtOp op, uint32_t* padding, int32_t* stride_w, + int32_t* stride_h, int32_t* depth_multiplier, + uint32_t* fused_activation_function, int32_t* dilation_w_factor, + int32_t* dilation_h_factor); + LiteRtStatus (*build_div_op_option)(LiteRtBuilder builder, LiteRtOp op, + uint32_t* fused_activation); + LiteRtStatus (*build_fully_connected_op_option)( + LiteRtBuilder builder, LiteRtOp op, uint32_t* fused_activation, + uint32_t* weights_format, bool* keep_num_dims, + uint32_t* quantized_bias_type, bool* asymmetric_quantize_input); + LiteRtStatus (*build_gather_op_option)(LiteRtBuilder builder, LiteRtOp op, + int32_t* axis, int32_t* batch_dims); + LiteRtStatus (*build_gelu_op_option)(LiteRtBuilder builder, LiteRtOp op, + bool* approximate); + LiteRtStatus (*build_l2_pool_2d_op_option)( + LiteRtBuilder builder, LiteRtOp op, uint32_t* padding, int32_t* stride_w, + int32_t* stride_h, int32_t* filter_width, int32_t* filter_height, + uint32_t* fused_activation_function); + LiteRtStatus (*build_leaky_relu_op_option)(LiteRtBuilder builder, LiteRtOp op, + float* alpha); + LiteRtStatus (*build_max_pool_2d_op_option)( + LiteRtBuilder builder, LiteRtOp op, uint32_t* padding, int32_t* stride_w, + int32_t* stride_h, int32_t* filter_width, int32_t* filter_height, + uint32_t* fused_activation_function); + LiteRtStatus (*build_mean_op_option)(LiteRtBuilder builder, LiteRtOp op, + bool* keepdims); + LiteRtStatus (*build_mirror_pad_op_option)(LiteRtBuilder builder, LiteRtOp op, + uint32_t* mode); + LiteRtStatus (*build_mul_op_option)(LiteRtBuilder builder, LiteRtOp op, + uint32_t* fused_activation); + LiteRtStatus (*build_one_hot_op_option)(LiteRtBuilder builder, LiteRtOp op, + int32_t* axis); + LiteRtStatus (*build_pack_op_option)(LiteRtBuilder builder, LiteRtOp op, + int32_t* axis, int32_t* values_count); + LiteRtStatus (*build_reduce_all_op_option)(LiteRtBuilder builder, LiteRtOp op, + bool* keepdims); + LiteRtStatus (*build_reduce_any_op_option)(LiteRtBuilder builder, LiteRtOp op, + bool* keepdims); + LiteRtStatus (*build_reduce_max_op_option)(LiteRtBuilder builder, LiteRtOp op, + bool* keepdims); + LiteRtStatus (*build_reduce_min_op_option)(LiteRtBuilder builder, LiteRtOp op, + bool* keepdims); + LiteRtStatus (*build_reshape_op_option)(LiteRtBuilder builder, LiteRtOp op, + int32_t* new_shape, + int32_t new_shape_size); + LiteRtStatus (*build_resize_bilinear_op_option)(LiteRtBuilder builder, + LiteRtOp op, + bool* align_corners, + bool* half_pixel_centers); + LiteRtStatus (*build_resize_nearest_neighbor_op_option)( + LiteRtBuilder builder, LiteRtOp op, bool* align_corners, + bool* half_pixel_centers); + LiteRtStatus (*build_softmax_op_option)(LiteRtBuilder builder, LiteRtOp op, + float* beta); + LiteRtStatus (*build_space_to_depth_op_option)(LiteRtBuilder builder, + LiteRtOp op, + int32_t* block_size); + LiteRtStatus (*build_split_op_option)(LiteRtBuilder builder, LiteRtOp op, + int32_t* num_splits); + LiteRtStatus (*build_split_v_op_option)(LiteRtBuilder builder, LiteRtOp op, + int32_t* num_splits); + LiteRtStatus (*build_squeeze_op_option)(LiteRtBuilder builder, LiteRtOp op, + const int32_t* squeeze_dims, + int32_t num_squeeze_dims); + LiteRtStatus (*build_strided_slice_op_option)( + LiteRtBuilder builder, LiteRtOp op, int32_t* begin_mask, + int32_t* end_mask, int32_t* ellipsis_mask, int32_t* new_axis_mask, + int32_t* shrink_axis_mask, bool* offset); + LiteRtStatus (*build_sub_op_option)(LiteRtBuilder builder, LiteRtOp op, + uint32_t* fused_activation); + LiteRtStatus (*build_sum_op_option)(LiteRtBuilder builder, LiteRtOp op, + bool* keepdims); + LiteRtStatus (*build_transpose_conv_op_option)( + LiteRtBuilder builder, LiteRtOp op, uint32_t* padding, int32_t* stride_w, + int32_t* stride_h, uint32_t* fused_activation_function); + LiteRtStatus (*build_unpack_op_option)(LiteRtBuilder builder, LiteRtOp op, + int32_t* axis, int32_t* num); + LiteRtStatus (*get_split_v_num_splits_option)(LiteRtOp op, + int32_t* num_splits); +} LiteRtCompilerContext; +// LINT.ThenChange(./litert_compiler_context.cc:compiler_context_version) + +// ABI compatibility check for LiteRtCompilerContext. +// +// Note: Please get review from the LiteRT ABI compatibility team when you make +// changes to this struct. +#if defined(__cplusplus) && defined(__SIZEOF_POINTER__) && \ + __SIZEOF_POINTER__ == 8 +static_assert(sizeof(LiteRtCompilerContext) == 1408, + "LiteRtCompilerContext size mismatch"); +static_assert(offsetof(LiteRtCompilerContext, abi_header) == 0, + "LiteRtCompilerContext abi_header offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_num_model_subgraphs) == 8, + "LiteRtCompilerContext get_num_model_subgraphs offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_model_subgraph) == 16, + "LiteRtCompilerContext get_model_subgraph offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_num_subgraph_ops) == 24, + "LiteRtCompilerContext get_num_subgraph_ops offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_subgraph_op) == 32, + "LiteRtCompilerContext get_subgraph_op offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_num_subgraph_inputs) == 40, + "LiteRtCompilerContext get_num_subgraph_inputs offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_subgraph_input) == 48, + "LiteRtCompilerContext get_subgraph_input offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_num_subgraph_outputs) == 56, + "LiteRtCompilerContext get_num_subgraph_outputs offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_subgraph_output) == 64, + "LiteRtCompilerContext get_subgraph_output offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_op_code) == 72, + "LiteRtCompilerContext get_op_code offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_custom_code) == 80, + "LiteRtCompilerContext get_custom_code offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_num_op_inputs) == 88, + "LiteRtCompilerContext get_num_op_inputs offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_op_input) == 96, + "LiteRtCompilerContext get_op_input offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_num_op_outputs) == 104, + "LiteRtCompilerContext get_num_op_outputs offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_op_output) == 112, + "LiteRtCompilerContext get_op_output offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_tensor_name) == 120, + "LiteRtCompilerContext get_tensor_name offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_tensor_index) == 128, + "LiteRtCompilerContext get_tensor_index offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_tensor_type_id) == 136, + "LiteRtCompilerContext get_tensor_type_id offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_ranked_tensor_type) == 144, + "LiteRtCompilerContext get_ranked_tensor_type offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_unranked_tensor_type) == 152, + "LiteRtCompilerContext get_unranked_tensor_type offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_quantization_type_id) == 160, + "LiteRtCompilerContext get_quantization_type_id offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_per_tensor_quantization) == 168, + "LiteRtCompilerContext get_per_tensor_quantization offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_per_channel_quantization) == 176, + "LiteRtCompilerContext get_per_channel_quantization offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_num_tensor_uses) == 184, + "LiteRtCompilerContext get_num_tensor_uses offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_tensor_use) == 192, + "LiteRtCompilerContext get_tensor_use offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_tensor_defining_op) == 200, + "LiteRtCompilerContext get_tensor_defining_op offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_tensor_weights) == 208, + "LiteRtCompilerContext get_tensor_weights offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_weights_buffer_id) == 216, + "LiteRtCompilerContext get_weights_buffer_id offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_weights_bytes) == 224, + "LiteRtCompilerContext get_weights_bytes offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_shlo_composite_op_name) == 232, + "LiteRtCompilerContext get_shlo_composite_op_name offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, + get_shlo_composite_op_decomposition_subgraph_index) == 240, + "LiteRtCompilerContext get_shlo_composite_op_decomposition_subgraph_index " + "offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_shlo_composite_op_attributes) == 248, + "LiteRtCompilerContext get_shlo_composite_op_attributes offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_shlo_composite_op_version) == 256, + "LiteRtCompilerContext get_shlo_composite_op_version offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, push_op) == 264, + "LiteRtCompilerContext push_op offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_opaque_options) == 272, + "LiteRtCompilerContext get_opaque_options offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, find_opaque_options_data) == 280, + "LiteRtCompilerContext find_opaque_options_data offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, destroy_options) == 288, + "LiteRtCompilerContext destroy_options offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_environment_options_value) == 296, + "LiteRtCompilerContext get_environment_options_value offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_strided_slice_begin_mask_option) == 304, + "LiteRtCompilerContext get_strided_slice_begin_mask_option " + "offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_strided_slice_end_mask_option) == 312, + "LiteRtCompilerContext get_strided_slice_end_mask_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_strided_slice_shrink_axis_mask_option) == 320, + "LiteRtCompilerContext get_strided_slice_shrink_axis_mask_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_strided_slice_ellipsis_mask_option) == 328, + "LiteRtCompilerContext get_strided_slice_ellipsis_mask_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_strided_slice_new_axis_mask_option) == 336, + "LiteRtCompilerContext get_strided_slice_new_axis_mask_option " + "offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_strided_slice_offset_option) == 344, + "LiteRtCompilerContext get_strided_slice_offset_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_sub_fused_activation_option) == 352, + "LiteRtCompilerContext get_sub_fused_activation_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_sum_keep_dims_option) == 360, + "LiteRtCompilerContext get_sum_keep_dims_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_conv_2d_padding_option) == 368, + "LiteRtCompilerContext get_conv_2d_padding_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_conv_2d_stride_w_option) == 376, + "LiteRtCompilerContext get_conv_2d_stride_w_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_conv_2d_stride_h_option) == 384, + "LiteRtCompilerContext get_conv_2d_stride_h_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_conv_2d_fused_activation_option) == 392, + "LiteRtCompilerContext get_conv_2d_fused_activation_option " + "offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_conv_2d_dilation_w_option) == 400, + "LiteRtCompilerContext get_conv_2d_dilation_w_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_conv_2d_dilation_h_option) == 408, + "LiteRtCompilerContext get_conv_2d_dilation_h_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_depthwise_conv_2d_padding_option) == 416, + "LiteRtCompilerContext get_depthwise_conv_2d_padding_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_depthwise_conv_2d_stride_w_option) == 424, + "LiteRtCompilerContext get_depthwise_conv_2d_stride_w_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_depthwise_conv_2d_stride_h_option) == 432, + "LiteRtCompilerContext get_depthwise_conv_2d_stride_h_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_depthwise_conv_2d_depth_multiplier_option) == 440, + "LiteRtCompilerContext " + "get_depthwise_conv_2d_depth_multiplier_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_depthwise_conv_2d_fused_activation_option) == 448, + "LiteRtCompilerContext " + "get_depthwise_conv_2d_fused_activation_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_depthwise_conv_2d_dilation_w_option) == 456, + "LiteRtCompilerContext get_depthwise_conv_2d_dilation_w_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_depthwise_conv_2d_dilation_h_option) == 464, + "LiteRtCompilerContext get_depthwise_conv_2d_dilation_h_option " + "offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_transpose_conv_padding_option) == 472, + "LiteRtCompilerContext get_transpose_conv_padding_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_transpose_conv_stride_w_option) == 480, + "LiteRtCompilerContext get_transpose_conv_stride_w_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_transpose_conv_stride_h_option) == 488, + "LiteRtCompilerContext get_transpose_conv_stride_h_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_transpose_conv_fused_activation_option) == 496, + "LiteRtCompilerContext " + "get_transpose_conv_fused_activation_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_add_fused_activation_option) == 504, + "LiteRtCompilerContext get_add_fused_activation_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_mul_fused_activation_option) == 512, + "LiteRtCompilerContext get_mul_fused_activation_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_div_fused_activation_option) == 520, + "LiteRtCompilerContext get_div_fused_activation_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_fully_connected_fused_activation_option) == 528, + "LiteRtCompilerContext " + "get_fully_connected_fused_activation_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_fully_connected_weights_format_option) == 536, + "LiteRtCompilerContext get_fully_connected_weights_format_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_fully_connected_keep_num_dims_option) == 544, + "LiteRtCompilerContext get_fully_connected_keep_num_dims_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_fully_connected_quantized_bias_type_option) == 552, + "LiteRtCompilerContext " + "get_fully_connected_quantized_bias_type_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, + get_fully_connected_asymmetric_quantize_input_option) == 560, + "LiteRtCompilerContext " + "get_fully_connected_asymmetric_quantize_input_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_softmax_beta_option) == 568, + "LiteRtCompilerContext get_softmax_beta_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_concatenation_axis_option) == 576, + "LiteRtCompilerContext get_concatenation_axis_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_concatenation_fused_activation_option) == 584, + "LiteRtCompilerContext get_concatenation_fused_activation_option " + "offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_split_num_splits_option) == 592, + "LiteRtCompilerContext get_split_num_splits_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_mean_keep_dims_option) == 600, + "LiteRtCompilerContext get_mean_keep_dims_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_reduce_max_keep_dims_option) == 608, + "LiteRtCompilerContext get_reduce_max_keep_dims_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_resize_bilinear_align_corners_option) == 616, + "LiteRtCompilerContext get_resize_bilinear_align_corners_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_resize_bilinear_half_pixel_center_option) == 624, + "LiteRtCompilerContext " + "get_resize_bilinear_half_pixel_center_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, + get_resize_nearest_neighbor_align_corners_option) == 632, + "LiteRtCompilerContext get_resize_nearest_neighbor_align_corners_option " + "offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, + get_resize_nearest_neighbor_half_pixel_center_option) == 640, + "LiteRtCompilerContext " + "get_resize_nearest_neighbor_half_pixel_center_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_batch_matmul_adj_x_option) == 648, + "LiteRtCompilerContext get_batch_matmul_adj_x_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_batch_matmul_adj_y_option) == 656, + "LiteRtCompilerContext get_batch_matmul_adj_y_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, + get_batch_matmul_asymmetric_quantize_input_option) == 664, + "LiteRtCompilerContext get_batch_matmul_asymmetric_quantize_input_option " + "offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_average_pool_2d_padding_option) == 672, + "LiteRtCompilerContext get_average_pool_2d_padding_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_average_pool_2d_stride_w_option) == 680, + "LiteRtCompilerContext get_average_pool_2d_stride_w_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_average_pool_2d_stride_h_option) == 688, + "LiteRtCompilerContext get_average_pool_2d_stride_h_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_average_pool_2d_filter_width_option) == 696, + "LiteRtCompilerContext get_average_pool_2d_filter_width_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_average_pool_2d_filter_height_option) == 704, + "LiteRtCompilerContext get_average_pool_2d_filter_height_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_average_pool_2d_fused_activation_option) == 712, + "LiteRtCompilerContext " + "get_average_pool_2d_fused_activation_option offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, get_max_pool_2d_padding_option) == 720, + "LiteRtCompilerContext get_max_pool_2d_padding_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_max_pool_2d_stride_w_option) == 728, + "LiteRtCompilerContext get_max_pool_2d_stride_w_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_max_pool_2d_stride_h_option) == 736, + "LiteRtCompilerContext get_max_pool_2d_stride_h_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_max_pool_2d_filter_width_option) == 744, + "LiteRtCompilerContext get_max_pool_2d_filter_width_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_max_pool_2d_filter_height_option) == 752, + "LiteRtCompilerContext get_max_pool_2d_filter_height_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_max_pool_2d_fused_activation_option) == 760, + "LiteRtCompilerContext get_max_pool_2d_fused_activation_option " + "offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, get_leaky_relu_alpha_option) == 768, + "LiteRtCompilerContext get_leaky_relu_alpha_option offset mismatch"); + +static_assert(offsetof(LiteRtCompilerContext, + get_fully_connected_keep_num_dims_option) == 544, + "LiteRtCompilerContext get_fully_connected_keep_num_dims_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_fully_connected_quantized_bias_type_option) == 552, + "LiteRtCompilerContext " + "get_fully_connected_quantized_bias_type_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, + get_fully_connected_asymmetric_quantize_input_option) == 560, + "LiteRtCompilerContext " + "get_fully_connected_asymmetric_quantize_input_option offset mismatch"); + +static_assert(offsetof(LiteRtCompilerContext, get_softmax_beta_option) == 568, + "LiteRtCompilerContext get_softmax_beta_option offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, get_concatenation_axis_option) == 576, + "LiteRtCompilerContext get_concatenation_axis_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_concatenation_fused_activation_option) == 584, + "LiteRtCompilerContext get_concatenation_fused_activation_option " + "offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, get_split_num_splits_option) == 592, + "LiteRtCompilerContext get_split_num_splits_option offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, get_mean_keep_dims_option) == 600, + "LiteRtCompilerContext get_mean_keep_dims_option offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, get_reduce_max_keep_dims_option) == 608, + "LiteRtCompilerContext get_reduce_max_keep_dims_option offset mismatch"); + +static_assert(offsetof(LiteRtCompilerContext, + get_resize_bilinear_align_corners_option) == 616, + "LiteRtCompilerContext get_resize_bilinear_align_corners_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_resize_bilinear_half_pixel_center_option) == 624, + "LiteRtCompilerContext " + "get_resize_bilinear_half_pixel_center_option offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, + get_resize_nearest_neighbor_align_corners_option) == 632, + "LiteRtCompilerContext get_resize_nearest_neighbor_align_corners_option " + "offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, + get_resize_nearest_neighbor_half_pixel_center_option) == 640, + "LiteRtCompilerContext " + "get_resize_nearest_neighbor_half_pixel_center_option offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, get_batch_matmul_adj_x_option) == 648, + "LiteRtCompilerContext get_batch_matmul_adj_x_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_batch_matmul_adj_y_option) == 656, + "LiteRtCompilerContext get_batch_matmul_adj_y_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, + get_batch_matmul_asymmetric_quantize_input_option) == 664, + "LiteRtCompilerContext get_batch_matmul_asymmetric_quantize_input_option " + "offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, get_average_pool_2d_padding_option) == 672, + "LiteRtCompilerContext get_average_pool_2d_padding_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_average_pool_2d_stride_w_option) == 680, + "LiteRtCompilerContext get_average_pool_2d_stride_w_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_average_pool_2d_stride_h_option) == 688, + "LiteRtCompilerContext get_average_pool_2d_stride_h_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_average_pool_2d_filter_width_option) == 696, + "LiteRtCompilerContext get_average_pool_2d_filter_width_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_average_pool_2d_filter_height_option) == 704, + "LiteRtCompilerContext get_average_pool_2d_filter_height_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_average_pool_2d_fused_activation_option) == 712, + "LiteRtCompilerContext " + "get_average_pool_2d_fused_activation_option offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, get_max_pool_2d_padding_option) == 720, + "LiteRtCompilerContext get_max_pool_2d_padding_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_max_pool_2d_stride_w_option) == 728, + "LiteRtCompilerContext get_max_pool_2d_stride_w_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_max_pool_2d_stride_h_option) == 736, + "LiteRtCompilerContext get_max_pool_2d_stride_h_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_max_pool_2d_filter_width_option) == 744, + "LiteRtCompilerContext get_max_pool_2d_filter_width_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_max_pool_2d_filter_height_option) == 752, + "LiteRtCompilerContext get_max_pool_2d_filter_height_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_max_pool_2d_fused_activation_option) == 760, + "LiteRtCompilerContext get_max_pool_2d_fused_activation_option " + "offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, get_leaky_relu_alpha_option) == 768, + "LiteRtCompilerContext get_leaky_relu_alpha_option offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, get_reshape_new_shape_option) == 776, + "LiteRtCompilerContext get_reshape_new_shape_option offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, get_reduce_min_keep_dims_option) == 784, + "LiteRtCompilerContext get_reduce_min_keep_dims_option offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, get_reduce_any_keep_dims_option) == 792, + "LiteRtCompilerContext get_reduce_any_keep_dims_option offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, get_reduce_all_keep_dims_option) == 800, + "LiteRtCompilerContext get_reduce_all_keep_dims_option offset mismatch"); + +static_assert(offsetof(LiteRtCompilerContext, get_pack_axis_option) == 808, + "LiteRtCompilerContext get_pack_axis_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_pack_values_count_option) == 816, + "LiteRtCompilerContext get_pack_values_count_option offset mismatch"); + +static_assert(offsetof(LiteRtCompilerContext, get_one_hot_axis_option) == 824, + "LiteRtCompilerContext get_one_hot_axis_option offset mismatch"); + +static_assert(offsetof(LiteRtCompilerContext, get_unpack_axis_option) == 832, + "LiteRtCompilerContext get_unpack_axis_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_unpack_num_option) == 840, + "LiteRtCompilerContext get_unpack_num_option offset mismatch"); + +static_assert(offsetof(LiteRtCompilerContext, get_gather_axis_option) == 848, + "LiteRtCompilerContext get_gather_axis_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_gather_batch_dims_option) == 856, + "LiteRtCompilerContext get_gather_batch_dims_option offset mismatch"); + +static_assert( + offsetof(LiteRtCompilerContext, get_conv_3d_padding_option) == 864, + "LiteRtCompilerContext get_conv_3d_padding_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_conv_3d_stride_d_option) == 872, + "LiteRtCompilerContext get_conv_3d_stride_d_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_conv_3d_stride_w_option) == 880, + "LiteRtCompilerContext get_conv_3d_stride_w_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_conv_3d_stride_h_option) == 888, + "LiteRtCompilerContext get_conv_3d_stride_h_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_conv_3d_fused_activation_option) == 896, + "LiteRtCompilerContext get_conv_3d_fused_activation_option " + "offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_conv_3d_dilation_d_option) == 904, + "LiteRtCompilerContext get_conv_3d_dilation_d_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_conv_3d_dilation_w_option) == 912, + "LiteRtCompilerContext get_conv_3d_dilation_w_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_conv_3d_dilation_h_option) == 920, + "LiteRtCompilerContext get_conv_3d_dilation_h_option offset mismatch"); + +static_assert(offsetof(LiteRtCompilerContext, + get_depth_to_space_block_size_option) == 976, + "LiteRtCompilerContext get_depth_to_space_block_size_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + get_space_to_depth_block_size_option) == 984, + "LiteRtCompilerContext get_space_to_depth_block_size_option " + "offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_cumsum_exclusive_option) == 992, + "LiteRtCompilerContext get_cumsum_exclusive_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_cumsum_reverse_option) == 1000, + "LiteRtCompilerContext get_cumsum_reverse_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_gelu_approximate_option) == 1008, + "LiteRtCompilerContext get_gelu_approximate_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_mirror_pad_mode_option) == 1016, + "LiteRtCompilerContext get_mirror_pad_mode_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_squeeze_dims_option) == 1024, + "LiteRtCompilerContext get_squeeze_dims_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, get_custom_options) == 1032, + "LiteRtCompilerContext get_custom_options offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, serialize_model_with_signatures) == 1040, + "LiteRtCompilerContext serialize_model_with_signatures offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_tensor) == 1048, + "LiteRtCompilerContext build_tensor offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_weights) == 1056, + "LiteRtCompilerContext build_weights offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_op) == 1064, + "LiteRtCompilerContext build_op offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, erase_op) == 1072, + "LiteRtCompilerContext erase_op offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_add_op_option) == 1080, + "LiteRtCompilerContext build_add_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_batch_matmul_op_option) == 1088, + "LiteRtCompilerContext build_batch_matmul_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_block_wise_quantization) == 1096, + "LiteRtCompilerContext get_block_wise_quantization offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_shlo_composite_op_option) == 1104, + "LiteRtCompilerContext build_shlo_composite_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_average_pool_2d_op_option) == 1112, + "LiteRtCompilerContext build_average_pool_2d_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_concatenation_op_option) == 1120, + "LiteRtCompilerContext build_concatenation_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_conv_2d_op_option) == 1128, + "LiteRtCompilerContext build_conv_2d_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_conv_3d_op_option) == 1136, + "LiteRtCompilerContext build_conv_3d_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_cumsum_op_option) == 1144, + "LiteRtCompilerContext build_cumsum_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_depth_to_space_op_option) == 1152, + "LiteRtCompilerContext build_depth_to_space_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_depthwise_conv_2d_op_option) == 1160, + "LiteRtCompilerContext build_depthwise_conv_2d_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_div_op_option) == 1168, + "LiteRtCompilerContext build_div_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_fully_connected_op_option) == 1176, + "LiteRtCompilerContext build_fully_connected_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_gather_op_option) == 1184, + "LiteRtCompilerContext build_gather_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_gelu_op_option) == 1192, + "LiteRtCompilerContext build_gelu_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_l2_pool_2d_op_option) == 1200, + "LiteRtCompilerContext build_l2_pool_2d_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_leaky_relu_op_option) == 1208, + "LiteRtCompilerContext build_leaky_relu_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_max_pool_2d_op_option) == 1216, + "LiteRtCompilerContext build_max_pool_2d_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_mean_op_option) == 1224, + "LiteRtCompilerContext build_mean_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_mirror_pad_op_option) == 1232, + "LiteRtCompilerContext build_mirror_pad_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_mul_op_option) == 1240, + "LiteRtCompilerContext build_mul_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_one_hot_op_option) == 1248, + "LiteRtCompilerContext build_one_hot_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_pack_op_option) == 1256, + "LiteRtCompilerContext build_pack_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_reduce_all_op_option) == 1264, + "LiteRtCompilerContext build_reduce_all_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_reduce_any_op_option) == 1272, + "LiteRtCompilerContext build_reduce_any_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_reduce_max_op_option) == 1280, + "LiteRtCompilerContext build_reduce_max_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_reduce_min_op_option) == 1288, + "LiteRtCompilerContext build_reduce_min_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_reshape_op_option) == 1296, + "LiteRtCompilerContext build_reshape_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_resize_bilinear_op_option) == 1304, + "LiteRtCompilerContext build_resize_bilinear_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, + build_resize_nearest_neighbor_op_option) == 1312, + "LiteRtCompilerContext build_resize_nearest_neighbor_op_option " + "offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_softmax_op_option) == 1320, + "LiteRtCompilerContext build_softmax_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_space_to_depth_op_option) == 1328, + "LiteRtCompilerContext build_space_to_depth_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_split_op_option) == 1336, + "LiteRtCompilerContext build_split_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_split_v_op_option) == 1344, + "LiteRtCompilerContext build_split_v_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_squeeze_op_option) == 1352, + "LiteRtCompilerContext build_squeeze_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_strided_slice_op_option) == 1360, + "LiteRtCompilerContext build_strided_slice_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_sub_op_option) == 1368, + "LiteRtCompilerContext build_sub_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_sum_op_option) == 1376, + "LiteRtCompilerContext build_sum_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, build_transpose_conv_op_option) == 1384, + "LiteRtCompilerContext build_transpose_conv_op_option offset mismatch"); +static_assert(offsetof(LiteRtCompilerContext, build_unpack_op_option) == 1392, + "LiteRtCompilerContext build_unpack_op_option offset mismatch"); +static_assert( + offsetof(LiteRtCompilerContext, get_split_v_num_splits_option) == 1400, + "LiteRtCompilerContext get_split_v_num_splits_option offset mismatch"); +#endif // __cplusplus + +LiteRtCompilerContext* LrtGetCompilerContext(); + +#ifdef __cplusplus +} +#endif + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_COMPILER_CONTEXT_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_custom_tensor_buffer_handlers_def.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_custom_tensor_buffer_handlers_def.h new file mode 100644 index 0000000000000000000000000000000000000000..7cb469bb670ef0990a7d877aeba6d8d75eec03c2 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_custom_tensor_buffer_handlers_def.h @@ -0,0 +1,80 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_CUSTOM_TENSOR_BUFFER_HANDLERS_DEF_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_CUSTOM_TENSOR_BUFFER_HANDLERS_DEF_H_ + +#include + +#include "litert/c/internal/litert_abi_header.h" +#include "litert/c/litert_custom_tensor_buffer.h" +#include "litert/c/litert_environment_options.h" +#include "litert/c/litert_tensor_buffer_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define LITERT_CUSTOM_BUFFER_HANDLERS_DEF_MAX_SUPPORTED_BUFFER_TYPES 16 + +/// A internal struct that holds custom tensor buffer handlers and supported +/// buffer types. +/// If a dispatch plugin wants to support custom tensor buffers, it can +/// provide a non-null pointer to this struct in the LiteRtDispatchApi. +/// +/// @note This concrete type is shared between the runtime and the Dispatch +/// plugin and Accelerator plugin, so it must be ABI stable. +typedef struct LiteRtCustomTensorBufferHandlersDef { + LiteRtAbiHeader abi_header; + + CreateCustomTensorBuffer create_func; + DestroyCustomTensorBuffer destroy_func; + LockCustomTensorBuffer lock_func; + UnlockCustomTensorBuffer unlock_func; + ClearCustomTensorBuffer clear_func; + ImportCustomTensorBuffer import_func; + + LiteRtEnvOptionTag device_tag; + LiteRtEnvOptionTag queue_tag; + + size_t num_supported_buffer_types; + LiteRtTensorBufferType supported_buffer_types + [LITERT_CUSTOM_BUFFER_HANDLERS_DEF_MAX_SUPPORTED_BUFFER_TYPES]; +} LiteRtCustomTensorBufferHandlersDef; + +#if defined(__cplusplus) && defined(__SIZEOF_POINTER__) && \ + __SIZEOF_POINTER__ == 8 +static_assert(sizeof(LiteRtCustomTensorBufferHandlersDef) == 136, + "LiteRtCustomTensorBufferHandlersDef size mismatch"); +static_assert(offsetof(LiteRtCustomTensorBufferHandlersDef, abi_header) == 0, + "LiteRtCustomTensorBufferHandlersDef abi_header offset mismatch"); +static_assert(offsetof(LiteRtCustomTensorBufferHandlersDef, device_tag) == 56, + "LiteRtCustomTensorBufferHandlersDef device_tag offset mismatch"); +static_assert(offsetof(LiteRtCustomTensorBufferHandlersDef, queue_tag) == 60, + "LiteRtCustomTensorBufferHandlersDef queue_tag offset mismatch"); +static_assert(offsetof(LiteRtCustomTensorBufferHandlersDef, + num_supported_buffer_types) == 64, + "LiteRtCustomTensorBufferHandlersDef num_supported_buffer_types " + "offset mismatch"); +static_assert(offsetof(LiteRtCustomTensorBufferHandlersDef, + supported_buffer_types) == 72, + "LiteRtCustomTensorBufferHandlersDef supported_buffer_types " + "offset mismatch"); +#endif // __cplusplus + +#ifdef __cplusplus +} +#endif + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_CUSTOM_TENSOR_BUFFER_HANDLERS_DEF_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_delegate_wrapper.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_delegate_wrapper.h new file mode 100644 index 0000000000000000000000000000000000000000..d1f4fc6e7f9c93b8c8d042acac0adc7e543256c9 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_delegate_wrapper.h @@ -0,0 +1,56 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_DELEGATE_WRAPPER_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_DELEGATE_WRAPPER_H_ + +// The LiteRtDelegateWrapper type is an abstract type that exists to +// hide the API dependency of the LiteRT API on the TF Lite API. +// +// This internal header file exposes the API dependency on the TF Lite API. +// However, this internal header file has limited visibility in the BUILD file +// -- it is exposed only to the LiteRT runtime implementation, and in +// particular to LiteRT runtime's built-in accelerator implementations that are +// implemented using TF Lite delegates. +// +// Users other than LiteRT runtime itself should not use this header. + +#include "litert/c/litert_common.h" +#include "tflite/c/common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Wrap a TF Lite opaque delegate into a LiteRT delegate wrapper. +// The lifetime of the wrapper returned in `*wrapper` is the same +// as the lifetime of the delegate passed in. +LiteRtStatus LiteRtWrapDelegate(TfLiteOpaqueDelegate* delegate, + void (*deleter)(TfLiteOpaqueDelegate*), + LiteRtDelegateWrapper* wrapper); + +// Extract a TF Lite opaque delegate from a LiteRT delegate wrapper. +// The lifetime of the delegate returned in `*delegate` is the same as the +// lifetime of the wrapper. +LiteRtStatus LiteRtUnwrapDelegate(LiteRtDelegateWrapper wrapper, + TfLiteOpaqueDelegate** delegate); + +// Destroy a LiteRT delegate wrapper and its underlying TF Lite delegate. +void LiteRtDestroyDelegateWrapper(LiteRtDelegateWrapper wrapper); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_DELEGATE_WRAPPER_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_dispatch_delegate.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_dispatch_delegate.h new file mode 100644 index 0000000000000000000000000000000000000000..2f3fe98bfd42c6525b940ab4ff10dc3213ea73ec --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_dispatch_delegate.h @@ -0,0 +1,60 @@ +// Copyright 2024 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_DISPATCH_DELEGATE_H_ +#define ODML_LITERT_LITERT_C_LITERT_DISPATCH_DELEGATE_H_ + +#include + +#include "litert/c/litert_common.h" +#include "litert/c/litert_profiler_types.h" +#include "tflite/c/c_api_types.h" +#include "tflite/c/common.h" + +typedef struct LiteRtDispatchDelegateOptions LiteRtDispatchDelegateOptions; + +// Create a delegate that uses the Dispatch API for execution. +// +// [TODO] DOCUMENT OWNERSHIP +TfLiteOpaqueDelegate* LiteRtCreateDispatchDelegate(LiteRtEnvironment env, + LiteRtOptions options); + +// Do any needed cleanup and delete 'delegate'. +void LiteRtDestroyDispatchDelegate(TfLiteOpaqueDelegate* delegate); + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// +// Metrics +// + +// Start collection of HW-specific metrics at a specific level of detail (>= 0). +LiteRtStatus LiteRtDispatchDelegateStartMetricsCollection( + TfLiteOpaqueDelegate* delegate, int detail_level); + +// Stop collection of HW-specific metrics and report the collected metrics. +LiteRtStatus LiteRtDispatchDelegateStopMetricsCollection( + TfLiteOpaqueDelegate* delegate, LiteRtMetrics metrics); + +// Retrieves the native vendor hooks from the accelerator. +LiteRtStatus LiteRtDispatchDelegateGetHooks(TfLiteOpaqueDelegate* delegate, + LiteRtHook* hook, void** user_data); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_DISPATCH_DELEGATE_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_external_litert_buffer_context.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_external_litert_buffer_context.h new file mode 100644 index 0000000000000000000000000000000000000000..3155d9751e1effc8abeed3a3279e38f85fadc5e4 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_external_litert_buffer_context.h @@ -0,0 +1,78 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_EXTERNAL_LITERT_BUFFER_CONTEXT_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_EXTERNAL_LITERT_BUFFER_CONTEXT_H_ + +#include "litert/c/litert_common.h" +#include "tflite/c/common.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Returns a TensorBuffer object for the given tensor. The returned +// TensorBuffer object is a duplicate (reference-counted) of the buffer +// context's registered TensorBuffer. The returned object is owned by the caller +// and must be destroyed. +LiteRtStatus LiteRtGetExternalLiteRtBufferContextTensorBuffer( + LiteRtExternalLiteRtBufferContext context, const TfLiteTensor* tensor, + LiteRtTensorBuffer* tensor_buffer); + +// Creates a TensorBuffer object for the given tensor. The returned object is +// owned by the caller and must be destroyed. +LiteRtStatus LiteRtExternalLiteRtBufferContextCreateBufferForTensor( + LiteRtExternalLiteRtBufferContext context, const TfLiteTensor* tensor, + LiteRtTensorBuffer* buffer); + +// Registers a TensorBuffer object for the given tensor. The buffer context +// assumes ownership of the TensorBuffer object. +LiteRtStatus LiteRtExternalLiteRtBufferContextRegisterTensorBuffer( + LiteRtExternalLiteRtBufferContext context, const TfLiteTensor* tensor, + LiteRtTensorBuffer buffer); + +// Unregisters a TensorBuffer object for the given tensor. +LiteRtStatus LiteRtExternalLiteRtBufferContextUnregisterTensorBuffer( + LiteRtExternalLiteRtBufferContext context, const TfLiteTensor* tensor); + +// Registers the buffer requirements for the given tensor. The buffer context +// assumes ownership of the buffer requirements. +LiteRtStatus LiteRtExternalLiteRtBufferContextRegisterBufferRequirements( + LiteRtExternalLiteRtBufferContext context, const TfLiteTensor* tensor, + LiteRtTensorBufferRequirements buffer_requirements); + +// Returns the environment for the given buffer context. No ownership is +// transferred. +LiteRtStatus LiteRtExternalLiteRtBufferContextGetEnvironment( + LiteRtExternalLiteRtBufferContext context, LiteRtEnvironment* env); + +// Sets whether the async execution mode is set. +LiteRtStatus LiteRtExternalLiteRtBufferContextIsAsyncExecutionMode( + LiteRtExternalLiteRtBufferContext context, bool* is_async_execution_mode); + +// Returns the per-run options handle for the current invocation. The +// returned options handle is borrowed and owned by the runtime. The caller +// must NOT destroy it. The handle is only valid during the current +// execution (inference run) and must not be stored. +LiteRtStatus LiteRtExternalLiteRtBufferContextGetRunOptions( + LiteRtExternalLiteRtBufferContext context, LiteRtOptions* run_options); + +// Destroys the buffer context. +void LiteRtDestroyExternalLiteRtBufferContext( + LiteRtExternalLiteRtBufferContext context); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_EXTERNAL_LITERT_BUFFER_CONTEXT_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_logging.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_logging.h new file mode 100644 index 0000000000000000000000000000000000000000..a71248c5df0eb836ea7145a1e8fece4ee485e6d5 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_logging.h @@ -0,0 +1,150 @@ +// Copyright 2024 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_INTERNAL_LITERT_LOGGING_H_ +#define ODML_LITERT_LITERT_C_INTERNAL_LITERT_LOGGING_H_ + +#include +#include +#include + +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// WARNING: The values of the following enum are to be kept in sync with +// tflite::LogSeverity. +typedef int8_t LiteRtLogSeverity; +enum { + kLiteRtLogSeverityDebug = -1, + kLiteRtLogSeverityVerbose = 0, + kLiteRtLogSeverityInfo = 1, + kLiteRtLogSeverityWarning = 2, + kLiteRtLogSeverityError = 3, + kLiteRtLogSeveritySilent = 4, +}; + +#define LITERT_DEBUG kLiteRtLogSeverityDebug +#define LITERT_VERBOSE kLiteRtLogSeverityVerbose +#define LITERT_INFO kLiteRtLogSeverityInfo +#define LITERT_WARNING kLiteRtLogSeverityWarning +#define LITERT_ERROR kLiteRtLogSeverityError +#define LITERT_SILENT kLiteRtLogSeveritySilent + +const char* LiteRtGetLogSeverityName(LiteRtLogSeverity severity); + +// Creates a default LiteRT logger. +LiteRtStatus LiteRtCreateLogger(LiteRtLogger* logger); + +LiteRtStatus LiteRtGetMinLoggerSeverity(LiteRtLogger logger, + LiteRtLogSeverity* min_severity); + +LiteRtStatus LiteRtSetMinLoggerSeverity(LiteRtLogger logger, + LiteRtLogSeverity min_severity); + +LiteRtStatus LiteRtLoggerLog(LiteRtLogger logger, LiteRtLogSeverity severity, + const char* format, ...); + +// Returns the identifier of the logger. +// The returned string pointer is owned by the logger. It becomes invalid when +// the LiteRtLogger is destroyed. +LiteRtStatus LiteRtGetLoggerIdentifier(LiteRtLoggerConst logger, + const char** identifier); + +void LiteRtDestroyLogger(LiteRtLogger logger); + +// Creates a sink logger. +// +// A sink logger will store the logs instead of outputting them. This allows the +// C++ public API to silence logs generated at the C boundary and control +// when/if to output them. +LiteRtStatus LiteRtCreateSinkLogger(LiteRtLogger* logger); + +// Returns the number of log calls that were done to the sink logger. +LiteRtStatus LiteRtGetSinkLoggerSize(LiteRtLogger logger, size_t* size); + +// Returns the idx_th log in the sink logger. +// The returned string pointer is owned by the sink logger. It becomes invalid +// when the LiteRtLogger is destroyed. +LiteRtStatus LiteRtGetSinkLoggerMessage(LiteRtLogger logger, size_t idx, + const char** message); + +// Clears the sink logger. +LiteRtStatus LiteRtClearSinkLogger(LiteRtLogger logger); + +LiteRtLogger LiteRtGetDefaultLogger(); + +LiteRtStatus LiteRtSetDefaultLogger(LiteRtLogger logger); + +LiteRtStatus LiteRtDefaultLoggerLog(LiteRtLogSeverity severity, + const char* format, ...); + +// Use the library provided standard logger instead of creating a new one. +LiteRtStatus LiteRtUseStandardLogger(); + +// Use the library provided sink logger instead of creating a new one. +LiteRtStatus LiteRtUseSinkLogger(); + +#ifdef __cplusplus +} // extern "C" + +// Compile statement only in debug mode. +#ifndef NDEBUG +#define LITERT_DEBUG_CODE(stmt) stmt; +#else +#define LITERT_DEBUG_CODE(stmt) +#endif + +#endif // __cplusplus + +#ifndef __FILE_NAME__ +#define __FILE_NAME__ __FILE__ +#endif + +#define LITERT_LOGGER_LOG_PROD(logger, severity, format, ...) \ + { \ + LiteRtLogSeverity __min_severity__; \ + if (LiteRtGetMinLoggerSeverity(logger, &__min_severity__) != \ + kLiteRtStatusOk) { \ + __min_severity__ = kLiteRtLogSeverityVerbose; \ + } \ + if (severity >= __min_severity__) { \ + LiteRtLoggerLog(logger, severity, "[%s:%d] " format, __FILE_NAME__, \ + __LINE__, ##__VA_ARGS__); \ + } \ + } + +#ifndef NDEBUG +#define LITERT_LOGGER_LOG LITERT_LOGGER_LOG_PROD +#else +#define LITERT_LOGGER_LOG(logger, severity, format, ...) \ + do { \ + LITERT_LOGGER_LOG_PROD(logger, severity, format, ##__VA_ARGS__); \ + } while (false) +#endif + +#define LITERT_LOG(severity, format, ...) \ + LITERT_LOGGER_LOG(LiteRtGetDefaultLogger(), severity, format, ##__VA_ARGS__); + +#define LITERT_ABORT abort() + +#define LITERT_FATAL(format, ...) \ + do { \ + LITERT_LOG(kLiteRtLogSeverityError, format, ##__VA_ARGS__) \ + LITERT_ABORT; \ + } while (0) + +#endif // ODML_LITERT_LITERT_C_INTERNAL_LITERT_LOGGING_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_logging_helper.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_logging_helper.h new file mode 100644 index 0000000000000000000000000000000000000000..156695a333cd423dda4c6829e79ea6404ed9da71 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_logging_helper.h @@ -0,0 +1,33 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_INTERNAL_LITERT_LOGGING_HELPER_H_ +#define ODML_LITERT_LITERT_C_INTERNAL_LITERT_LOGGING_HELPER_H_ + +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// TODO(niuchl): Remove this function once NPU moves to the runtime context. +// Propagates the minimum logger severity from environment options to the +// default logger. +LiteRtStatus LiteRtPropagateMinLoggerSeverity(LiteRtEnvironmentOptions options); + +#ifdef __cplusplus +} +#endif + +#endif // ODML_LITERT_LITERT_C_INTERNAL_LITERT_LOGGING_HELPER_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_logging_helper_with_compiler_context.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_logging_helper_with_compiler_context.h new file mode 100644 index 0000000000000000000000000000000000000000..e533040a91e3a55d0d7858e6b0bad1b09728e2f8 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_logging_helper_with_compiler_context.h @@ -0,0 +1,35 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_INTERNAL_LITERT_LOGGING_HELPER_WITH_COMPILER_CONTEXT_H_ +#define ODML_LITERT_LITERT_C_INTERNAL_LITERT_LOGGING_HELPER_WITH_COMPILER_CONTEXT_H_ + +#include "litert/c/litert_common.h" +#include "litert/c/litert_environment_options.h" + +typedef struct LiteRtCompilerContext LiteRtCompilerContext; + +#ifdef __cplusplus +extern "C" { +#endif + +LiteRtStatus LiteRtPropagateMinLoggerSeverityWithCompilerContext( + const LiteRtCompilerContext* compiler_context, + LiteRtEnvironmentOptions options); + +#ifdef __cplusplus +} +#endif + +#endif // ODML_LITERT_LITERT_C_INTERNAL_LITERT_LOGGING_HELPER_WITH_COMPILER_CONTEXT_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_logging_helper_with_runtime_context.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_logging_helper_with_runtime_context.h new file mode 100644 index 0000000000000000000000000000000000000000..193454ede99c16f7d5e074f6c1765f66ff7eb3ea --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_logging_helper_with_runtime_context.h @@ -0,0 +1,36 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_INTERNAL_LITERT_LOGGING_HELPER_WITH_RUNTIME_CONTEXT_H_ +#define ODML_LITERT_LITERT_C_INTERNAL_LITERT_LOGGING_HELPER_WITH_RUNTIME_CONTEXT_H_ + +#include "litert/c/litert_common.h" + +typedef struct LiteRtRuntimeContext LiteRtRuntimeContext; + +#ifdef __cplusplus +extern "C" { +#endif + +// Propagates the minimum logger severity from environment options to the +// default logger using the runtime context. +LiteRtStatus LiteRtPropagateMinLoggerSeverityWithRuntimeContext( + const LiteRtRuntimeContext* runtime_context, + LiteRtEnvironmentOptions options); + +#ifdef __cplusplus +} +#endif + +#endif // ODML_LITERT_LITERT_C_INTERNAL_LITERT_LOGGING_HELPER_WITH_RUNTIME_CONTEXT_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_options_helper.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_options_helper.h new file mode 100644 index 0000000000000000000000000000000000000000..3a321692c9805faf15ebfbb774b8e112deb96abe --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_options_helper.h @@ -0,0 +1,36 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_OPTIONS_HELPER_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_OPTIONS_HELPER_H_ + +#include + +#include "absl/strings/string_view.h" // from @com_google_absl + +namespace litert { +namespace internal { + +inline void MakeCStringPayload(absl::string_view toml_str, void** payload, + void (**payload_deleter)(void*)) { + *payload = new char[toml_str.size() + 1]; + memcpy(*payload, toml_str.data(), toml_str.size()); + static_cast(*payload)[toml_str.size()] = '\0'; + *payload_deleter = [](void* p) { delete[] static_cast(p); }; +} + +} // namespace internal +} // namespace litert + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_OPTIONS_HELPER_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_runtime_api_export.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_runtime_api_export.h new file mode 100644 index 0000000000000000000000000000000000000000..dd22e604bdf9b55238cbb4546e3ed1658f39a976 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_runtime_api_export.h @@ -0,0 +1,31 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_RUNTIME_API_EXPORT_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_RUNTIME_API_EXPORT_H_ + +#include "litert/c/litert_common.h" +#include "litert/c/internal/litert_runtime_c_api.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern LITERT_CAPI_EXPORT const LiteRtRuntimeCApiStruct kLiteRtRuntimeBuiltin; + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_RUNTIME_API_EXPORT_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_runtime_builtin.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_runtime_builtin.h new file mode 100644 index 0000000000000000000000000000000000000000..e90fab1bbb8677d157f5524c26c904a8a359426d --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_runtime_builtin.h @@ -0,0 +1,31 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_CC_INTERNAL_LITERT_RUNTIME_BUILTIN_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_CC_INTERNAL_LITERT_RUNTIME_BUILTIN_H_ + +#include "litert/c/internal/litert_runtime_c_api.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/// Gets the builtin LiteRT runtime implementation. +const LiteRtRuntimeCApiStruct* GetLiteRtRuntimeBuiltin(); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_CC_INTERNAL_LITERT_RUNTIME_BUILTIN_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_runtime_c_api.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_runtime_c_api.h new file mode 100644 index 0000000000000000000000000000000000000000..ae2a377fdde8352d5976d18a5e9e97f3f7d7ac2e --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_runtime_c_api.h @@ -0,0 +1,771 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_RUNTIME_C_API_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_RUNTIME_C_API_H_ + +#include +#include + +#include "litert/c/internal/litert_scheduling_info.h" +#include "litert/c/litert_any.h" +#include "litert/c/litert_common.h" +#include "litert/c/litert_custom_op_kernel.h" +#include "litert/c/litert_custom_tensor_buffer.h" +#include "litert/c/litert_environment_options.h" +#include "litert/c/litert_event_type.h" +#include "litert/c/litert_gl_types.h" +#include "litert/c/litert_layout.h" +#include "litert/c/litert_metrics.h" +#include "litert/c/litert_model_types.h" +#include "litert/c/litert_opaque_options.h" +#include "litert/c/litert_opencl_types.h" +#include "litert/c/litert_tensor_buffer_types.h" +#include "litert/c/litert_webgpu_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// For any changes to this file that would affect the ABI, +// don't forget to also bump the ABI version number. + +// LINT.IfChange(version_number) + +// LiteRT CompiledModels ABI version number, in semver 2 format +// (see https://semver.org). This is the ABI version number for +// the methods in LiteRtRuntimeCApiStruct, which is defined below. +#define LITERT_RUNTIME_ABI_VERSION "1.1.0" +// TODO(b/493650900): declare that as an extern const (and +// initialize it in a .cc file) rather than using a macro. + +// LINT.ThenChange() + +// LINT.IfChange(method_table) + +// A struct that contains all the LiteRT runtime C API functions. +// +// This struct is used to provide a unified interface for the LiteRT runtime +// regardless of the underlying runtime implementation. +// +// NOTE: All new fields should be added to the end of the struct. +// +// For binary backwards compatibility, EXISTING ENTRIES IN THESE TABLES SHOULD +// NEVER BE DELETED, and should not be modified until they are no longer used, +// including the usage in already built app binaries -- verifying this may +// require adding logging. Entries that are really not longer used at all, +// even by old code, can be replaced by a placeholder of the same signature, +// e.g. a function pointer that is set to a no-op function, but should not be +// deleted, to avoid affecting the offsets of entries later in the table. Any +// new methods should only be added at the END of the table (unless reusing a +// slot occupied by a placeholder). + +typedef struct LiteRtRuntimeCApiStruct { + // + // LiteRtEnvironment + // + // litert_environment.h: LiteRtCreateEnvironment + LiteRtStatus (*litert_create_environment)(int num_options, + const LiteRtEnvOption* options, + LiteRtEnvironment* environment); + // litert_environment.h: LiteRtDestroyEnvironment + void (*litert_destroy_environment)(LiteRtEnvironment environment); + // litert_environment.h: LiteRtGetEnvironmentOptions + LiteRtStatus (*litert_get_environment_options)( + LiteRtEnvironment environment, LiteRtEnvironmentOptions* options); + // litert_environment.h: LiteRtAddEnvironmentOptions + LiteRtStatus (*litert_add_environment_options)(LiteRtEnvironment environment, + int num_options, + const LiteRtEnvOption* options, + bool overwrite); + // litert_environment.h: LiteRtGpuEnvironmentCreate + LiteRtStatus (*litert_gpu_environment_create)(LiteRtEnvironment environment, + int num_options, + const LiteRtEnvOption* options); + // litert_environment.h: LiteRtEnvironmentSupportsClGlInterop + LiteRtStatus (*litert_environment_supports_cl_gl_interop)( + LiteRtEnvironment environment, bool* is_supported); + // litert_environment.h: LiteRtEnvironmentSupportsAhwbClInterop + LiteRtStatus (*litert_environment_supports_ahwb_cl_interop)( + LiteRtEnvironment environment, bool* is_supported); + // litert_environment.h: LiteRtEnvironmentSupportsAhwbGlInterop + LiteRtStatus (*litert_environment_supports_ahwb_gl_interop)( + LiteRtEnvironment environment, bool* is_supported); + // litert_environment.h: LiteRtEnvironmentHasGpuEnvironment + void (*litert_environment_has_gpu_environment)(LiteRtEnvironment environment, + bool* has_gpu_environment); + + // + // LiteRtEnvironmentOptions + // + // litert_environment_options.h: LiteRtGetEnvironmentOptionsValue + LiteRtStatus (*litert_get_environment_options_value)( + LiteRtEnvironmentOptions options, LiteRtEnvOptionTag tag, + LiteRtAny* value); + + // + // LiteRtTensor + // + // litert_model.h: LiteRtGetTensorName + LiteRtStatus (*litert_get_tensor_name)(LiteRtTensor tensor, + const char** name); + // litert_model.h: LiteRtGetTensorIndex + LiteRtStatus (*litert_get_tensor_index)(LiteRtTensor tensor, + uint32_t* tensor_index); + // litert_model.h: LiteRtGetTensorTypeId + LiteRtStatus (*litert_get_tensor_type_id)(LiteRtTensor tensor, + LiteRtTensorTypeId* type_id); + // litert_model.h: LiteRtGetUnrankedTensorType + LiteRtStatus (*litert_get_unranked_tensor_type)( + LiteRtTensor tensor, LiteRtUnrankedTensorType* unranked_tensor_type); + // litert_model.h: LiteRtGetRankedTensorType + LiteRtStatus (*litert_get_ranked_tensor_type)( + LiteRtTensor tensor, LiteRtRankedTensorType* ranked_tensor_type); + // litert_model.h: LiteRtGetQuantizationTypeId + LiteRtStatus (*litert_get_quantization_type_id)( + LiteRtTensor tensor, LiteRtQuantizationTypeId* q_type_id); + // litert_model.h: LiteRtGetPerTensorQuantization + LiteRtStatus (*litert_get_per_tensor_quantization)( + LiteRtTensor tensor, + LiteRtQuantizationPerTensor* per_tensor_quantization); + // litert_model.h: LiteRtGetPerChannelQuantization + LiteRtStatus (*litert_get_per_channel_quantization)( + LiteRtTensor tensor, + LiteRtQuantizationPerChannel* per_channel_quantization); + // litert_model.h: LiteRtGetNumTensorUses + LiteRtStatus (*litert_get_num_tensor_uses)(LiteRtTensor tensor, + LiteRtParamIndex* num_uses); + // litert_model.h: LiteRtGetTensorUse + LiteRtStatus (*litert_get_tensor_use)(LiteRtTensor tensor, + LiteRtParamIndex use_index, + LiteRtOp* user, + LiteRtParamIndex* user_arg_index); + // litert_model.h: LiteRtGetTensorDefiningOp + LiteRtStatus (*litert_get_tensor_defining_op)( + LiteRtTensor tensor, bool* has_defining_op, + LiteRtTensorDefiningOp* defining_op); + // litert_model.h: LiteRtGetTensorWeights + LiteRtStatus (*litert_get_tensor_weights)(LiteRtTensor tensor, + LiteRtWeights* weights); + + // + // LiteRtSubgraph + // + // litert_model.h: LiteRtGetNumSubgraphInputs + LiteRtStatus (*litert_get_num_subgraph_inputs)(LiteRtSubgraph subgraph, + LiteRtParamIndex* num_inputs); + // litert_model.h: LiteRtGetSubgraphInput + LiteRtStatus (*litert_get_subgraph_input)(LiteRtSubgraph subgraph, + LiteRtParamIndex input_index, + LiteRtTensor* input); + // litert_model.h: LiteRtGetNumSubgraphOutputs + LiteRtStatus (*litert_get_num_subgraph_outputs)( + LiteRtSubgraph subgraph, LiteRtParamIndex* num_outputs); + // litert_model.h: LiteRtGetSubgraphOutput + LiteRtStatus (*litert_get_subgraph_output)(LiteRtSubgraph subgraph, + LiteRtParamIndex output_index, + LiteRtTensor* output); + // litert_model.h: LiteRtGetNumSubgraphOps + LiteRtStatus (*litert_get_num_subgraph_ops)(LiteRtSubgraph subgraph, + LiteRtParamIndex* num_ops); + // litert_model.h: LiteRtGetSubgraphOp + LiteRtStatus (*litert_get_subgraph_op)(LiteRtSubgraph subgraph, + LiteRtParamIndex op_index, + LiteRtOp* op); + + // + // LiteRtSignature + // + // litert_model.h: LiteRtGetSignatureKey + LiteRtStatus (*litert_get_signature_key)(LiteRtSignature signature, + const char** signature_key); + // litert_model.h: LiteRtGetSignatureSubgraph + LiteRtStatus (*litert_get_signature_subgraph)(LiteRtSignature signature, + LiteRtSubgraph* subgraph); + // litert_model.h: LiteRtGetNumSignatureInputs + LiteRtStatus (*litert_get_num_signature_inputs)(LiteRtSignature signature, + LiteRtParamIndex* num_inputs); + // litert_model.h: LiteRtGetSignatureInputName + LiteRtStatus (*litert_get_signature_input_name)(LiteRtSignature signature, + LiteRtParamIndex input_idx, + const char** input_name); + // litert_model.h: LiteRtGetSignatureInputTensorByIndex + LiteRtStatus (*litert_get_signature_input_tensor_by_index)( + LiteRtSignature signature, LiteRtParamIndex input_idx, + LiteRtTensor* tensor); + // litert_model.h: LiteRtGetNumSignatureOutputs + LiteRtStatus (*litert_get_num_signature_outputs)( + LiteRtSignature signature, LiteRtParamIndex* num_outputs); + // litert_model.h: LiteRtGetSignatureOutputName + LiteRtStatus (*litert_get_signature_output_name)(LiteRtSignature signature, + LiteRtParamIndex output_idx, + const char** output_name); + // litert_model.h: LiteRtGetSignatureOutputTensorByIndex + LiteRtStatus (*litert_get_signature_output_tensor_by_index)( + LiteRtSignature signature, LiteRtParamIndex output_idx, + LiteRtTensor* tensor); + + // + // LiteRtModel + // + // litert_model.h: LiteRtCreateModelFromFile + LiteRtStatus (*litert_create_model_from_file)(LiteRtEnvironment environment, + const char* filename, + LiteRtModel* model); + // litert_model.h: LiteRtCreateModelFromBuffer + LiteRtStatus (*litert_create_model_from_buffer)(LiteRtEnvironment environment, + const void* buffer_addr, + size_t buffer_size, + LiteRtModel* model); + // litert_model.h: LiteRtGetModelMetadata + LiteRtStatus (*litert_get_model_metadata)(LiteRtModel model, + const char* metadata_key, + const void** metadata_buffer, + size_t* metadata_buffer_size); + // litert_model.h: LiteRtAddModelMetadata + LiteRtStatus (*litert_add_model_metadata)(LiteRtModel model, + const char* metadata_key, + const void* metadata_buffer, + size_t metadata_buffer_size); + // litert_model.h: LiteRtGetMainModelSubgraphIndex + LiteRtStatus (*litert_get_main_model_subgraph_index)( + LiteRtModel model, LiteRtParamIndex* main_subgraph_index); + // litert_model.h: LiteRtGetNumModelSubgraphs + LiteRtStatus (*litert_get_num_model_subgraphs)( + LiteRtModel model, LiteRtParamIndex* num_subgraphs); + // litert_model.h: LiteRtGetModelSubgraph + LiteRtStatus (*litert_get_model_subgraph)(LiteRtModel model, + LiteRtParamIndex subgraph_index, + LiteRtSubgraph* subgraph); + // litert_model.h: LiteRtGetNumModelSignatures + LiteRtStatus (*litert_get_num_model_signatures)( + LiteRtModel model, LiteRtParamIndex* num_signatures); + // litert_model.h: LiteRtGetModelSignature + LiteRtStatus (*litert_get_model_signature)(LiteRtModel model, + LiteRtParamIndex signature_index, + LiteRtSignature* signature); + // litert_model.h: LiteRtDestroyModel + void (*litert_destroy_model)(LiteRtModel model); + // litert_model.h: LiteRtPushOp + LiteRtStatus (*litert_push_op)(LiteRtOpList op_list, LiteRtOp op, + LiteRtParamIndex partition_index); + // litert_model.h: LiteRtSerializeModelWithSignatures + LiteRtStatus (*litert_serialize_model_with_signatures)( + LiteRtModel model, uint8_t** buf, size_t* size, size_t* offset, + bool destroy_model, char** signatures, LiteRtParamIndex num_signatures, + LiteRtModelSerializationOptions options); + // litert_model.h: LiteRtSerializeModel + LiteRtStatus (*litert_serialize_model)( + LiteRtModel model, uint8_t** buf, size_t* size, size_t* offset, + bool destroy_model, LiteRtModelSerializationOptions options); + + // + // LiteRtCompiledModel + // + // litert_compiled_model.h: LiteRtCreateCompiledModel + LiteRtStatus (*litert_create_compiled_model)( + LiteRtEnvironment environment, LiteRtModel model, + LiteRtOptions compilation_options, LiteRtCompiledModel* compiled_model); + // litert_compiled_model.h: LiteRtGetCompiledModelInputBufferRequirements + LiteRtStatus (*litert_get_compiled_model_input_buffer_requirements)( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + LiteRtParamIndex input_index, + LiteRtTensorBufferRequirements* buffer_requirements); + // litert_compiled_model.h: LiteRtGetCompiledModelOutputBufferRequirements + LiteRtStatus (*litert_get_compiled_model_output_buffer_requirements)( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + LiteRtParamIndex output_index, + LiteRtTensorBufferRequirements* buffer_requirements); + // litert_compiled_model.h: LiteRtGetCompiledModelInputTensorLayout + LiteRtStatus (*litert_get_compiled_model_input_tensor_layout)( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + LiteRtParamIndex input_index, LiteRtLayout* layout); + // litert_compiled_model.h: LiteRtGetCompiledModelOutputTensorLayouts + LiteRtStatus (*litert_get_compiled_model_output_tensor_layouts)( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + size_t num_layouts, LiteRtLayout* layouts, bool update_allocation); + // litert_compiled_model.h: LiteRtRunCompiledModel + LiteRtStatus (*litert_run_compiled_model)(LiteRtCompiledModel compiled_model, + LiteRtParamIndex signature_index, + size_t num_input_buffers, + LiteRtTensorBuffer* input_buffers, + size_t num_output_buffers, + LiteRtTensorBuffer* output_buffers); + // litert_compiled_model.h: LiteRtRunCompiledModelWithOptions + LiteRtStatus (*litert_run_compiled_model_with_options)( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + size_t num_input_buffers, LiteRtTensorBuffer* input_buffers, + size_t num_output_buffers, LiteRtTensorBuffer* output_buffers, + LiteRtOptions options); + // litert_compiled_model.h: LiteRtRunCompiledModelAsync + LiteRtStatus (*litert_run_compiled_model_async)( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + size_t num_input_buffers, LiteRtTensorBuffer* input_buffers, + size_t num_output_buffers, LiteRtTensorBuffer* output_buffers, + bool* async); + // litert_compiled_model.h: LiteRtRunCompiledModelAsyncWithOptions + LiteRtStatus (*litert_run_compiled_model_async_with_options)( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + size_t num_input_buffers, LiteRtTensorBuffer* input_buffers, + size_t num_output_buffers, LiteRtTensorBuffer* output_buffers, + bool* async, LiteRtOptions options); + // litert_compiled_model.h: LiteRtSetCompiledModelCancellationFunction + LiteRtStatus (*litert_set_compiled_model_cancellation_function)( + LiteRtCompiledModel compiled_model, void* data, + bool (*check_cancelled_func)(void*)); + // litert_compiled_model.h: LiteRtDestroyCompiledModel + void (*litert_destroy_compiled_model)(LiteRtCompiledModel compiled_model); + // litert_compiled_model.h: LiteRtCompiledModelStartMetricsCollection + LiteRtStatus (*litert_compiled_model_start_metrics_collection)( + LiteRtCompiledModel compiled_model, int detail_level); + // litert_compiled_model.h: LiteRtCompiledModelStopMetricsCollection + LiteRtStatus (*litert_compiled_model_stop_metrics_collection)( + LiteRtCompiledModel compiled_model, LiteRtMetrics metrics); + // litert_compiled_model.h: LiteRtCompiledModelIsFullyAccelerated + LiteRtStatus (*litert_compiled_model_is_fully_accelerated)( + LiteRtCompiledModel compiled_model, bool* fully_accelerated); + // litert_compiled_model.h: LiteRtCompiledModelGetProfiler + LiteRtStatus (*litert_compiled_model_get_profiler)( + LiteRtCompiledModel compiled_model, LiteRtProfiler* profiler); + // litert_compiled_model.h: LiteRtCompiledModelResizeInputTensor + LiteRtStatus (*litert_compiled_model_resize_input_tensor)( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + LiteRtParamIndex input_index, const int* dims, size_t dims_size); + // litert_compiled_model.h: LiteRtCompiledModelResizeInputTensorNonStrict + LiteRtStatus (*litert_compiled_model_resize_input_tensor_non_strict)( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + LiteRtParamIndex input_index, const int* dims, size_t dims_size); + // litert_compiled_model.h: LiteRtCompiledModelSetDispatchAnnotation + LiteRtStatus (*litert_compiled_model_set_dispatch_annotation)( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + const char* key, const char* value); + // litert_compiled_model.h: LiteRtCompiledModelGetDispatchAnnotation + LiteRtStatus (*litert_compiled_model_get_dispatch_annotation)( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + const char* key, const char** value); + // litert_compiled_model.h: LiteRtCompiledModelRemoveDispatchAnnotation + LiteRtStatus (*litert_compiled_model_remove_dispatch_annotation)( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + const char* key); + // litert_compiled_model.h: LiteRtCompiledModelReportError + LiteRtStatus (*litert_compiled_model_report_error)( + LiteRtCompiledModel compiled_model, const char* format, ...); + // litert_compiled_model.h: LiteRtCompiledModelClearErrors + LiteRtStatus (*litert_compiled_model_clear_errors)( + LiteRtCompiledModel compiled_model); + // litert_compiled_model.h: LiteRtCompiledModelGetErrorMessages + LiteRtStatus (*litert_compiled_model_get_error_messages)( + LiteRtCompiledModel compiled_model, char** error_messages); + + // + // LiteRtTensorBufferRequirements + // + // litert_tensor_buffer_requirements.h: LiteRtCreateTensorBufferRequirements + LiteRtStatus (*litert_create_tensor_buffer_requirements)( + int num_supported_tensor_buffer_types, + const LiteRtTensorBufferType* supported_tensor_buffer_types, + size_t buffer_size, int num_strides, const uint32_t* strides, + LiteRtTensorBufferRequirements* requirements); + // litert_tensor_buffer_requirements.h: + // LiteRtCreateTensorBufferRequirementsWithAlignment + LiteRtStatus (*litert_create_tensor_buffer_requirements_with_alignment)( + int num_supported_tensor_buffer_types, + const LiteRtTensorBufferType* supported_tensor_buffer_types, + size_t buffer_size, int num_strides, const uint32_t* strides, + size_t alignment, LiteRtTensorBufferRequirements* requirements); + // litert_tensor_buffer_requirements.h: + // LiteRtGetNumTensorBufferRequirementsSupportedBufferTypes + LiteRtStatus ( + *litert_get_num_tensor_buffer_requirements_supported_buffer_types)( + LiteRtTensorBufferRequirements requirements, int* num_types); + // litert_tensor_buffer_requirements.h: + // LiteRtGetTensorBufferRequirementsSupportedTensorBufferType + LiteRtStatus ( + *litert_get_tensor_buffer_requirements_supported_tensor_buffer_type)( + LiteRtTensorBufferRequirements requirements, int type_index, + LiteRtTensorBufferType* type); + // litert_tensor_buffer_requirements.h: + // LiteRtGetTensorBufferRequirementsBufferSize + LiteRtStatus (*litert_get_tensor_buffer_requirements_buffer_size)( + LiteRtTensorBufferRequirements requirements, size_t* buffer_size); + // litert_tensor_buffer_requirements.h: + // LiteRtGetTensorBufferRequirementsStrides + LiteRtStatus (*litert_get_tensor_buffer_requirements_strides)( + LiteRtTensorBufferRequirements requirements, int* num_strides, + const uint32_t** strides); + // litert_tensor_buffer_requirements.h: + // LiteRtGetTensorBufferRequirementsAlignment + LiteRtStatus (*litert_get_tensor_buffer_requirements_alignment)( + LiteRtTensorBufferRequirements requirements, size_t* alignment); + // litert_tensor_buffer_requirements.h: LiteRtJoinTensorBufferRequirements + LiteRtStatus (*litert_join_tensor_buffer_requirements)( + LiteRtTensorBufferRequirements src_requirements_1, + LiteRtTensorBufferRequirements src_requirements_2, + LiteRtTensorBufferRequirements* joined_requirements); + // litert_tensor_buffer_requirements.h: + // LiteRtDestroyTensorBufferRequirements + void (*litert_destroy_tensor_buffer_requirements)( + LiteRtTensorBufferRequirements requirements); + + // + // LiteRtTensorBuffer + // + // litert_tensor_buffer.h: LiteRtCreateTensorBufferFromHostMemory + LiteRtStatus (*litert_create_tensor_buffer_from_host_memory)( + const LiteRtRankedTensorType* tensor_type, void* host_buffer_addr, + size_t host_buffer_size, LiteRtHostMemoryDeallocator deallocator, + LiteRtTensorBuffer* buffer); + // litert_tensor_buffer.h: LiteRtGetTensorBufferHostMemory + LiteRtStatus (*litert_get_tensor_buffer_host_memory)( + LiteRtTensorBuffer tensor_buffer, void** host_memory_addr); + // litert_tensor_buffer.h: LiteRtCreateTensorBufferFromAhwb + LiteRtStatus (*litert_create_tensor_buffer_from_ahwb)( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + AHardwareBuffer* ahwb, size_t ahwb_offset, + LiteRtAhwbDeallocator deallocator, LiteRtTensorBuffer* buffer); + // litert_tensor_buffer.h: LiteRtGetTensorBufferAhwb + LiteRtStatus (*litert_get_tensor_buffer_ahwb)( + LiteRtTensorBuffer tensor_buffer, AHardwareBuffer** ahwb); + // litert_tensor_buffer.h: LiteRtCreateTensorBufferFromIonBuffer + LiteRtStatus (*litert_create_tensor_buffer_from_ion_buffer)( + const LiteRtRankedTensorType* tensor_type, void* ion_buffer_addr, + int ion_buffer_fd, size_t ion_buffer_size, size_t ion_buffer_offset, + LiteRtIonDeallocator deallocator, LiteRtTensorBuffer* buffer); + // litert_tensor_buffer.h: LiteRtGetTensorBufferIonBuffer + LiteRtStatus (*litert_get_tensor_buffer_ion_buffer)(LiteRtTensorBuffer buffer, + void** ion_buffer_addr, + int* ion_buffer_fd); + // litert_tensor_buffer.h: LiteRtCreateTensorBufferFromDmaBufBuffer + LiteRtStatus (*litert_create_tensor_buffer_from_dma_buf_buffer)( + const LiteRtRankedTensorType* tensor_type, void* dmabuf_buffer_addr, + int dmabuf_buffer_fd, size_t dmabuf_buffer_size, + size_t dmabuf_buffer_offset, LiteRtDmaBufDeallocator deallocator, + LiteRtTensorBuffer* buffer); + // litert_tensor_buffer.h: LiteRtGetTensorBufferDmaBufBuffer + LiteRtStatus (*litert_get_tensor_buffer_dma_buf_buffer)( + LiteRtTensorBuffer tensor_buffer, void** dmabuf_buffer_addr, + int* dmabuf_buffer_fd); + // litert_tensor_buffer.h: LiteRtCreateTensorBufferFromFastRpcBuffer + LiteRtStatus (*litert_create_tensor_buffer_from_fast_rpc_buffer)( + const LiteRtRankedTensorType* tensor_type, void* fastrpc_buffer_addr, + int fastrpc_fd, size_t fastrpc_buffer_size, size_t fastrpc_buffer_offset, + LiteRtFastRpcDeallocator deallocator, LiteRtTensorBuffer* buffer); + // litert_tensor_buffer.h: LiteRtGetTensorBufferFastRpcBuffer + LiteRtStatus (*litert_get_tensor_buffer_fast_rpc_buffer)( + LiteRtTensorBuffer tensor_buffer, void** fastrpc_buffer_addr, + int* fastrpc_buffer_fd); + // litert_tensor_buffer.h: LiteRtCreateTensorBufferFromOpenClMemory + LiteRtStatus (*litert_create_tensor_buffer_from_opencl_memory)( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + LiteRtTensorBufferType buffer_type, LiteRtClMem cl_mem_addr, + size_t opencl_buffer_size, LiteRtOpenClDeallocator deallocator, + LiteRtTensorBuffer* buffer); + // litert_tensor_buffer.h: LiteRtGetTensorBufferOpenClMemory + LiteRtStatus (*litert_get_tensor_buffer_opencl_memory)( + LiteRtTensorBuffer tensor_buffer, LiteRtClMem* cl_mem_addr); + // litert_tensor_buffer.h: LiteRtGetTensorBufferCustomTensorBufferHandle + LiteRtStatus (*litert_get_tensor_buffer_custom_tensor_buffer_handle)( + LiteRtTensorBuffer tensor_buffer, HwMemoryHandle* hw_memory_handle); + // litert_tensor_buffer.h: LiteRtCreateTensorBufferFromGlBuffer + LiteRtStatus (*litert_create_tensor_buffer_from_gl_buffer)( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + LiteRtGLenum target, LiteRtGLuint id, size_t size_bytes, size_t offset, + LiteRtGlBufferDeallocator deallocator, LiteRtTensorBuffer* buffer); + // litert_tensor_buffer.h: LiteRtGetTensorBufferGlBuffer + LiteRtStatus (*litert_get_tensor_buffer_gl_buffer)( + LiteRtTensorBuffer tensor_buffer, LiteRtGLenum* target, LiteRtGLuint* id, + size_t* size_bytes, size_t* offset); + // litert_tensor_buffer.h: LiteRtCreateTensorBufferFromGlTexture + LiteRtStatus (*litert_create_tensor_buffer_from_gl_texture)( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + LiteRtGLenum target, LiteRtGLuint id, LiteRtGLenum format, + size_t size_bytes, LiteRtGLint layer, + LiteRtGlTextureDeallocator deallocator, LiteRtTensorBuffer* buffer); + // litert_tensor_buffer.h: LiteRtGetTensorBufferGlTexture + LiteRtStatus (*litert_get_tensor_buffer_gl_texture)( + LiteRtTensorBuffer tensor_buffer, LiteRtGLenum* target, LiteRtGLuint* id, + LiteRtGLenum* format, size_t* size_bytes, LiteRtGLint* layer); + // litert_tensor_buffer.h: LiteRtCreateTensorBufferFromWebGpuBuffer + LiteRtStatus (*litert_create_tensor_buffer_from_web_gpu_buffer)( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + LiteRtTensorBufferType buffer_type, LiteRtWGPUBuffer wgpu_buffer, + size_t wgpu_buffer_size, LiteRtWebGpuBufferDeallocator deallocator, + LiteRtTensorBuffer* tensor_buffer); + // litert_tensor_buffer.h: LiteRtGetTensorBufferWebGpuBuffer + LiteRtStatus (*litert_get_tensor_buffer_web_gpu_buffer)( + LiteRtTensorBuffer tensor_buffer, HwMemoryHandle* hw_memory_handle); + LiteRtStatus (*litert_create_tensor_buffer_from_web_gpu_texture)( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + void* webgpu_texture, size_t webgpu_texture_size, + LiteRtWebGpuTextureDeallocator deallocator, + LiteRtTensorBuffer* tensor_buffer); + // litert_tensor_buffer.h: LiteRtCreateTensorBufferFromMetalMemory + LiteRtStatus (*litert_create_tensor_buffer_from_metal_memory)( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + LiteRtTensorBufferType buffer_type, void* metal_buffer, + size_t metal_buffer_size, LiteRtMetalDeallocator deallocator, + LiteRtTensorBuffer* tensor_buffer); + // litert_tensor_buffer.h: LiteRtGetTensorBufferMetalMemory + LiteRtStatus (*litert_get_tensor_buffer_metal_memory)( + LiteRtTensorBuffer tensor_buffer, HwMemoryHandle* hw_memory_handle); + // litert_tensor_buffer.h: LiteRtGetTensorBufferVulkanMemory + LiteRtStatus (*litert_get_tensor_buffer_vulkan_memory)( + LiteRtTensorBuffer tensor_buffer, HwMemoryHandle* hw_memory_handle); + // litert_tensor_buffer.h: LiteRtCreateManagedTensorBuffer + LiteRtStatus (*litert_create_managed_tensor_buffer)( + LiteRtEnvironment env, LiteRtTensorBufferType buffer_type, + const LiteRtRankedTensorType* tensor_type, size_t buffer_size, + LiteRtTensorBuffer* buffer); + // litert_tensor_buffer.h: LiteRtCreateManagedTensorBufferFromRequirements + LiteRtStatus (*litert_create_managed_tensor_buffer_from_requirements)( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + LiteRtTensorBufferRequirements requirements, LiteRtTensorBuffer* buffer); + // litert_tensor_buffer.h: LiteRtDuplicateTensorBuffer + LiteRtStatus (*litert_duplicate_tensor_buffer)( + LiteRtTensorBuffer tensor_buffer); + // litert_tensor_buffer.h: LiteRtGetTensorBufferType + LiteRtStatus (*litert_get_tensor_buffer_type)( + LiteRtTensorBuffer tensor_buffer, LiteRtTensorBufferType* buffer_type); + // litert_tensor_buffer.h: LiteRtGetTensorBufferTensorType + LiteRtStatus (*litert_get_tensor_buffer_tensor_type)( + LiteRtTensorBuffer tensor_buffer, LiteRtRankedTensorType* tensor_type); + // litert_tensor_buffer.h: LiteRtGetTensorBufferSize + LiteRtStatus (*litert_get_tensor_buffer_size)( + LiteRtTensorBuffer tensor_buffer, size_t* size); + // litert_tensor_buffer.h: LiteRtGetTensorBufferPackedSize + LiteRtStatus (*litert_get_tensor_buffer_packed_size)( + LiteRtTensorBuffer tensor_buffer, size_t* size); + // litert_tensor_buffer.h: LiteRtGetTensorBufferOffset + LiteRtStatus (*litert_get_tensor_buffer_offset)( + LiteRtTensorBuffer tensor_buffer, size_t* offset); + // litert_tensor_buffer.h: LiteRtHasTensorBufferEvent + LiteRtStatus (*litert_has_tensor_buffer_event)( + LiteRtTensorBuffer tensor_buffer, bool* has_event); + // litert_tensor_buffer.h: LiteRtGetTensorBufferEvent + LiteRtStatus (*litert_get_tensor_buffer_event)( + LiteRtTensorBuffer tensor_buffer, LiteRtEvent* event); + // litert_tensor_buffer.h: LiteRtSetTensorBufferEvent + LiteRtStatus (*litert_set_tensor_buffer_event)( + LiteRtTensorBuffer tensor_buffer, LiteRtEvent event); + // litert_tensor_buffer.h: LiteRtClearTensorBufferEvent + LiteRtStatus (*litert_clear_tensor_buffer_event)( + LiteRtTensorBuffer tensor_buffer); + // litert_tensor_buffer.h: LiteRtLockTensorBuffer + LiteRtStatus (*litert_lock_tensor_buffer)( + LiteRtTensorBuffer tensor_buffer, void** host_mem_addr, + LiteRtTensorBufferLockMode lock_mode); + // litert_tensor_buffer.h: LiteRtUnlockTensorBuffer + LiteRtStatus (*litert_unlock_tensor_buffer)(LiteRtTensorBuffer buffer); + // litert_tensor_buffer.h: LiteRtClearTensorBuffer + LiteRtStatus (*litert_clear_tensor_buffer)(LiteRtTensorBuffer buffer); + // litert_tensor_buffer.h: LiteRtDestroyTensorBuffer + void (*litert_destroy_tensor_buffer)(LiteRtTensorBuffer buffer); + + // + // LiteRtEvent + // + // litert_event.h: LiteRtCreateEventFromSyncFenceFd + LiteRtStatus (*litert_create_event_from_sync_fence_fd)(LiteRtEnvironment env, + int sync_fence_fd, + bool owns_fd, + LiteRtEvent* event); + // litert_event.h: LiteRtCreateEventFromOpenClEvent + LiteRtStatus (*litert_create_event_from_opencl_event)(LiteRtEnvironment env, + LiteRtClEvent cl_event, + LiteRtEvent* event); + // litert_event.h: LiteRtCreateEventFromEglSyncFence + LiteRtStatus (*litert_create_event_from_egl_sync_fence)( + LiteRtEnvironment env, LiteRtEglSyncKhr egl_sync, LiteRtEvent* event); + // litert_event.h: LiteRtCreateManagedEvent + LiteRtStatus (*litert_create_managed_event)(LiteRtEnvironment env, + LiteRtEventType type, + LiteRtEvent* event); + // litert_event.h: LiteRtSetCustomEvent + LiteRtStatus (*litert_set_custom_event)(LiteRtEvent event, + LiteRtCustomEvent custom_event); + // litert_event.h: LiteRtGetEventEventType + LiteRtStatus (*litert_get_event_event_type)(LiteRtEvent event, + LiteRtEventType* type); + // litert_event.h: LiteRtGetEventSyncFenceFd + LiteRtStatus (*litert_get_event_sync_fence_fd)(LiteRtEvent event, + int* sync_fence_fd); + // litert_event.h: LiteRtGetEventOpenClEvent + LiteRtStatus (*litert_get_event_opencl_event)(LiteRtEvent event, + LiteRtClEvent* cl_event); + // litert_event.h: LiteRtGetEventEglSync + LiteRtStatus (*litert_get_event_egl_sync)(LiteRtEvent event, + LiteRtEglSyncKhr* egl_sync); + // litert_event.h: LiteRtGetEventCustomNativeEvent + LiteRtStatus (*litert_get_event_custom_native_event)(LiteRtEvent event, + void** native); + // litert_event.h: LiteRtWaitEvent + LiteRtStatus (*litert_wait_event)(LiteRtEvent event, int64_t timeout_in_ms); + // litert_event.h: LiteRtSignalEvent + LiteRtStatus (*litert_signal_event)(LiteRtEvent event); + // litert_event.h: LiteRtIsEventSignaled + LiteRtStatus (*litert_is_event_signaled)(LiteRtEvent event, + bool* is_signaled); + // litert_event.h: LiteRtDupFdEvent + LiteRtStatus (*litert_dup_fd_event)(LiteRtEvent event, int* dup_fd); + // litert_event.h: LiteRtDestroyEvent + void (*litert_destroy_event)(LiteRtEvent event); + + // + // LiteRtLayout + // + // litert_layout.h: LiteRtGetNumLayoutElements + LiteRtStatus (*litert_get_num_layout_elements)(const LiteRtLayout* layout, + size_t* num_elements); + // litert_layout.h: LiteRtIsSameLayout + LiteRtStatus (*litert_is_same_layout)(const LiteRtLayout* layout1, + const LiteRtLayout* layout2, + bool* result); + + // + // LiteRtMetrics + // + // litert_metrics.h: LiteRtCreateMetrics + LiteRtStatus (*litert_create_metrics)(LiteRtMetrics* metrics); + // litert_metrics.h: LiteRtGetNumMetrics + LiteRtStatus (*litert_get_num_metrics)(LiteRtMetrics metrics, + int* num_metrics); + // litert_metrics.h: LiteRtGetMetric + LiteRtStatus (*litert_get_metric)(LiteRtMetrics metrics, int metric_index, + LiteRtMetric* metric); + // litert_metrics.h: LiteRtDestroyMetrics + void (*litert_destroy_metrics)(LiteRtMetrics metrics); + + // + // LiteRtOpaqueOptions + // + // litert_opaque_options.h: LiteRtCreateOpaqueOptions + LiteRtStatus (*litert_create_opaque_options)( + const char* payload_identifier, void* payload_data, + void (*payload_destructor)(void* payload_data), + LiteRtOpaqueOptions* options); + // litert_opaque_options.h: LiteRtDestroyOpaqueOptions + void (*litert_destroy_opaque_options)(LiteRtOpaqueOptions options); + // litert_opaque_options.h: LiteRtGetOpaqueOptionsIdentifier + LiteRtStatus (*litert_get_opaque_options_identifier)( + LiteRtOpaqueOptions options, const char** payload_identifier); + // litert_opaque_options.h: LiteRtGetOpaqueOptionsData + LiteRtStatus (*litert_get_opaque_options_data)(LiteRtOpaqueOptions options, + void** payload_data); + // litert_opaque_options.h: LiteRtFindOpaqueOptionsData + LiteRtStatus (*litert_find_opaque_options_data)( + LiteRtOpaqueOptions options, const char* payload_identifier, + void** payload_data); + // litert_opaque_options.h: LiteRtGetNextOpaqueOptions + LiteRtStatus (*litert_get_next_opaque_options)(LiteRtOpaqueOptions* options); + // litert_opaque_options.h: LiteRtAppendOpaqueOptions + LiteRtStatus (*litert_append_opaque_options)( + LiteRtOpaqueOptions* options, LiteRtOpaqueOptions appended_options); + // litert_opaque_options.h: LiteRtPopOpaqueOptions + LiteRtStatus (*litert_pop_opaque_options)(LiteRtOpaqueOptions* options); + // litert_opaque_options.h: LiteRtSetOpaqueOptionsHash + LiteRtStatus (*litert_set_opaque_options_hash)( + LiteRtOpaqueOptions options, + LiteRtOpaqueOptionsHashFunc payload_hash_func); + // litert_opaque_options.h: LiteRtGetOpaqueOptionsHash + LiteRtStatus (*litert_get_opaque_options_hash)(LiteRtOpaqueOptions options, + uint64_t* hash); + + // + // LiteRtOptions + // + // litert_options.h: LiteRtCreateOptions + LiteRtStatus (*litert_create_options)(LiteRtOptions* options); + // litert_options.h: LiteRtDestroyOptions + void (*litert_destroy_options)(LiteRtOptions options); + // litert_options.h: LiteRtSetOptionsHardwareAccelerators + LiteRtStatus (*litert_set_options_hardware_accelerators)( + LiteRtOptions options, LiteRtHwAcceleratorSet hardware_accelerators); + // litert_options.h: LiteRtGetOptionsHardwareAccelerators + LiteRtStatus (*litert_get_options_hardware_accelerators)( + LiteRtOptions options, LiteRtHwAcceleratorSet* hardware_accelerators); + // litert_options.h: LiteRtAddOpaqueOptions + LiteRtStatus (*litert_add_opaque_options)(LiteRtOptions options, + LiteRtOpaqueOptions opaque_options); + // litert_options.h: LiteRtGetOpaqueOptions + LiteRtStatus (*litert_get_opaque_options)( + LiteRtOptions options, LiteRtOpaqueOptions* opaque_options); + // litert_options.h: LiteRtAddCustomOpKernelOption + LiteRtStatus (*litert_add_custom_op_kernel_option)( + LiteRtOptions options, const char* custom_op_name, int custom_op_version, + const LiteRtCustomOpKernel* custom_op_kernel, + void* custom_op_kernel_user_data); + // litert_options.h: LiteRtAddExternalTensorBinding + LiteRtStatus (*litert_add_external_tensor_binding)(LiteRtOptions options, + const char* signature_name, + const char* tensor_name, + void* data, + int size_bytes); + + // + // Scheduling info APIs (litert_compiled_model.h) + // + // litert_compiled_model.h: LiteRtCompiledModelSetSchedulingInfo + LiteRtStatus (*litert_compiled_model_set_scheduling_info)( + LiteRtCompiledModel compiled_model, + const LiteRtSchedulingInfo* scheduling_info); + // litert_compiled_model.h: LiteRtRunCompiledModelWithSchedulingInfo + LiteRtStatus (*litert_run_compiled_model_with_scheduling_info)( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + size_t num_input_buffers, LiteRtTensorBuffer* input_buffers, + size_t num_output_buffers, LiteRtTensorBuffer* output_buffers, + const LiteRtSchedulingInfo* scheduling_info); + // litert_compiled_model.h: LiteRtRunCompiledModelAsyncWithSchedulingInfo + LiteRtStatus (*litert_run_compiled_model_async_with_scheduling_info)( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + size_t num_input_buffers, LiteRtTensorBuffer* input_buffers, + size_t num_output_buffers, LiteRtTensorBuffer* output_buffers, + bool* async, const LiteRtSchedulingInfo* scheduling_info); + + // litert_environment.h: LiteRtEnvironmentSupportsFP16 + LiteRtStatus (*litert_environment_supports_fp16)( + LiteRtEnvironment environment, bool* is_supported); + + // litert_model.h: LiteRtCreateModelFromFd + LiteRtStatus (*litert_create_model_from_fd)(LiteRtEnvironment environment, + int fd, size_t offset, + size_t size, LiteRtModel* model); + // litert_model.h: LiteRtGetBlockWiseQuantization + LiteRtStatus (*litert_get_block_wise_quantization)( + LiteRtTensor tensor, + LiteRtQuantizationBlockWise* block_wise_quantization); + + // litert_accelerator.h: LiteRtGetNumAccelerators + LiteRtStatus (*litert_get_num_accelerators)( + LiteRtEnvironment environment, LiteRtParamIndex* num_accelerators); + // litert_accelerator.h: LiteRtGetAccelerator + LiteRtStatus (*litert_get_accelerator)(LiteRtEnvironment environment, + LiteRtParamIndex index, + LiteRtAccelerator* accelerator); + // litert_accelerator.h: LiteRtGetAcceleratorHardwareSupport + LiteRtStatus (*litert_get_accelerator_hardware_support)( + LiteRtAcceleratorConst accelerator, + LiteRtHwAcceleratorSet* supported_hardware); + // litert_compiled_model.h: LiteRtCompiledModelIsNonCpuFullyAccelerated + // This API was added in version 1.1.0. + LiteRtStatus (*litert_compiled_model_is_non_cpu_fully_accelerated)( + LiteRtCompiledModel compiled_model, bool* non_cpu_fully_accelerated); +} LiteRtRuntimeCApiStruct; + +// LINT.ThenChange(:version_number) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_RUNTIME_C_API_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_runtime_context.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_runtime_context.h new file mode 100644 index 0000000000000000000000000000000000000000..645a299df566463d3fa011a541b0c16271a6e9ef --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_runtime_context.h @@ -0,0 +1,358 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_RUNTIME_CONTEXT_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_RUNTIME_CONTEXT_H_ + +#include +#include + +#include "litert/c/internal/litert_abi_header.h" +#include "litert/c/litert_any.h" +#include "litert/c/litert_common.h" +#include "litert/c/litert_custom_tensor_buffer.h" +#include "litert/c/litert_environment_options.h" +#include "litert/c/litert_event_type.h" +#include "litert/c/litert_gl_types.h" +#include "litert/c/litert_metrics.h" +#include "litert/c/litert_model_types.h" +#include "litert/c/litert_opencl_types.h" +#include "litert/c/litert_tensor_buffer_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#include "tflite/c/c_api_types.h" + +typedef struct TfLiteTensor TfLiteTensor; +typedef struct AHardwareBuffer AHardwareBuffer; + +/// A function table that contains LiteRT C APIs needed for Accelerators. +/// +/// @note This concrete type is shared with LiteRT runtime and Accelerators and +/// Dispatch APIs. So it must be ABI stable. +// LINT.IfChange(runtime_context_table) +typedef struct LiteRtRuntimeContext { + LiteRtAbiHeader abi_header; + + LiteRtStatus (*create_tensor_buffer_requirements)( + int num_supported_tensor_buffer_types, + const LiteRtTensorBufferType* supported_tensor_buffer_types, + size_t buffer_size, int num_strides, const uint32_t* strides, + LiteRtTensorBufferRequirements* requirements); + + // third_party/odml/litert/litert/c/internal/litert_external_litert_buffer_context.h + LiteRtStatus (*get_external_litert_buffer_context_tensor_buffer)( + LiteRtExternalLiteRtBufferContext context, const TfLiteTensor* tensor, + LiteRtTensorBuffer* tensor_buffer); + LiteRtStatus (*external_litert_buffer_context_create_tensor_buffer)( + LiteRtExternalLiteRtBufferContext context, const TfLiteTensor* tensor, + LiteRtTensorBuffer* buffer); + LiteRtStatus (*external_litert_buffer_context_register_tensor_buffer)( + LiteRtExternalLiteRtBufferContext context, const TfLiteTensor* tensor, + LiteRtTensorBuffer buffer); + LiteRtStatus (*external_litert_buffer_context_unregister_tensor_buffer)( + LiteRtExternalLiteRtBufferContext context, const TfLiteTensor* tensor); + LiteRtStatus (*external_litert_buffer_context_register_buffer_requirements)( + LiteRtExternalLiteRtBufferContext context, const TfLiteTensor* tensor, + LiteRtTensorBufferRequirements buffer_requirements); + LiteRtStatus (*external_litert_buffer_context_get_environment)( + LiteRtExternalLiteRtBufferContext context, LiteRtEnvironment* env); + LiteRtStatus (*external_litert_buffer_context_is_async_execution_mode)( + LiteRtExternalLiteRtBufferContext context, bool* is_async_execution_mode); + void (*external_litert_buffer_context_destroy)( + LiteRtExternalLiteRtBufferContext context); + + LiteRtStatus (*get_opaque_options)(LiteRtOptions options, + LiteRtOpaqueOptions* opaque_options); + LiteRtStatus (*find_opaque_options_data)(LiteRtOpaqueOptions options, + const char* payload_identifier, + void** payload_data); + void (*destroy_options)(LiteRtOptions options); + LiteRtStatus (*get_environment_options)(LiteRtEnvironment env, + LiteRtEnvironmentOptions* options); + LiteRtStatus (*get_environment_options_value)( + LiteRtEnvironmentOptions options, LiteRtEnvOptionTag tag, + LiteRtAny* option_value); + void (*environment_has_gpu_environment)(LiteRtEnvironment environment, + bool* has_gpu_environment); + LiteRtStatus (*add_environment_options)(LiteRtEnvironment environment, + int num_options, + const LiteRtEnvOption* options, + bool overwrite); + LiteRtStatus (*gpu_environment_create)(LiteRtEnvironment environment, + int num_options, + const LiteRtEnvOption* options); + + LiteRtStatus (*wrap_delegate)(TfLiteOpaqueDelegate* delegate, + void (*deleter)(TfLiteOpaqueDelegate*), + LiteRtDelegateWrapper* wrapper); + LiteRtStatus (*unwrap_delegate)(LiteRtDelegateWrapper wrapper, + TfLiteOpaqueDelegate** delegate); + + // third_party/odml/litert/litert/c/litert_tensor_buffer.h + LiteRtStatus (*create_tensor_buffer_from_host_memory)( + const LiteRtRankedTensorType* tensor_type, void* host_buffer_addr, + size_t host_buffer_size, LiteRtHostMemoryDeallocator deallocator, + LiteRtTensorBuffer* buffer); + LiteRtStatus (*create_managed_tensor_buffer)( + LiteRtEnvironment env, LiteRtTensorBufferType buffer_type, + const LiteRtRankedTensorType* tensor_type, size_t buffer_size, + LiteRtTensorBuffer* buffer); + void (*destroy_tensor_buffer)(LiteRtTensorBuffer buffer); + LiteRtStatus (*get_tensor_buffer_type)(LiteRtTensorBuffer tensor_buffer, + LiteRtTensorBufferType* buffer_type); + LiteRtStatus (*get_tensor_buffer_tensor_type)( + LiteRtTensorBuffer tensor_buffer, LiteRtRankedTensorType* tensor_type); + LiteRtStatus (*get_tensor_buffer_size)(LiteRtTensorBuffer tensor_buffer, + size_t* buffer_size); + LiteRtStatus (*get_tensor_buffer_packed_size)( + LiteRtTensorBuffer tensor_buffer, size_t* size); + LiteRtStatus (*get_tensor_buffer_offset)(LiteRtTensorBuffer tensor_buffer, + size_t* offset); + LiteRtStatus (*lock_tensor_buffer)(LiteRtTensorBuffer tensor_buffer, + void** host_mem_addr, + LiteRtTensorBufferLockMode mode); + LiteRtStatus (*unlock_tensor_buffer)(LiteRtTensorBuffer tensor_buffer); + LiteRtStatus (*get_tensor_buffer_host_memory)( + LiteRtTensorBuffer tensor_buffer, void** host_memory_addr); + LiteRtStatus (*get_tensor_buffer_opencl_memory)( + LiteRtTensorBuffer tensor_buffer, LiteRtClMem* cl_mem_addr); + LiteRtStatus (*get_tensor_buffer_gl_buffer)(LiteRtTensorBuffer tensor_buffer, + LiteRtGLenum* target, + LiteRtGLuint* id, + size_t* size_bytes, + size_t* offset); + LiteRtStatus (*get_tensor_buffer_custom_tensor_buffer_handle)( + LiteRtTensorBuffer tensor_buffer, HwMemoryHandle* hw_memory_handle); + LiteRtStatus (*get_tensor_buffer_ahwb)(LiteRtTensorBuffer tensor_buffer, + AHardwareBuffer** ahwb); + LiteRtStatus (*get_tensor_buffer_dma_buf_buffer)( + LiteRtTensorBuffer tensor_buffer, void** dmabuf_buffer_addr, + int* dmabuf_buffer_fd); + LiteRtStatus (*get_tensor_buffer_fast_rpc_buffer)( + LiteRtTensorBuffer tensor_buffer, void** host_buffer_addr, int* fd); + LiteRtStatus (*has_tensor_buffer_event)(LiteRtTensorBuffer tensor_buffer, + bool* has_event); + LiteRtStatus (*get_tensor_buffer_event)(LiteRtTensorBuffer tensor_buffer, + LiteRtEvent* event); + LiteRtStatus (*set_tensor_buffer_event)(LiteRtTensorBuffer tensor_buffer, + LiteRtEvent event); + + // third_party/odml/litert/litert/c/litert_event.h + LiteRtStatus (*create_managed_event)(LiteRtEnvironment env, + LiteRtEventType event_type, + LiteRtEvent* event); + LiteRtStatus (*create_event_from_sync_fence_fd)(LiteRtEnvironment env, + int sync_fence_fd, + bool owns_fd, + LiteRtEvent* event); + LiteRtStatus (*get_event_event_type)(LiteRtEvent event, + LiteRtEventType* type); + LiteRtStatus (*get_event_sync_fence_fd)(LiteRtEvent event, + int* sync_fence_fd); + LiteRtStatus (*create_event_from_opencl_event)(LiteRtEnvironment env, + LiteRtClEvent cl_event, + LiteRtEvent* event); + LiteRtStatus (*get_event_opencl_event)(LiteRtEvent event, + LiteRtClEvent* cl_event); + LiteRtStatus (*set_custom_event)(LiteRtEvent event, + LiteRtCustomEvent custom_event); + LiteRtStatus (*get_custom_event)(LiteRtEvent event, + LiteRtCustomEvent* custom_event); + LiteRtStatus (*wait_event)(LiteRtEvent event, int64_t timeout_in_ms); + // Returns the per-run options handle for the current invocation. The + // returned options handle is borrowed and owned by the runtime. The caller + // must NOT destroy it. The handle is only valid during the current + // execution (inference run) and must not be stored. + LiteRtStatus (*external_litert_buffer_context_get_run_options)( + LiteRtExternalLiteRtBufferContext context, LiteRtOptions* run_options); + + // Added in version 1.1.0 + // Returns the hardware accelerator set configured in the given options. + LiteRtStatus (*get_options_hardware_accelerators)( + LiteRtOptions options, LiteRtHwAcceleratorSet* hardware_accelerators); + + // Added in version 1.2.0 + // Append a metric to the metrics object. + LiteRtStatus (*append_metric)(LiteRtMetrics metrics, + const LiteRtMetric* metric); +} LiteRtRuntimeContext; +// LINT.ThenChange(./litert_runtime_context.cc:runtime_context_version) + +// ABI compatibility check for LiteRtRuntimeContext. +// +// Note: Please get review from the LiteRT ABI compatibility team when you make +// changes to this struct. +#if defined(__cplusplus) && defined(__SIZEOF_POINTER__) && \ + __SIZEOF_POINTER__ == 8 +static_assert(sizeof(LiteRtRuntimeContext) == 416, + "LiteRtRuntimeContext size mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, abi_header) == 0, + "LiteRtRuntimeContext abi_header offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, create_tensor_buffer_requirements) == 8, + "LiteRtRuntimeContext create_tensor_buffer_requirements offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, + get_external_litert_buffer_context_tensor_buffer) == 16, + "LiteRtRuntimeContext get_external_litert_buffer_context_tensor_buffer " + "offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, + external_litert_buffer_context_create_tensor_buffer) == 24, + "LiteRtRuntimeContext external_litert_buffer_context_create_tensor_buffer " + "offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, + external_litert_buffer_context_register_tensor_buffer) == 32, + "LiteRtRuntimeContext " + "external_litert_buffer_context_register_tensor_buffer offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, + external_litert_buffer_context_unregister_tensor_buffer) == 40, + "LiteRtRuntimeContext " + "external_litert_buffer_context_unregister_tensor_buffer offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, + external_litert_buffer_context_register_buffer_requirements) == 48, + "LiteRtRuntimeContext " + "external_litert_buffer_context_register_buffer_requirements offset " + "mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, + external_litert_buffer_context_get_environment) == 56, + "LiteRtRuntimeContext " + "external_litert_buffer_context_get_environment offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, + external_litert_buffer_context_is_async_execution_mode) == 64, + "LiteRtRuntimeContext " + "external_litert_buffer_context_is_async_execution_mode offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, + external_litert_buffer_context_destroy) == 72, + "LiteRtRuntimeContext external_litert_buffer_context_destroy " + "offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, get_opaque_options) == 80, + "LiteRtRuntimeContext get_opaque_options offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, find_opaque_options_data) == 88, + "LiteRtRuntimeContext find_opaque_options_data offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, destroy_options) == 96, + "LiteRtRuntimeContext destroy_options offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, get_environment_options) == 104, + "LiteRtRuntimeContext get_environment_options offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, get_environment_options_value) == 112, + "LiteRtRuntimeContext get_environment_options_value offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, environment_has_gpu_environment) == 120, + "LiteRtRuntimeContext environment_has_gpu_environment offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, add_environment_options) == 128, + "LiteRtRuntimeContext add_environment_options offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, gpu_environment_create) == 136, + "LiteRtRuntimeContext gpu_environment_create offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, wrap_delegate) == 144, + "LiteRtRuntimeContext wrap_delegate offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, unwrap_delegate) == 152, + "LiteRtRuntimeContext unwrap_delegate offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, + create_tensor_buffer_from_host_memory) == 160, + "LiteRtRuntimeContext create_tensor_buffer_from_host_memory " + "offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, create_managed_tensor_buffer) == 168, + "LiteRtRuntimeContext create_managed_tensor_buffer offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, destroy_tensor_buffer) == 176, + "LiteRtRuntimeContext destroy_tensor_buffer offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, get_tensor_buffer_type) == 184, + "LiteRtRuntimeContext get_tensor_buffer_type offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, get_tensor_buffer_tensor_type) == 192, + "LiteRtRuntimeContext get_tensor_buffer_tensor_type offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, get_tensor_buffer_size) == 200, + "LiteRtRuntimeContext get_tensor_buffer_size offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, get_tensor_buffer_packed_size) == 208, + "LiteRtRuntimeContext get_tensor_buffer_packed_size offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, get_tensor_buffer_offset) == 216, + "LiteRtRuntimeContext get_tensor_buffer_offset offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, lock_tensor_buffer) == 224, + "LiteRtRuntimeContext lock_tensor_buffer offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, unlock_tensor_buffer) == 232, + "LiteRtRuntimeContext unlock_tensor_buffer offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, get_tensor_buffer_host_memory) == 240, + "LiteRtRuntimeContext get_tensor_buffer_host_memory offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, get_tensor_buffer_opencl_memory) == 248, + "LiteRtRuntimeContext get_tensor_buffer_opencl_memory offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, get_tensor_buffer_gl_buffer) == 256, + "LiteRtRuntimeContext get_tensor_buffer_gl_buffer offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, + get_tensor_buffer_custom_tensor_buffer_handle) == 264, + "LiteRtRuntimeContext " + "get_tensor_buffer_custom_tensor_buffer_handle offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, get_tensor_buffer_ahwb) == 272, + "LiteRtRuntimeContext get_tensor_buffer_ahwb offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, get_tensor_buffer_dma_buf_buffer) == 280, + "LiteRtRuntimeContext get_tensor_buffer_dma_buf_buffer offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, get_tensor_buffer_fast_rpc_buffer) == 288, + "LiteRtRuntimeContext get_tensor_buffer_fast_rpc_buffer offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, has_tensor_buffer_event) == 296, + "LiteRtRuntimeContext has_tensor_buffer_event offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, get_tensor_buffer_event) == 304, + "LiteRtRuntimeContext get_tensor_buffer_event offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, set_tensor_buffer_event) == 312, + "LiteRtRuntimeContext set_tensor_buffer_event offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, create_managed_event) == 320, + "LiteRtRuntimeContext create_managed_event offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, create_event_from_sync_fence_fd) == 328, + "LiteRtRuntimeContext create_event_from_sync_fence_fd offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, get_event_event_type) == 336, + "LiteRtRuntimeContext get_event_event_type offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, get_event_sync_fence_fd) == 344, + "LiteRtRuntimeContext get_event_sync_fence_fd offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, create_event_from_opencl_event) == 352, + "LiteRtRuntimeContext create_event_from_opencl_event offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, get_event_opencl_event) == 360, + "LiteRtRuntimeContext get_event_opencl_event offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, set_custom_event) == 368, + "LiteRtRuntimeContext set_custom_event offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, get_custom_event) == 376, + "LiteRtRuntimeContext get_custom_event offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, wait_event) == 384, + "LiteRtRuntimeContext wait_event offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, + external_litert_buffer_context_get_run_options) == 392, + "LiteRtRuntimeContext " + "external_litert_buffer_context_get_run_options offset mismatch"); +static_assert( + offsetof(LiteRtRuntimeContext, get_options_hardware_accelerators) == 400, + "LiteRtRuntimeContext get_options_hardware_accelerators offset mismatch"); +static_assert(offsetof(LiteRtRuntimeContext, append_metric) == 408, + "LiteRtRuntimeContext append_metric offset mismatch"); +#endif // __cplusplus + +LiteRtRuntimeContext* LrtGetRuntimeContext(); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_RUNTIME_CONTEXT_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_scheduling_info.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_scheduling_info.h new file mode 100644 index 0000000000000000000000000000000000000000..7a00ae02b46966a1180ff23339633cd38452ba6f --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_scheduling_info.h @@ -0,0 +1,94 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_SCHEDULING_INFO_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_SCHEDULING_INFO_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Bitmask values describing which fields in `LiteRtSchedulingInfo` are +// explicitly provided. +typedef enum LiteRtSchedulingInfoField { + kLiteRtSchedulingInfoFieldOriginalUid = 1u << 0, + kLiteRtSchedulingInfoFieldDebugFeatureId = 1u << 1, + kLiteRtSchedulingInfoFieldJobPriority = 1u << 2, + kLiteRtSchedulingInfoFieldGroupId = 1u << 3, +} LiteRtSchedulingInfoField; + +enum { + // Group id is a raw 16-byte UUID value. + kLiteRtSchedulingInfoGroupIdSize = 16, +}; + +typedef enum LiteRtSchedulingJobPriority { + // Lower numeric values indicate higher priority. + kLiteRtSchedulingInfoJobPriorityHighest = 0, + kLiteRtSchedulingInfoJobPriorityLowest = 1000, +} LiteRtSchedulingJobPriority; + +// Scheduling information associated with an inference request. This data is +// passed from application code through LiteRT to vendor delegates (e.g. NPU +// dispatch implementations). +// +// Fields are considered set if the corresponding bit is present in +// `fields_mask`. +// +// This is reserved for 1P access only (Android NPU Manager). +// +// Note: This concrete type is shared with LiteRT runtime and Dispatch APIs. So +// it must be ABI stable. +typedef struct LiteRtSchedulingInfo { + uint32_t fields_mask; + int32_t original_uid; + // Null-terminated debug feature string, e.g. + // "com.android.aicore.text_summarization". + const char* debug_feature_id; + // Priority in [kLiteRtSchedulingInfoJobPriorityHighest, + // kLiteRtSchedulingInfoJobPriorityLowest], where smaller values indicate + // higher priority. + int32_t job_priority; + // Raw 16-byte UUID identifying a related scheduling group. + uint8_t group_id[kLiteRtSchedulingInfoGroupIdSize]; +} LiteRtSchedulingInfo; + +// ABI compatibility check for LiteRtSchedulingInfo. +// +// Note: Please get review from the LiteRT ABI compatibility team when you make +// changes to this struct. +#if defined(__cplusplus) && defined(__SIZEOF_POINTER__) && \ + __SIZEOF_POINTER__ == 8 +static_assert(sizeof(LiteRtSchedulingInfo) == 40, + "LiteRtSchedulingInfo size mismatch"); +static_assert(offsetof(LiteRtSchedulingInfo, fields_mask) == 0, + "LiteRtSchedulingInfo fields_mask offset mismatch"); +static_assert(offsetof(LiteRtSchedulingInfo, original_uid) == 4, + "LiteRtSchedulingInfo original_uid offset mismatch"); +static_assert(offsetof(LiteRtSchedulingInfo, debug_feature_id) == 8, + "LiteRtSchedulingInfo debug_feature_id offset mismatch"); +static_assert(offsetof(LiteRtSchedulingInfo, job_priority) == 16, + "LiteRtSchedulingInfo job_priority offset mismatch"); +static_assert(offsetof(LiteRtSchedulingInfo, group_id) == 20, + "LiteRtSchedulingInfo group_id offset mismatch"); +#endif // __cplusplus + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_SCHEDULING_INFO_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_tensor_buffer_registry.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_tensor_buffer_registry.h new file mode 100644 index 0000000000000000000000000000000000000000..75a6cdc06986a63cfa2f62baf57114c28c9c201e --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/internal/litert_tensor_buffer_registry.h @@ -0,0 +1,46 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_TENSOR_BUFFER_REGISTRY_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_TENSOR_BUFFER_REGISTRY_H_ + +#include + +#include "litert/c/litert_common.h" +#include "litert/c/litert_custom_tensor_buffer.h" +#include "litert/c/litert_environment_options.h" +#include "litert/c/litert_tensor_buffer_types.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Registers custom tensor buffer handlers for the given buffer type. +LiteRtStatus LiteRtRegisterTensorBufferHandlers( + LiteRtEnvironment env, LiteRtTensorBufferType buffer_type, + CreateCustomTensorBuffer create_func, + DestroyCustomTensorBuffer destroy_func, LockCustomTensorBuffer lock_func, + UnlockCustomTensorBuffer unlock_func, ClearCustomTensorBuffer clear_func, + ImportCustomTensorBuffer import_func, LiteRtEnvOptionTag device_tag, + LiteRtEnvOptionTag queue_tag); + +// Retrieves a singleton instance of the tensor buffer registry. +LiteRtStatus LiteRtGetTensorBufferRegistry(LiteRtEnvironment env, + void** registry); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_INTERNAL_LITERT_TENSOR_BUFFER_REGISTRY_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_any.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_any.h new file mode 100644 index 0000000000000000000000000000000000000000..a37b3418e38873818db97a24ebc8b5b19b9e3d5a --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_any.h @@ -0,0 +1,75 @@ +// Copyright 2024 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_ANY_H_ +#define ODML_LITERT_LITERT_C_LITERT_ANY_H_ + +#include // NOLINT: To use bool type in C +#include + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +typedef enum { + kLiteRtAnyTypeNone = 0, + kLiteRtAnyTypeBool = 1, + kLiteRtAnyTypeInt = 2, + kLiteRtAnyTypeReal = 3, + kLiteRtAnyTypeString = 8, + kLiteRtAnyTypeVoidPtr = 9, +} LiteRtAnyType; + +inline const char* LiteRtAnyTypeToString(LiteRtAnyType type) { + switch (type) { + case kLiteRtAnyTypeNone: + return "kLiteRtAnyTypeNone"; + case kLiteRtAnyTypeBool: + return "kLiteRtAnyTypeBool"; + case kLiteRtAnyTypeInt: + return "kLiteRtAnyTypeInt"; + case kLiteRtAnyTypeReal: + return "kLiteRtAnyTypeReal"; + case kLiteRtAnyTypeString: + return "kLiteRtAnyTypeString"; + case kLiteRtAnyTypeVoidPtr: + return "kLiteRtAnyTypeVoidPtr"; + } + return "Unknown"; +} + +/// An object that holds various value type. +/// +/// @note This concrete type is part of the public API and is ABI stable. +typedef struct { + LiteRtAnyType type; + union { + bool bool_value; + int64_t int_value; + double real_value; + const char* str_value; + const void* ptr_value; + }; +} LiteRtAny; + +#if defined(__cplusplus) && defined(__SIZEOF_POINTER__) && \ + __SIZEOF_POINTER__ == 8 +static_assert(sizeof(LiteRtAny) == 16, "LiteRtAny size mismatch"); +#endif // __cplusplus + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_ANY_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_builder.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_builder.h new file mode 100644 index 0000000000000000000000000000000000000000..a89f76e1ad36b48e25bdc8d69c6bc8235bdcdef6 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_builder.h @@ -0,0 +1,86 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_BUILDER_H_ +#define ODML_LITERT_LITERT_C_LITERT_BUILDER_H_ + +#include // NOLINT: To use bool type in C +#include +#include + +#include "litert/c/litert_common.h" +#include "litert/c/litert_model_types.h" +#include "litert/c/litert_op_code.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// +// LiteRtBuilder (Expirementatal API) +// + +// Creates a new tensor within the graph being rewritten. +// This function allows specifying all properties of the tensor, including its +// type, shape (ranked or unranked), weight data, quantization parameters, and +// name. The new tensor is created within the context of the provided +// builder. +LiteRtStatus LiteRtBuilderBuildTensor( + LiteRtBuilder builder, LiteRtTensorTypeId tensor_type_id, + LiteRtRankedTensorType ranked_tensor_type, + LiteRtUnrankedTensorType unranked_tensor_type, LiteRtWeights weights, + LiteRtQuantizationTypeId quantization_type_id, + LiteRtQuantizationPerTensor per_tensor_quantization, + LiteRtQuantizationPerChannel per_channel_quantization, + LiteRtQuantizationBlockWise block_wise_quantization, const char* name, + LiteRtTensor* new_tensor); + +// Builds weights for a tensor. Builder will take the ownership of the data, +// the built weights will be owned by the tensor before calling ApplyChanges(). +LiteRtStatus LiteRtBuilderBuildWeights(LiteRtBuilder builder, + const uint8_t* data, + LiteRtParamIndex size, + LiteRtTensor tensor, + LiteRtWeights* new_weights); + +// Creates a new OP within the graph being rewritten. +// This function takes the OP code, input tensors, and output tensors +// to construct a new op in the graph. +// The new op is created within the context of the provided builder. +LiteRtStatus LiteRtBuilderBuildOp(LiteRtBuilder builder, LiteRtOpCode op_code, + LiteRtParamIndex num_inputs, + LiteRtTensor* inputs, + LiteRtParamIndex num_outputs, + LiteRtTensor* outputs, LiteRtOp* new_op); + +// Removes an existing OP from the graph being rewritten. +// This function is performed transactionally within the builder context. +LiteRtStatus LiteRtBuilderEraseOp(LiteRtBuilder builder, LiteRtOp op_to_erase); + +struct LiteRtCompilerContext; + +// Function pointer type for a rewrite pattern (also known as a transformation). +// A LiteRtPatternFn takes a LiteRtCompilerContext, an LiteRtBuilder and an +// LiteRtOp instance. It can analyze the OP and use the builder to modify +// the graph, for example, by replacing the OP with a sequence of other +// operations. +typedef LiteRtStatus (*LiteRtPatternFn)( + const struct LiteRtCompilerContext* context, LiteRtBuilder builder, + LiteRtOp op); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_BUILDER_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_common.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_common.h new file mode 100644 index 0000000000000000000000000000000000000000..f5562bea71e28740caa9b88fe1e4f5f9f053e584 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_common.h @@ -0,0 +1,430 @@ +// Copyright 2024 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_COMMON_H_ +#define ODML_LITERT_LITERT_C_LITERT_COMMON_H_ + +#include +#include + +#include "litert/build_common/build_config.h" // IWYU pragma: keep + +// Define LITERT_WINDOWS_OS if the current OS is Windows. +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || \ + defined(__NT__) || defined(_WIN64) +#define LITERT_WINDOWS_OS 1 +#endif + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Define LITERT_CAPI_EXPORT macro to export a function properly with a shared +// library. +#if defined(LITERT_WINDOWS_OS) +#if defined(LITERT_STATIC) +#define LITERT_CAPI_EXPORT +#elif defined(LITERT_COMPILE_LIBRARY) +#define LITERT_CAPI_EXPORT __declspec(dllexport) +#else +#define LITERT_CAPI_EXPORT __declspec(dllimport) +#endif // LITERT_STATIC +#else +#define LITERT_CAPI_EXPORT __attribute__((visibility("default"))) +#endif // LITERT_WINDOWS_OS + +#if defined(__linux__) +// Disable CFI check for calling shared library functions. +#define LITERT_NO_CFI_CHECK __attribute__((no_sanitize("cfi-icall"))) +#else +#define LITERT_NO_CFI_CHECK +#endif // __linux__ + +// Declares canonical opaque type. + +#ifdef __cplusplus +#define LITERT_DEFINE_HANDLE(name) \ + typedef class name##T* name; \ + typedef const class name##T* name##Const +#else // __cplusplus +#define LITERT_DEFINE_HANDLE(name) \ + typedef struct name##T* name; \ + typedef const struct name##T* name##Const +#endif // __cplusplus + +#define LITERT_DEFINE_HANDLE_STRUCT(name) \ + typedef struct name##T* name; \ + typedef const struct name##T* name##Const + +// LiteRT Accelerator object. (litert_accelerator.h) +LITERT_DEFINE_HANDLE(LiteRtAccelerator); +// LiteRT DelegateWrapper object. (litert_delegate_wrapper.h). +// This wraps a TF Lite delegate (TfLiteOpaqueDelegate*). +LITERT_DEFINE_HANDLE(LiteRtDelegateWrapper); +// LiteRT CompiledModel object. (litert_compiled_model.h) +LITERT_DEFINE_HANDLE(LiteRtCompiledModel); +// Opaque handle to a JIT compiled executable. (LiteRtJitExecutableT is +// intentionally left out as an opaque type) +LITERT_DEFINE_HANDLE(LiteRtJitExecutable); +// LiteRT Environment object. (litert_environment.h) +LITERT_DEFINE_HANDLE(LiteRtEnvironment); +// LiteRT EnvironmentOptions object. (litert_environment_options.h) +LITERT_DEFINE_HANDLE(LiteRtEnvironmentOptions); +// LiteRT Event object. (litert_event.h) +LITERT_DEFINE_HANDLE(LiteRtEvent); +// LiteRT Logger object. (litert_logging.h) +LITERT_DEFINE_HANDLE(LiteRtLogger); +// LiteRT Metrics object. (litert_metrics.h) +LITERT_DEFINE_HANDLE(LiteRtMetrics); + +// Constant data behind a tensor stored in the model. (litert_model.h) +LITERT_DEFINE_HANDLE(LiteRtWeights); +// Values/edges of the model's graph. (litert_model.h) +LITERT_DEFINE_HANDLE(LiteRtTensor); +// Operations/nodes of the model's graph. (litert_model.h) +LITERT_DEFINE_HANDLE(LiteRtOp); +// Fundamental block of program, i.e. a function body. (litert_model.h) +LITERT_DEFINE_HANDLE(LiteRtSubgraph); +// Signature of the model. (litert_model.h) +LITERT_DEFINE_HANDLE(LiteRtSignature); +// A collection of subgraph + metadata + signature. (litert_model.h) +LITERT_DEFINE_HANDLE(LiteRtModel); +// Append only list of ops. (litert_model.h) +LITERT_DEFINE_HANDLE(LiteRtOpList); +// LiteRT Builder object. (litert_builder.h) +LITERT_DEFINE_HANDLE(LiteRtBuilder); +// Representations of an custom op. (litert_op_options.h) +LITERT_DEFINE_HANDLE(LiteRtOp); +// A linked list of type erased opaque options. These are added to the +// LiteRtOptions object. (litert_opaque_options.h) +LITERT_DEFINE_HANDLE(LiteRtOpaqueOptions); +// The compilation options for the LiteRtCompiledModel. (litert_options.h) +LITERT_DEFINE_HANDLE_STRUCT(LiteRtOptions); +// LiteRT TensorBuffer object. (litert_tensor_buffer.h) +LITERT_DEFINE_HANDLE(LiteRtTensorBuffer); +// LiteRT TensorBufferRequirements object. (litert_tensor_buffer_requirements.h) +LITERT_DEFINE_HANDLE(LiteRtTensorBufferRequirements); +// LiteRT Profiler object. (litert_profiler.h) +LITERT_DEFINE_HANDLE(LiteRtProfiler); +// LiteRT ExternalLiteRtBufferContext object. +// (litert_external_litert_buffer_context.h) +LITERT_DEFINE_HANDLE(LiteRtExternalLiteRtBufferContext); + +#if defined(__linux__) || defined(__ANDROID__) +#define LITERT_HAS_SYNC_FENCE_SUPPORT 1 +#else +#define LITERT_HAS_SYNC_FENCE_SUPPORT 0 +#endif + +#if defined(__ANDROID__) +#define LITERT_HAS_AHWB_SUPPORT_DEFAULT 1 +#define LITERT_HAS_OPENGL_SUPPORT_DEFAULT 1 +#define LITERT_HAS_ION_SUPPORT_DEFAULT 1 +#define LITERT_HAS_DMABUF_SUPPORT_DEFAULT 1 +#define LITERT_HAS_FASTRPC_SUPPORT_DEFAULT 1 +#elif defined(__linux__) && defined(__aarch64__) +#define LITERT_HAS_AHWB_SUPPORT_DEFAULT 0 +#define LITERT_HAS_OPENGL_SUPPORT_DEFAULT 0 +#define LITERT_HAS_ION_SUPPORT_DEFAULT 1 +#define LITERT_HAS_DMABUF_SUPPORT_DEFAULT 0 +#define LITERT_HAS_FASTRPC_SUPPORT_DEFAULT 1 +// copybara:uncomment_begin(google-only) +// #elif defined(GOOGLE_UNSUPPORTED_OS_LOONIX) +// #define LITERT_HAS_OPENGL_SUPPORT_DEFAULT 0 +// #define LITERT_HAS_ION_SUPPORT_DEFAULT 0 +// #define LITERT_HAS_DMABUF_SUPPORT_DEFAULT 1 +// #define LITERT_HAS_FASTRPC_SUPPORT_DEFAULT 0 +// copybara:uncomment_end +#else +#define LITERT_HAS_AHWB_SUPPORT_DEFAULT 0 +#define LITERT_HAS_OPENGL_SUPPORT_DEFAULT 0 +#define LITERT_HAS_ION_SUPPORT_DEFAULT 0 +#define LITERT_HAS_DMABUF_SUPPORT_DEFAULT 0 +#define LITERT_HAS_FASTRPC_SUPPORT_DEFAULT 0 +#endif + +#if defined(__APPLE__) +#define LITERT_HAS_METAL_SUPPORT_DEFAULT 1 +#define LITERT_HAS_OPENCL_SUPPORT_DEFAULT 0 +#define LITERT_HAS_VULKAN_SUPPORT_DEFAULT 0 +#elif defined(LITERT_WINDOWS_OS) +#define LITERT_HAS_METAL_SUPPORT_DEFAULT 0 +#define LITERT_HAS_OPENCL_SUPPORT_DEFAULT 0 +#define LITERT_HAS_VULKAN_SUPPORT_DEFAULT 1 +#else +#define LITERT_HAS_METAL_SUPPORT_DEFAULT 0 +#define LITERT_HAS_OPENCL_SUPPORT_DEFAULT 1 +#define LITERT_HAS_VULKAN_SUPPORT_DEFAULT 1 +#endif + +#define LITERT_HAS_WEBGPU_SUPPORT_DEFAULT 1 + +#if defined(LITERT_DISABLE_NPU) +#define LITERT_DISABLE_AHWB_SUPPORT +#define LITERT_DISABLE_ION_SUPPORT +#define LITERT_DISABLE_DMABUF_SUPPORT +#define LITERT_DISABLE_FASTRPC_SUPPORT +#endif + +#if defined(LITERT_DISABLE_GPU) +#define LITERT_DISABLE_METAL_SUPPORT +#define LITERT_DISABLE_OPENCL_SUPPORT +#define LITERT_DISABLE_WEBGPU_SUPPORT +#define LITERT_DISABLE_VULKAN_SUPPORT +#define LITERT_DISABLE_OPENGL_SUPPORT +#endif + +#if defined(LITERT_DISABLE_METAL_SUPPORT) +#define LITERT_HAS_METAL_SUPPORT 0 +#else +#define LITERT_HAS_METAL_SUPPORT LITERT_HAS_METAL_SUPPORT_DEFAULT +#endif + +#if defined(LITERT_DISABLE_OPENCL_SUPPORT) +#define LITERT_HAS_OPENCL_SUPPORT 0 +#else +#define LITERT_HAS_OPENCL_SUPPORT LITERT_HAS_OPENCL_SUPPORT_DEFAULT +#endif + +#if defined(LITERT_DISABLE_WEBGPU_SUPPORT) +#define LITERT_HAS_WEBGPU_SUPPORT 0 +#else +#define LITERT_HAS_WEBGPU_SUPPORT LITERT_HAS_WEBGPU_SUPPORT_DEFAULT +#endif + +#if defined(LITERT_DISABLE_VULKAN_SUPPORT) +#define LITERT_HAS_VULKAN_SUPPORT 0 +#else +#define LITERT_HAS_VULKAN_SUPPORT LITERT_HAS_VULKAN_SUPPORT_DEFAULT +#endif + +#if defined(LITERT_DISABLE_OPENGL_SUPPORT) +#define LITERT_HAS_OPENGL_SUPPORT 0 +#else +#define LITERT_HAS_OPENGL_SUPPORT LITERT_HAS_OPENGL_SUPPORT_DEFAULT +#endif + +#if defined(LITERT_DISABLE_AHWB_SUPPORT) +#define LITERT_HAS_AHWB_SUPPORT 0 +#else +#define LITERT_HAS_AHWB_SUPPORT LITERT_HAS_AHWB_SUPPORT_DEFAULT +#endif + +#if defined(LITERT_DISABLE_ION_SUPPORT) +#define LITERT_HAS_ION_SUPPORT 0 +#else +#define LITERT_HAS_ION_SUPPORT LITERT_HAS_ION_SUPPORT_DEFAULT +#endif + +#if defined(LITERT_DISABLE_DMABUF_SUPPORT) +#define LITERT_HAS_DMABUF_SUPPORT 0 +#else +#define LITERT_HAS_DMABUF_SUPPORT LITERT_HAS_DMABUF_SUPPORT_DEFAULT +#endif + +#if defined(LITERT_DISABLE_FASTRPC_SUPPORT) +#define LITERT_HAS_FASTRPC_SUPPORT 0 +#else +#define LITERT_HAS_FASTRPC_SUPPORT LITERT_HAS_FASTRPC_SUPPORT_DEFAULT +#endif + +#define LITERT_API_VERSION_MAJOR 0 +#define LITERT_API_VERSION_MINOR 1 +#define LITERT_API_VERSION_PATCH 0 + +typedef struct LiteRtApiVersion { + int major; + int minor; + int patch; +} LiteRtApiVersion; + +// Compares `v1` and `v2`. +// +// Returns 0 if they are the same, a negative number if v1 < v2 and a positive +// number if v1 > v2. +int LiteRtCompareApiVersion(LiteRtApiVersion version, + LiteRtApiVersion reference); + +// LINT.IfChange(status_codes) +typedef enum { + kLiteRtStatusOk = 0, + + // Generic errors. + kLiteRtStatusErrorInvalidArgument = 1, + kLiteRtStatusErrorMemoryAllocationFailure = 2, + kLiteRtStatusErrorRuntimeFailure = 3, + kLiteRtStatusErrorMissingInputTensor = 4, + kLiteRtStatusErrorUnsupported = 5, + kLiteRtStatusErrorNotFound = 6, + kLiteRtStatusErrorTimeoutExpired = 7, + kLiteRtStatusErrorWrongVersion = 8, + kLiteRtStatusErrorUnknown = 9, + kLiteRtStatusErrorAlreadyExists = 10, + + // Inference progression errors. + kLiteRtStatusCancelled = 100, + + // File and loading related errors. + kLiteRtStatusErrorFileIO = 500, + kLiteRtStatusErrorInvalidFlatbuffer = 501, + kLiteRtStatusErrorDynamicLoading = 502, + kLiteRtStatusErrorSerialization = 503, + kLiteRtStatusErrorCompilation = 504, + + // IR related errors. + kLiteRtStatusErrorIndexOOB = 1000, + kLiteRtStatusErrorInvalidIrType = 1001, + kLiteRtStatusErrorInvalidGraphInvariant = 1002, + kLiteRtStatusErrorGraphModification = 1003, + + // Tool related errors. + kLiteRtStatusErrorInvalidToolConfig = 1500, + + // Legalization related errors. + kLiteRtStatusLegalizeNoMatch = 2000, + kLiteRtStatusErrorInvalidLegalization = 2001, + + // Transformation related errors. + kLiteRtStatusPatternNoMatch = 3000, + kLiteRtStatusInvalidTransformation = 3001, + + // Version related errors. + kLiteRtStatusErrorUnsupportedRuntimeVersion = 4000, + kLiteRtStatusErrorUnsupportedCompilerVersion = 4001, + kLiteRtStatusErrorIncompatibleByteCodeVersion = 4002, + + // Shape inference related errors. + kLiteRtStatusErrorUnsupportedOpShapeInferer = 5000, + kLiteRtStatusErrorShapeInferenceFailed = 5001, +} LiteRtStatus; +// LINT.ThenChange( +// ../kotlin/src/main/kotlin/com/google/ai/edge/litert/LiteRtException.kt:status_codes, +// ../cc/litert_common.h:status_codes, +// ../objc/apis/LRTError.h:status_codes +// ) + +// Returns a string describing the status value. +const char* LiteRtGetStatusString(LiteRtStatus status); + +typedef enum LiteRtHwAccelerators { + kLiteRtHwAcceleratorNone = 0, + kLiteRtHwAcceleratorCpu = 1 << 0, + kLiteRtHwAcceleratorGpu = 1 << 1, + kLiteRtHwAcceleratorNpu = 1 << 2, +#if defined(__EMSCRIPTEN__) + kLiteRtHwAcceleratorWebNn = 1 << 3, +#endif // __EMSCRIPTEN__ + // Force standard C compilers to use a signed 32-bit integer + // as the underlying type for Rust `bindgen` compatibility. + _kLiteRtHwAcceleratorNegativeDummy = -1, +} LiteRtHwAccelerators; + +typedef enum { + kLiteRtDelegatePrecisionDefault = 0, + kLiteRtDelegatePrecisionFp16 = 1, + kLiteRtDelegatePrecisionFp32 = 2, + // FP16 storage and arithmetic with FP32 accumulation where supported. + // Currently the option is only for the GPU backend and only impacts the + // CONV_2D, DEPTHWISE_CONV_2D, FULLY_CONNECTED, TRANSPOSE_CONV and + // BATCH_MAT_MUL operators and any stablehlo composite op that uses them. + kLiteRtDelegatePrecisionFp16WithFp32Accum = 3, +} LiteRtDelegatePrecision; + +typedef enum { + kLiteRtGpuPriorityDefault = 0, + kLiteRtGpuPriorityLow = 1, + kLiteRtGpuPriorityNormal = 2, + kLiteRtGpuPriorityHigh = 3, +} LiteRtGpuPriority; + +// Storage type needed by buffers to be allocated in the GPU delegate. +// Default means the storage type will be automatically determined by the +// delegate. +typedef enum { + kLiteRtDelegateBufferStorageTypeDefault = 0, + kLiteRtDelegateBufferStorageTypeBuffer = 1, + kLiteRtDelegateBufferStorageTypeTexture2D = 2, +} LiteRtDelegateBufferStorageType; + +// Lock mode for tensor buffer. +typedef enum { + kLiteRtTensorBufferLockModeRead = 0, + kLiteRtTensorBufferLockModeWrite = 1, + kLiteRtTensorBufferLockModeReadWrite = 2, +} LiteRtTensorBufferLockMode; + +// Backend option of GPU Accelerator. +// No need to specify on iOS or Metal since there is only one backend. +typedef enum { + kLiteRtGpuBackendAutomatic = 0, + kLiteRtGpuBackendOpenCl = 1, + kLiteRtGpuBackendWebGpu = 2, + kLiteRtGpuBackendOpenGl = 3, // Experimental, do not use. +} LiteRtGpuBackend; + +// GPU Wait type on synchronous execution. +// Values are 1:1 mapping to GpuDelegateWaitType. +typedef enum { + // Wait type will be automatically determined by the delegate. + kLiteRtGpuWaitTypeDefault = 0, + // Blocked waiting for GPU to finish. + kLiteRtGpuWaitTypePassive = 1, + // Active busy-waiting for GPU to finish. + kLiteRtGpuWaitTypeActive = 2, + // Do not wait for GPU to finish. Relies on other synchronization ways like + // barriers or in-order queue. As it's for backward compatibility, not + // recommended for new use cases. Use asynchronous execution mode instead. + kLiteRtGpuWaitTypeDoNotWait = 3, +} LiteRtGpuWaitType; + +// Error reporter mode enum +typedef enum LiteRtErrorReporterMode { + // No error reporting (errors are ignored) + kLiteRtErrorReporterModeNone = 0, + // Default stderr error reporter + kLiteRtErrorReporterModeStderr = 1, + // Buffer error reporter that collects errors for later retrieval + kLiteRtErrorReporterModeBuffer = 2, +} LiteRtErrorReporterMode; + +// A bit field of `LiteRtHwAccelerators` values. +typedef int LiteRtHwAcceleratorSet; + +// For indexing into LiteRT collections or counting LiteRT things. +typedef size_t LiteRtParamIndex; + +#if defined(_WIN32) +// Provides posix_memalign() missing in Windows. +#include + +#define posix_memalign(p, a, s) \ + (((*(p)) = _aligned_malloc((s), (a))), *(p) ? 0 : errno) + +// Memory allocated by _aligned_malloc() on Windows needs to be freed by +// _aligned_free(). Use aligned_free() instead of free() for the memory +// allocated by posix_memalign() for cross-platform compatibility. +// https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/aligned-malloc?view=msvc-170 +// litert_ prefix is added to avoid name conflicts with one defined in +// base/port.h, for example, included in unit tests. +#define litert_aligned_free _aligned_free + +#else // _WIN32 +#define litert_aligned_free free +#endif // _WIN32 + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_COMMON_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_compiled_model.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_compiled_model.h new file mode 100644 index 0000000000000000000000000000000000000000..69f33c89e1e3bd6a5605169638df89eaad412f88 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_compiled_model.h @@ -0,0 +1,376 @@ +// Copyright 2024 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_COMPILED_MODEL_H_ +#define ODML_LITERT_LITERT_C_LITERT_COMPILED_MODEL_H_ + +#include + +#include "litert/c/internal/litert_scheduling_info.h" +#include "litert/c/litert_common.h" +#include "litert/c/litert_layout.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// The LiteRtCompiledModel is a higher level inference API. It is created by +// provided model with compilation options. Internally, it instantiates runtime +// and applies Delegates mapped to the compilation options. +// It also supports getting LiteRtTensorBufferRequirements to create +// input/output TensorBuffers, and it allows to invoke the model with the +// input/output TensorBuffers. +// +// Example user flow: +// +// 1. Create LiteRtCompiledModel +// 2. Query the model input/output LiteRtTensorBufferRequirements +// 3. Create input/output LiteRtTensorBuffer +// 4. Fill the input LiteRtTensorBuffer with input data +// 5. Invoke the model with the input/output LiteRtTensorBuffer +// 6. Evaluate the output LiteRtTensorBuffer + +// Creates a LiteRtCompiledModel from a LiteRtModel object. Parameter +// `compilation_options` is optional and can be null, and is owned by the +// caller. The model is loaded into memory and the caller takes ownership of +// the returned object. +// +// Caller owns the returned LiteRtCompiledModel. The owner is responsible for +// calling LiteRtDestroyCompiledModel() to release the object. +LiteRtStatus LiteRtCreateCompiledModel(LiteRtEnvironment environment, + LiteRtModel model, + LiteRtOptions compilation_options, + LiteRtCompiledModel* compiled_model); + +// Returns the buffer requirements for the given n-th input tensor. The returned +// LiteRtTensorBufferRequirements is used to create the input tensor +// buffer. +// +// Parameters: +// - compiled_model: the target `LiteRtCompiledModel` object. +// - signature_index: the index of the signature in `LiteRtModel`. +// - input_index: the index of the input tensor in the signature (subgraph). +// - buffer_requirements: the returned `LiteRtTensorBufferRequirements`. +// +// Note: The returned LiteRtTensorBufferRequirements is still owned by the +// LiteRtCompiledModel and is only valid during the LiteRtCompileModel's +// lifetime. +LiteRtStatus LiteRtGetCompiledModelInputBufferRequirements( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + LiteRtParamIndex input_index, + LiteRtTensorBufferRequirements* buffer_requirements); + +// Returns the buffer requirements for the given n-th output tensor. The +// returned LiteRtTensorBufferRequirements is used to create the output tensor +// buffer. +// +// Parameters: +// - compiled_model: the target `LiteRtCompiledModel` object. +// - signature_index: the index of the signature in `LiteRtModel`. +// - input_index: the index of the input tensor in the signature (subgraph). +// - buffer_requirements: the returned `LiteRtTensorBufferRequirements`. +// +// Note: The returned LiteRtTensorBufferRequirements is still owned by the +// LiteRtCompiledModel and is only valid during the LiteRtCompileModel's +// lifetime. +LiteRtStatus LiteRtGetCompiledModelOutputBufferRequirements( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + LiteRtParamIndex output_index, + LiteRtTensorBufferRequirements* buffer_requirements); + +// Returns the tensor layout for the given input tensor. This reflects the most +// recent shape requested via LiteRtCompiledModelResizeInputTensor or automatic +// resizing during execution. +// +// Parameters: +// - compiled_model: the target `LiteRtCompiledModel` object. +// - signature_index: the index of the signature in `LiteRtModel`. +// - input_index: the index of the input tensor in the signature (subgraph). +// - layout: user provided storage to receive the `LiteRtLayout`. +LiteRtStatus LiteRtGetCompiledModelInputTensorLayout( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + LiteRtParamIndex input_index, LiteRtLayout* layout); + +// Returns the tensor layouts for all output tensors. +// +// Parameters: +// - compiled_model: the target `LiteRtCompiledModel` object. +// - signature_index: the index of the signature in `LiteRtModel`. +// - num_layouts: the number of output tensor layouts. +// - layouts: user allocated memory to store `LiteRtLayout` for tensor outputs. +// - update_allocation: whether to update the tensor allocation. Set to true +// for dynamic models after resize input tensors. +// +// Note: This function usually should be called after resizing input tensors +// to get the new output tensor layouts. User should be responsible for +// allocation and deallocating of the layouts memory. +LiteRtStatus LiteRtGetCompiledModelOutputTensorLayouts( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + size_t num_layouts, LiteRtLayout* layouts, bool update_allocation); + +// Returns the associated environment of the given compiled model. +LiteRtStatus LiteRtGetCompiledModelEnvironment( + LiteRtCompiledModel compiled_model, LiteRtEnvironment* environment); + +// Runs the model of the given signature synchronously, with the provided +// input/output LiteRtTensorBuffer. +// +// Parameters: +// - compiled_model: the target `LiteRtCompiledModel` object. +// - signature_index: the index of the signature in `LiteRtModel`. +// - num_input_buffers: the number of input `LiteRtTensorBuffer`. +// - input_buffers: the array of input `LiteRtTensorBuffer`. +// - num_output_buffers: the number of output `LiteRtTensorBuffer`. +// - output_buffers: the array of output LiteRtTensorBuffer. +LiteRtStatus LiteRtRunCompiledModel(LiteRtCompiledModel compiled_model, + LiteRtParamIndex signature_index, + size_t num_input_buffers, + LiteRtTensorBuffer* input_buffers, + size_t num_output_buffers, + LiteRtTensorBuffer* output_buffers); + +// Runs the model of the given signature synchronously, with the provided +// input/output LiteRtTensorBuffer, and applies the provided runtime `options` +// for this invocation. +// +// `options` is optional; when nullptr, the model is run with the compiled +// options only. +LiteRtStatus LiteRtRunCompiledModelWithOptions( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + size_t num_input_buffers, LiteRtTensorBuffer* input_buffers, + size_t num_output_buffers, LiteRtTensorBuffer* output_buffers, + LiteRtOptions options); + +// Runs the model of the given signature asynchronously, if possible, with the +// provided input/output LiteRtTensorBuffers. If asynchronous execution is +// possible, then the function sets parameter `async` to true; if asynchronous +// execution is not possible, then the function runs the model synchronously and +// sets parameter `async` to false. Note that: +// +// - Asynchronous execution is possible only in certain cases, based on the ops +// included in the model, the selected HW accelerator(s), and the capability +// of the user device hardware. +// +// - If asynchronous execution is indeed possible, it may be that only some +// parts of the model are run asynchronously (e.g., ops mapped to the GPU) +// while other parts of the model are still run synchronously with the +// invocation of this call (e.g., ops mapped to the CPU). +// +// - In case of asynchronous execution some or all of the output tensor buffers +// will have a synchronization event attached to them and the caller is +// responsible for passing such events to a downstream processing step. +// +// Parameters: +// - async: optional boolean to let the caller know if the model is being run +// asynchronously. +LiteRtStatus LiteRtRunCompiledModelAsync( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + size_t num_input_buffers, LiteRtTensorBuffer* input_buffers, + size_t num_output_buffers, LiteRtTensorBuffer* output_buffers, bool* async); + +// Runs the model of the given signature asynchronously, if possible, with the +// provided input/output LiteRtTensorBuffers, and applies the provided runtime +// `options` for this invocation. +// +// `options` is optional; when nullptr, the model is run with the compiled +// options only. +LiteRtStatus LiteRtRunCompiledModelAsyncWithOptions( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + size_t num_input_buffers, LiteRtTensorBuffer* input_buffers, + size_t num_output_buffers, LiteRtTensorBuffer* output_buffers, bool* async, + LiteRtOptions options); + +// Sets default scheduling information for all future requests on this compiled +// model. +// +// This is the "set once per model" scenario. If `scheduling_info` is null, the +// compiled model resets to default scheduling behavior. +LiteRtStatus LiteRtCompiledModelSetSchedulingInfo( + LiteRtCompiledModel compiled_model, + const LiteRtSchedulingInfo* scheduling_info); + +// Runs the model for a given signature synchronously with per-request +// scheduling info. This is the "set once per request" scenario. +// +// If `scheduling_info` is null, the compiled model's default scheduling info +// (set via `LiteRtCompiledModelSetSchedulingInfo`) will be used. +LiteRtStatus LiteRtRunCompiledModelWithSchedulingInfo( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + size_t num_input_buffers, LiteRtTensorBuffer* input_buffers, + size_t num_output_buffers, LiteRtTensorBuffer* output_buffers, + const LiteRtSchedulingInfo* scheduling_info); + +// Runs the model for a given signature asynchronously, if possible, with +// per-request scheduling info. This is the "set once per request" scenario. +// +// If `scheduling_info` is null, the compiled model's default scheduling info +// (set via `LiteRtCompiledModelSetSchedulingInfo`) will be used. +LiteRtStatus LiteRtRunCompiledModelAsyncWithSchedulingInfo( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + size_t num_input_buffers, LiteRtTensorBuffer* input_buffers, + size_t num_output_buffers, LiteRtTensorBuffer* output_buffers, bool* async, + const LiteRtSchedulingInfo* scheduling_info); + +// Sets a callback function that will be called periodically during model +// execution to check if the execution should be cancelled. +// +// Parameters: +// - compiled_model: the target `LiteRtCompiledModel` object. +// - data: user-provided data that will be passed to the callback function. +// - check_cancelled_func: callback function that returns true if execution +// should be cancelled, false otherwise. +// +// Note: Either use this callback-based mechanism or the non callback version +// with LiteRtEnableCompiledModelCancellation/LiteRtCancelCompiledModel, but not +// both. +LiteRtStatus LiteRtSetCompiledModelCancellationFunction( + LiteRtCompiledModel compiled_model, void* data, + bool (*check_cancelled_func)(void*)); + +// Destroy an owned LiteRtCompiledModel object. +void LiteRtDestroyCompiledModel(LiteRtCompiledModel compiled_model); + +// Start collection of HW-specific metrics at a specific level of detail (>= 0). +LiteRtStatus LiteRtCompiledModelStartMetricsCollection( + LiteRtCompiledModel compiled_model, int detail_level); + +// Stop collection of HW-specific metrics and report the collected metrics. +LiteRtStatus LiteRtCompiledModelStopMetricsCollection( + LiteRtCompiledModel compiled_model, LiteRtMetrics metrics); + +// Returns true if the model is fully accelerated for all the selected HW +// accelerator(s). For example, if both GPU and NPU are selected and the model +// is only delegated to GPU, this method will still return true. +LiteRtStatus LiteRtCompiledModelIsFullyAccelerated( + LiteRtCompiledModel compiled_model, bool* fully_accelerated); + +// Returns true if the model is fully accelerated on non-CPU accelerators +// (e.g. 100% delegated on GPU or NPU with zero CPU execution). +LiteRtStatus LiteRtCompiledModelIsNonCpuFullyAccelerated( + LiteRtCompiledModel compiled_model, bool* non_cpu_fully_accelerated); + +// Gets the profiler for the model. CompiledModel owns the profiler. +LiteRtStatus LiteRtCompiledModelGetProfiler(LiteRtCompiledModel compiled_model, + LiteRtProfiler* profiler); + +// Resizes the specified input tensor to support dynamic shapes. +// +// This function allows resizing input tensors at runtime, similar to TFLite's +// ResizeInputTensorStrict API. After calling this function, the compiled model +// will reallocate internal buffers as needed to accommodate the new tensor +// shape. +// +// Parameters: +// - compiled_model: the target `LiteRtCompiledModel` object. +// - signature_index: the index of the signature in `LiteRtModel`. +// - input_index: the index of the input tensor in the signature (subgraph). +// - dims: A span containing the new dimensions for the input tensor. +// +// Note: After resizing, the previously obtained buffer requirements may be +// invalidated. Callers should re-query buffer requirements if needed. After +// resizing, LiteRtGetCompiledModelAllOutputTensorLayouts can be used to get +// the new output tensor layouts. +// +// Returns: +// - kLiteRtStatusOk: Success. +// - kLiteRtStatusErrorInvalidArgument: Invalid parameters. +// - kLiteRtStatusErrorRuntimeFailure: Failed to resize tensor. +// - kLiteRtStatusErrorUnimplemented: Dynamic shape is not supported for the +// given model or delegate. +LiteRtStatus LiteRtCompiledModelResizeInputTensor( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + LiteRtParamIndex input_index, const int* dims, size_t dims_size); + +// Resizes the specified input tensor without requiring dynamic dimensions in +// the tensor signature. This mirrors TFLite's non-strict resize API and should +// be paired with LiteRtGetCompiledModelOutputTensorLayouts(..., +// /*update_allocation=*/true) to propagate shape changes to outputs. +// +// Parameters are identical to LiteRtCompiledModelResizeInputTensor. +LiteRtStatus LiteRtCompiledModelResizeInputTensorNonStrict( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + LiteRtParamIndex input_index, const int* dims, size_t dims_size); + +// Sets a dispatch annotation on the compiled model. These annotations will be +// propagated to dispatch graphs when they are created during model execution. +// The annotations provide runtime hints and metadata that can be used by +// hardware accelerators for optimization. +// +// Parameters: +// - compiled_model: the target `LiteRtCompiledModel` object. +// - signature_index: the index of the signature (zero-based). +// - key: the annotation key (must not be null). +// - value: the annotation value (must not be null). +// +// Example annotations: +// - "priority": "high|medium|low" - execution priority hints +// - "memory_type": "shared|dedicated" - memory allocation preferences +// - "accelerator": "npu|gpu|dsp" - preferred hardware accelerator +// - "precision": "fp32|fp16|int8" - computation precision requirements +LiteRtStatus LiteRtCompiledModelSetDispatchAnnotation( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + const char* key, const char* value); + +// Gets a dispatch annotation from the compiled model. +// +// Parameters: +// - compiled_model: the target `LiteRtCompiledModel` object. +// - signature_index: the index of the signature (zero-based). +// - key: the annotation key to look up (must not be null). +// - value: pointer to store the annotation value (will be set to null if key +// not found). +// +// Returns: +// - kLiteRtStatusOk if successful (even if key not found). +// - kLiteRtStatusErrorInvalidArgument if inputs are invalid. +// +// Note: The returned value pointer is owned by the compiled model and should +// not be freed or outlive the compiled model. +LiteRtStatus LiteRtCompiledModelGetDispatchAnnotation( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + const char* key, const char** value); + +// Removes a dispatch annotation from the compiled model. +// +// Parameters: +// - compiled_model: the target `LiteRtCompiledModel` object. +// - key: the annotation key to remove (must not be null). +// +// Returns: +// - kLiteRtStatusOk if successful (even if key not found). +// - kLiteRtStatusErrorInvalidArgument if inputs are invalid. +LiteRtStatus LiteRtCompiledModelRemoveDispatchAnnotation( + LiteRtCompiledModel compiled_model, LiteRtParamIndex signature_index, + const char* key); + +// Error reporter APIs + +// Reports an error to the compiled model's error reporter. +// Note: This function accepts printf-style format strings. +LiteRtStatus LiteRtCompiledModelReportError(LiteRtCompiledModel compiled_model, + const char* format, ...); + +// Clears all errors (only available with buffer error reporter mode). +LiteRtStatus LiteRtCompiledModelClearErrors(LiteRtCompiledModel compiled_model); + +// Gets all error messages as a single string (only available with buffer error +// reporter mode). The caller is responsible for freeing the returned +// `error_messages` buffer using `free`. +LiteRtStatus LiteRtCompiledModelGetErrorMessages( + LiteRtCompiledModel compiled_model, char** error_messages); +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_COMPILED_MODEL_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_custom_op_kernel.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_custom_op_kernel.h new file mode 100644 index 0000000000000000000000000000000000000000..5505fb9549d74791c6adbb2488154e77e85bd3c0 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_custom_op_kernel.h @@ -0,0 +1,48 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_CUSTOM_OP_KERNEL_H_ +#define ODML_LITERT_LITERT_C_LITERT_CUSTOM_OP_KERNEL_H_ + +#include +#include + +#include "litert/c/litert_common.h" +#include "litert/c/litert_layout.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +typedef struct { + // NOLINTBEGIN(*-readability-class-member-naming) + LiteRtStatus (*Init)(void* user_data, const void* init_data, + size_t init_data_size); + // Called when the input size has changed. + LiteRtStatus (*GetOutputLayouts)(void* user_data, size_t num_inputs, + const LiteRtLayout* input_layouts, + size_t num_outputs, + LiteRtLayout* output_layouts); + LiteRtStatus (*Run)(void* user_data, size_t num_inputs, + const LiteRtTensorBuffer* inputs, size_t num_outputs, + LiteRtTensorBuffer* outputs); + LiteRtStatus (*Destroy)(void* user_data); + // NOLINTEND(*-readability-class-member-naming) +} LiteRtCustomOpKernel; + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_CUSTOM_OP_KERNEL_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_custom_tensor_buffer.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_custom_tensor_buffer.h new file mode 100644 index 0000000000000000000000000000000000000000..fd4cc64bb36349a7eed64126c99956ec28686402 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_custom_tensor_buffer.h @@ -0,0 +1,95 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_CUSTOM_TENSOR_BUFFER_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_CUSTOM_TENSOR_BUFFER_H_ + +#include + +#include "litert/c/litert_common.h" +#include "litert/c/litert_model_types.h" +#include "litert/c/litert_tensor_buffer_types.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// GPU HW Device ID. It could be specific HW object depends on the environment +// such as `WGPUDevice` in WebGPU. +typedef void* LiteRtGpuDeviceId; + +// GPU HW Command Queue ID. It could be specific HW object depends on the +// environment such as `WGPUQueue` in WebGPU. +typedef void* LiteRtGpuQueueId; + +// Generic hardware memory handle type. This could be a specific hardware +// memory handle type such as cl_mem, WGPBuffer, etc. +// It's created by `CreateCustomTensorBuffer` and destroyed by +// `DestroyCustomTensorBuffer`. +typedef void* HwMemoryHandle; + +// Custom hardware memory information data. +// Custom TensorBuffer handler can use this to keep additional information +// about the hardware memory such as CPU mapped memory pointer. +// The information should be kept in the child structure of `HwMemoryInfo`. +// It's created by `CreateCustomTensorBuffer` and destroyed by +// `DestroyCustomTensorBuffer`. +struct HwMemoryInfo { + HwMemoryHandle memory_handle; + void* raw_handle; +}; + +typedef struct HwMemoryInfo* HwMemoryInfoPtr; + +// Custom TensorBuffer handler function to create a custom TensorBuffer. +typedef LiteRtStatus (*CreateCustomTensorBuffer)( + LiteRtGpuDeviceId device_id, LiteRtGpuQueueId queue_id, + const LiteRtRankedTensorType* tensor_type, + LiteRtTensorBufferType buffer_type, size_t bytes, size_t packed_bytes, + HwMemoryInfoPtr* hw_memory_info); + +// Custom TensorBuffer handler function to import an existing custom +// TensorBuffer. +// This function creates the HwMemoryInfo wrapper but does NOT take ownership +// or destroy the handle. The implementation should store an "owns_tensor = +// false" flag inside its HwMemoryInfo-derived struct. +typedef LiteRtStatus (*ImportCustomTensorBuffer)( + LiteRtGpuDeviceId device_id, LiteRtGpuQueueId queue_id, + const LiteRtRankedTensorType* tensor_type, + LiteRtTensorBufferType buffer_type, HwMemoryHandle hw_buffer_handle, + size_t bytes, size_t packed_bytes, HwMemoryInfoPtr* hw_memory_info); + +// Custom TensorBuffer handler function to destroy a custom TensorBuffer. +typedef LiteRtStatus (*DestroyCustomTensorBuffer)( + HwMemoryInfoPtr hw_memory_info); + +// Custom TensorBuffer handler function to lock a custom TensorBuffer. +// `host_memory_ptr` is the CPU mapped memory pointer to the custom +// TensorBuffer. +typedef LiteRtStatus (*LockCustomTensorBuffer)(HwMemoryInfoPtr hw_memory_info, + LiteRtTensorBufferLockMode mode, + void** host_memory_ptr); + +// Custom TensorBuffer handler function to unlock a custom TensorBuffer. +typedef LiteRtStatus (*UnlockCustomTensorBuffer)( + HwMemoryInfoPtr hw_memory_info); + +// Custom TensorBuffer handler function to clear a custom TensorBuffer. +typedef LiteRtStatus (*ClearCustomTensorBuffer)(HwMemoryInfoPtr hw_memory_info); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_CUSTOM_TENSOR_BUFFER_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_environment.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_environment.h new file mode 100644 index 0000000000000000000000000000000000000000..70b839624ebe14c5b691e9a22b2f5ee00e9c0d28 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_environment.h @@ -0,0 +1,85 @@ +// Copyright 2024 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_ENVIRONMENT_H_ +#define ODML_LITERT_LITERT_C_LITERT_ENVIRONMENT_H_ + +#include "litert/c/litert_common.h" +#include "litert/c/litert_environment_options.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Create a LiteRT environment with options. +// Used to set the path of the compiler plugin library and dispatch library. +// Caller owns the returned LiteRtEnvironment. The owner is responsible for +// calling LiteRtDestroyEnvironment() to release the environment. +// +// Note: options of kLiteRtEnvOptionTagOpenCl* shouldn't be set with this API. +LiteRtStatus LiteRtCreateEnvironment(int num_options, + const LiteRtEnvOption* options, + LiteRtEnvironment* environment); + +// Destroy an owned LiteRT environment object. +void LiteRtDestroyEnvironment(LiteRtEnvironment environment); + +// Get the options that the environment was created with. +LiteRtStatus LiteRtGetEnvironmentOptions(LiteRtEnvironment environment, + LiteRtEnvironmentOptions* options); + +// Add options to the existing environment. When overwrite is true, the options +// will overwrite all existing options with the same tags. When overwrite is +// false, an error will be returned if the option already exists in the +// environment. +LiteRtStatus LiteRtAddEnvironmentOptions(LiteRtEnvironment environment, + int num_options, + const LiteRtEnvOption* options, + bool overwrite); + +// Create a LiteRT GPU environment with options. +// The given `environment` takes ownership of the created GPU environment. +// This API is usually called by the GPU accelerator implementation to set GPU +// environment options which affect the entire LiteRT runtime. +// +// Note: In most cases, users should not call this API directly. +LiteRtStatus LiteRtGpuEnvironmentCreate(LiteRtEnvironment environment, + int num_options, + const LiteRtEnvOption* options); + +// Returns whether the environment supports CL/GL interop. +LiteRtStatus LiteRtEnvironmentSupportsClGlInterop(LiteRtEnvironment environment, + bool* is_supported); + +// Returns whether the environment supports AHWB/CL interop. +LiteRtStatus LiteRtEnvironmentSupportsAhwbClInterop( + LiteRtEnvironment environment, bool* is_supported); + +// Returns whether the environment supports AHWB/GL interop. +LiteRtStatus LiteRtEnvironmentSupportsAhwbGlInterop( + LiteRtEnvironment environment, bool* is_supported); + +// Returns whether the environment supports FP16. +LiteRtStatus LiteRtEnvironmentSupportsFP16(LiteRtEnvironment environment, + bool* is_supported); + +// Returns whether the environment has a GPU environment. +void LiteRtEnvironmentHasGpuEnvironment(LiteRtEnvironment environment, + bool* has_gpu_environment); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_ENVIRONMENT_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_environment_options.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_environment_options.h new file mode 100644 index 0000000000000000000000000000000000000000..448cf78e9edaf0333d97f17565b25b764fc548f8 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_environment_options.h @@ -0,0 +1,163 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_ENVIRONMENT_OPTIONS_H_ +#define ODML_LITERT_LITERT_C_LITERT_ENVIRONMENT_OPTIONS_H_ + +#include +#include + +#include "litert/c/litert_any.h" +#include "litert/c/litert_common.h" +#include "litert/c/litert_custom_tensor_buffer.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// LINT.IfChange(LiteRtEnvOptionTag) +typedef enum { + kLiteRtEnvOptionTagCompilerPluginLibraryDir = 0, + kLiteRtEnvOptionTagDispatchLibraryDir = 1, + kLiteRtEnvOptionTagOpenClDeviceId = 2, + kLiteRtEnvOptionTagOpenClPlatformId = 3, + kLiteRtEnvOptionTagOpenClContext = 4, + kLiteRtEnvOptionTagOpenClCommandQueue = 5, + kLiteRtEnvOptionTagEglDisplay = 6, + kLiteRtEnvOptionTagEglContext = 7, + kLiteRtEnvOptionTagWebGpuDevice = 8, + kLiteRtEnvOptionTagWebGpuQueue = 9, + kLiteRtEnvOptionTagMetalDevice = 10, + kLiteRtEnvOptionTagMetalCommandQueue = 11, + // WARNING: Vulkan support is experimental. + kLiteRtEnvOptionTagVulkanEnvironment = 12, + // kLiteRtEnvOptionTagVulkanCommandPool = 13, // Deprecated. + kLiteRtEnvOptionTagCallbackOnGpuEnvDestroy = 14, + kLiteRtEnvOptionTagCallbackUserDataOnGpuEnvDestroy = 15, + kLiteRtEnvOptionTagMagicNumberConfigs = 16, + kLiteRtEnvOptionTagMagicNumberVerifications = 17, + kLiteRtEnvOptionTagCompilerCacheDir = 18, + // Singleton ML Drift WebGPU/Dawn instance required for shared libraries not + // to create their own instances. + kLiteRtEnvOptionTagWebGpuInstance = 19, + // Dawn procedure table pointer for shared libraries to populate their tables + // with the shared procedures instead of their own procedures. + kLiteRtEnvOptionTagWebGpuProcs = 20, // Deprecated. + kLiteRtEnvOptionTagCustomTensorBufferHandlers_deprecated = 21, // Deprecated. + kLiteRtEnvOptionTagRuntimeLibraryDir = 22, + /// \internal This is for internal use only, for a custom runtime. + kLiteRtEnvOptionTagSystemRuntimeHandle = 23, + // Bitmask of LiteRtHwAccelerators to auto-register when the environment is + // created. If unset, LiteRT auto-registers all supported accelerators. + kLiteRtEnvOptionTagAutoRegisterAccelerators = 24, + // Minimum logger severity for the environment. + kLiteRtEnvOptionTagMinLoggerSeverity = 25, + // Maximum number of configurations to store per model in the compiler cache. + kLiteRtEnvOptionTagCompilerCacheMaxConfigsPerModel = 26, + kLiteRtEnvOptionTagCompilerCacheMaxTotalSize = 27, + /// \internal This is for internal use only. Reserved for use by LiteRT in + /// Play services. + kLiteRtEnvOptionTagContext = 28, + // An optional custom callback (`void (*)()`) invoked during synchronous + // WebGPU buffer readback (e.g., with Dawn Wire handler) to flush outbound + // wire commands and pump inbound events on the thread message loop. + kLiteRtEnvOptionTagWebGpuFlushCallback = 29, + /// \internal This is for internal use only, for a custom GPU accelerator + /// handle. + kLiteRtEnvOptionTagSystemGpuAcceleratorHandle = 30, + // Internal use only. Virtual null tag for option that is not defined. + kLiteRtEnvOptionTagNull = 255, +} LiteRtEnvOptionTag; +// LINT.ThenChange(../kotlin/src/main/kotlin/com/google/ai/edge/litert/Environment.kt) + +/// An object that holds option data for the LiteRtEnvironment. +/// +/// @note This concrete type is part of the public API and is ABI stable. +typedef struct { + LiteRtEnvOptionTag tag; + LiteRtAny value; +} LiteRtEnvOption; + +#if defined(__cplusplus) && defined(__SIZEOF_POINTER__) && \ + __SIZEOF_POINTER__ == 8 +static_assert(sizeof(LiteRtEnvOption) == 24, "LiteRtEnvOption size mismatch"); +static_assert(offsetof(LiteRtEnvOption, value) == 8, + "LiteRtEnvOption value offset mismatch"); +#endif // __cplusplus + +// Arbitrary size of array following the pattern in TfLiteIntArray. +#if defined(_MSC_VER) && !defined(__clang__) +#define _LITERT_ARBITRARY_ARRAY_SIZE 1 +#elif (!defined(__clang__) && defined(__GNUC__) && __GNUC__ == 6 && \ + __GNUC_MINOR__ >= 1) || \ + defined(HEXAGON) || \ + (defined(__clang__) && __clang_major__ == 7 && __clang_minor__ == 1) +#define _LITERT_ARBITRARY_ARRAY_SIZE 0 +#else +#define _LITERT_ARBITRARY_ARRAY_SIZE +#endif + +typedef struct { + int64_t magic_number; + int64_t target_number; + // Prefix of signatures to update magic numbers. If null or empty, all + // signatures will be updated. + // This C string is owned by the user of LiteRT runtime and must outlive until + // model is initialized. + const char* signature_prefix; +} LiteRtMagicNumberConfig; + +// Magic number replacement configs set as an option with a pointer to this +// structure. +typedef struct { + int64_t num_configs; + LiteRtMagicNumberConfig configs[_LITERT_ARBITRARY_ARRAY_SIZE]; +} LiteRtMagicNumberConfigs; + +typedef struct { + // Signature with magic numbers replaced. + // This C string is owned by the user of LiteRT runtime and must outlive until + // model is initialized. + const char* signature; + // Signature to test against for verification. + // This C string is owned by the user of LiteRT runtime and must outlive until + // model is initialized. + const char* test_signature; + // Whether the ops of signature is a superset of the ops of test_signature. + // If true, it verifies only if all ops in test_signature exists in the + // signature in the same order and their operands are of the same shape + // assuming that the extra ops manipulate the input/output tensors of larger + // dimensions, but not to change the semantics of the graph. + // If false, the test signature must be exactly the same to the signature in + // all aspects including # of tensors, # of ops, and their shapes. + bool is_superset; +} LiteRtMagicNumberVerification; + +typedef struct { + int64_t num_verifications; + LiteRtMagicNumberVerification verifications[_LITERT_ARBITRARY_ARRAY_SIZE]; +} LiteRtMagicNumberVerifications; + +// Retrieves the value corresponding to the given tag. +// +// Returns kLiteRtStatusErrorNotFound if the option tag is not found. +LiteRtStatus LiteRtGetEnvironmentOptionsValue(LiteRtEnvironmentOptions options, + LiteRtEnvOptionTag tag, + LiteRtAny* value); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_ENVIRONMENT_OPTIONS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_event.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_event.h new file mode 100644 index 0000000000000000000000000000000000000000..08b869f6dac6ac79e57f37257cc39d2475757d2f --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_event.h @@ -0,0 +1,109 @@ +// Copyright 2024 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_EVENT_H_ +#define ODML_LITERT_LITERT_C_LITERT_EVENT_H_ + +#include // NOLINT: To use bool type in C +#include + +#include "litert/c/litert_common.h" +#include "litert/c/litert_event_type.h" +#include "litert/c/litert_gl_types.h" +#include "litert/c/litert_opencl_types.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Creates a LiteRtEvent from a sync fence fd. +// If owns_fd is true, the LiteRtEvent will own the fd and close it when +// destroyed. +// +// Caller owns the returned LiteRtEvent. The owner is responsible for +// calling LiteRtDestroyEvent() to release the object. +LiteRtStatus LiteRtCreateEventFromSyncFenceFd(LiteRtEnvironment env, + int sync_fence_fd, bool owns_fd, + LiteRtEvent* event); + +// Another LiteRtEvent creation API for OpenCL event. +// +// Caller owns the returned LiteRtEvent (but not the cl_event). The owner is +// responsible for calling LiteRtDestroyEvent() to release the object (but not +// the underlying cl_event). +LiteRtStatus LiteRtCreateEventFromOpenClEvent(LiteRtEnvironment env, + LiteRtClEvent cl_event, + LiteRtEvent* event); + +// Another LiteRtEvent creation API for OpenCL event. +// +// Caller owns the returned LiteRtEvent. The owner is responsible for +// calling LiteRtDestroyEvent() to release the object. +LiteRtStatus LiteRtCreateEventFromEglSyncFence(LiteRtEnvironment env, + LiteRtEglSyncKhr egl_sync, + LiteRtEvent* event); + +// Creates a LiteRtEvent with the given type. +// +// Caller owns the returned LiteRtEvent. The owner is responsible for +// calling LiteRtDestroyEvent() to release the object. +LiteRtStatus LiteRtCreateManagedEvent(LiteRtEnvironment env, + LiteRtEventType type, LiteRtEvent* event); + +// Sets a custom event to the LiteRtEvent. Event type must be +// LiteRtEventTypeCustom. +LiteRtStatus LiteRtSetCustomEvent(LiteRtEvent event, + LiteRtCustomEvent custom_event); + +// Returns the custom event from the LiteRtEvent. Event type must be +// LiteRtEventTypeCustom. +// +// Note: This function is only used for internal components and will not be +// exposed in the public C++ API. +LiteRtStatus LiteRtGetCustomEvent(LiteRtEvent event, + LiteRtCustomEvent* custom_event); + +// Returns the native event of the custom event if supported. +LiteRtStatus LiteRtGetEventCustomNativeEvent(LiteRtEvent event, void** native); + +LiteRtStatus LiteRtGetEventEventType(LiteRtEvent event, LiteRtEventType* type); + +LiteRtStatus LiteRtGetEventSyncFenceFd(LiteRtEvent event, int* sync_fence_fd); + +LiteRtStatus LiteRtGetEventOpenClEvent(LiteRtEvent event, + LiteRtClEvent* cl_event); + +LiteRtStatus LiteRtGetEventEglSync(LiteRtEvent event, + LiteRtEglSyncKhr* egl_sync); + +// Pass -1 for timeout_in_ms for indefinite wait. +LiteRtStatus LiteRtWaitEvent(LiteRtEvent event, int64_t timeout_in_ms); + +// Signals the event to notify the waiters. +LiteRtStatus LiteRtSignalEvent(LiteRtEvent event); + +// Returns true if the event is signaled. +LiteRtStatus LiteRtIsEventSignaled(LiteRtEvent event, bool* is_signaled); + +// Returns a dup of the event's sync fence fd. +LiteRtStatus LiteRtDupFdEvent(LiteRtEvent event, int* dup_fd); + +// Destroys an owned LiteRtEvent object. +void LiteRtDestroyEvent(LiteRtEvent event); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_EVENT_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_event_type.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_event_type.h new file mode 100644 index 0000000000000000000000000000000000000000..aaca472e06616f86eaf6d612fe109102cf90ede0 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_event_type.h @@ -0,0 +1,58 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_EVENT_TYPE_H_ +#define ODML_LITERT_LITERT_C_LITERT_EVENT_TYPE_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// LINT.IfChange(event_type) +typedef enum { + LiteRtEventTypeUnknown = 0, + LiteRtEventTypeSyncFenceFd = 1, + LiteRtEventTypeOpenCl = 2, + LiteRtEventTypeEglSyncFence = 3, + LiteRtEventTypeEglNativeSyncFence = 4, + LiteRtEventTypeCustom = 5, +} LiteRtEventType; +// LINT.ThenChange(../cc/litert_event.h:event_type) + +// Custom events managed by the client. +typedef struct LiteRtCustomEventT* LiteRtCustomEvent; +struct LiteRtCustomEventT { + // Retains the custom event, e.g. increases the reference count. + void (*Retain)(LiteRtCustomEvent event); // NOLINT + // Releases the custom event, e.g. decreases the reference count. + // If the reference count reaches 0, the custom event will be destroyed. + void (*Release)(LiteRtCustomEvent event); // NOLINT + // Waits for the custom event to be signaled. How to signal the event is + // backend dependent, e.g. emulating within Wait() or wrapping an actual GPU + // event signaled by the device. + void (*Wait)(LiteRtCustomEvent event, int64_t timeout_in_ms); // NOLINT + // Returns 1 if the custom event is signaled, 0 otherwise. + int (*IsSignaled)(LiteRtCustomEvent event); // NOLINT + // Returns the native pointer of the custom event, or nullptr if not + // supported. + void* (*GetNative)(LiteRtCustomEvent event); // NOLINT +}; + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_EVENT_TYPE_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_gl_types.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_gl_types.h new file mode 100644 index 0000000000000000000000000000000000000000..b09076805d143fac89e3786d7c885a477fd4d74d --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_gl_types.h @@ -0,0 +1,55 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_GL_TYPES_H_ +#define ODML_LITERT_LITERT_C_LITERT_GL_TYPES_H_ + +#include +#if LITERT_HAS_OPENGL_SUPPORT +#include +#include +#include +#include +#endif // LITERT_HAS_OPENGL_SUPPORT + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +#if LITERT_HAS_OPENGL_SUPPORT +typedef GLenum LiteRtGLenum; +typedef GLuint LiteRtGLuint; +typedef GLint LiteRtGLint; +typedef EGLContext LiteRtEglContext; +typedef EGLDisplay LiteRtEglDisplay; +typedef EGLSyncKHR LiteRtEglSyncKhr; +#define LITE_RT_EGL_NO_CONTEXT EGL_NO_CONTEXT +#define LITE_RT_EGL_NO_DISPLAY EGL_NO_DISPLAY +#else +// Allows for compilation of GL types when OpenGl support is not available. +typedef uint32_t LiteRtGLenum; +typedef uint32_t LiteRtGLuint; +typedef int32_t LiteRtGLint; +typedef struct LiteRtEglContextStruct* LiteRtEglContext; +typedef struct LiteRtEglDisplayStruct* LiteRtEglDisplay; +typedef struct LiteRtEglSyncKhrStruct* LiteRtEglSyncKhr; +#define LITE_RT_EGL_NO_CONTEXT static_cast(0) +#define LITE_RT_EGL_NO_DISPLAY static_cast(0) +#endif // LITERT_HAS_OPENGL_SUPPORT + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_GL_TYPES_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_layout.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_layout.h new file mode 100644 index 0000000000000000000000000000000000000000..cce2cd84284ed92e65a14eb7aed6bb9c83d1c3ce --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_layout.h @@ -0,0 +1,85 @@ +// Copyright 2024 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_LAYOUT_H_ +#define ODML_LITERT_LITERT_C_LITERT_LAYOUT_H_ + +#include // NOLINT: To use bool type in C +#include +#include + +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Max number of dimensions in any ranked tensor type. +#define LITERT_TENSOR_MAX_RANK 8 + +/// The shape information for tensor types of fixed rank. +/// +/// @note This concrete type is part of the public API and is ABI stable. +typedef struct { + unsigned int rank : 7; // The number of dimensions. + // Whether the layout has strides. + // + // NOTE: This bit-field uses `unsigned int` (matching `rank` above) rather + // than `bool` on purpose. MSVC does not coalesce adjacent bit-fields with + // different underlying types into the same storage unit, so a `bool` field + // here would open a fresh 4-byte unit and shift `dimensions`/`strides`, + // making this public struct binary-incompatible between MSVC and GCC/Clang + // builds. Keeping the underlying type identical packs both fields together + // on every compiler. See https://github.com/google-ai-edge/LiteRT/issues/7459 + unsigned int has_strides : 1; + + // Dimension sizes, array of length `rank`. Dynamic dimensions are anything + // less than 0. Everything from [rank, LITERT_MAX_RANK) is undefined. + int32_t dimensions[LITERT_TENSOR_MAX_RANK]; + + // Strides. Used only if has_strides is true. + uint32_t strides[LITERT_TENSOR_MAX_RANK]; +} LiteRtLayout; + +// The layout below is now identical across MSVC and GCC/Clang because `rank` +// and `has_strides` share an underlying type and pack into a single storage +// unit on every compiler. These asserts intentionally have no `_MSC_VER` +// branch so any future change that reintroduces cross-compiler divergence +// fails the build. +#if defined(__cplusplus) && defined(__SIZEOF_POINTER__) && \ + __SIZEOF_POINTER__ == 8 +static_assert(sizeof(LiteRtLayout) == 68, "LiteRtLayout size mismatch"); +static_assert(offsetof(LiteRtLayout, dimensions) == 4, + "LiteRtLayout dimensions offset mismatch"); +static_assert(offsetof(LiteRtLayout, strides) == 36, + "LiteRtLayout strides offset mismatch"); +#endif // __cplusplus + +// Return the number of scalar elements in the provided tensor layout. Return an +// error if the layout includes dynamic dimensions. +// +// Note: LiteRtLayout is a non-opaque type (struct is defined in this header). +// Therefore, its access methods do not need to and should NOT be exported +// from the dynamic C API library (e.g. libLiteRt.so). +LiteRtStatus LiteRtGetNumLayoutElements(const LiteRtLayout* layout, + size_t* num_elements); + +LiteRtStatus LiteRtIsSameLayout(const LiteRtLayout* layout1, + const LiteRtLayout* layout2, bool* result); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_LAYOUT_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_metrics.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_metrics.h new file mode 100644 index 0000000000000000000000000000000000000000..aad6f20754df7836711e9a55d538416506ca5a5b --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_metrics.h @@ -0,0 +1,54 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_METRICS_H_ +#define ODML_LITERT_LITERT_C_LITERT_METRICS_H_ + +#include "litert/c/litert_any.h" +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +typedef struct LiteRtMetric { + const char* name; + LiteRtAny value; +} LiteRtMetric; + +// Create a metrics object. The caller is responsible for deallocating the +// returned metrics by calling `LiteRtDestroyMetrics`. +LiteRtStatus LiteRtCreateMetrics(LiteRtMetrics* metrics); + +// Get the number of metrics collected. +LiteRtStatus LiteRtGetNumMetrics(LiteRtMetrics metrics, int* num_metrics); + +// Fetch a specific metric. +// NOTE The output object fields are owned by the `metrics` object and should +// not be used after the `metrics` object has been destroyed. +LiteRtStatus LiteRtGetMetric(LiteRtMetrics metrics, int metric_index, + LiteRtMetric* metric); + +// Destroy the metrics object. +void LiteRtDestroyMetrics(LiteRtMetrics metrics); + +// Append a new metric to the metrics object. +LiteRtStatus LiteRtAppendMetric(LiteRtMetrics metrics, + const LiteRtMetric* metric); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_METRICS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_model.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_model.h new file mode 100644 index 0000000000000000000000000000000000000000..4791691478e70bb59e43958dc82bac9a7855723d --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_model.h @@ -0,0 +1,356 @@ +// Copyright 2024 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_MODEL_H_ +#define ODML_LITERT_LITERT_C_LITERT_MODEL_H_ + +#include // NOLINT: To use bool type in C +#include +#include + +#include "litert/c/litert_common.h" +#include "litert/c/litert_model_types.h" +#include "litert/c/litert_op_code.h" + +#ifdef __cplusplus +namespace tflite { +class Allocation; +} +using LiteRtAllocationT = tflite::Allocation; +typedef LiteRtAllocationT* LiteRtAllocation; +typedef const LiteRtAllocationT* LiteRtAllocationConst; +#else +typedef struct LiteRtAllocationT* LiteRtAllocation; +typedef const struct LiteRtAllocationT* LiteRtAllocationConst; +#endif + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// +// LiteRtTensor + Types +// + +// Get the string name associated with this tensor. This is an optional +// attribute and if not set will return a zero-length string. +// The returned string pointer is owned by the LiteRtModel to which the given +// Tensor belongs. It becomes invalid when the LiteRtModel is destroyed. +LiteRtStatus LiteRtGetTensorName(LiteRtTensor tensor, const char** name); + +// Get the index associated with this tensor. +LiteRtStatus LiteRtGetTensorIndex(LiteRtTensor tensor, uint32_t* tensor_index); + +// Get type identifier from tensor. +LiteRtStatus LiteRtGetTensorTypeId(LiteRtTensor tensor, + LiteRtTensorTypeId* type_id); + +// Get unranked tensor type info, return bad status if not unranked. +LiteRtStatus LiteRtGetUnrankedTensorType( + LiteRtTensor tensor, LiteRtUnrankedTensorType* unranked_tensor_type); + +// Get ranked tensor type info, return bad status if not ranked. +LiteRtStatus LiteRtGetRankedTensorType( + LiteRtTensor tensor, LiteRtRankedTensorType* ranked_tensor_type); + +// QUANTIZATION + +// Get the identifier for the type of quantization for a given tensor. +LiteRtStatus LiteRtGetQuantizationTypeId(LiteRtTensor tensor, + LiteRtQuantizationTypeId* q_type_id); + +// Get the per-tensor quantization information for a given tensor if it has it. +LiteRtStatus LiteRtGetPerTensorQuantization( + LiteRtTensor tensor, LiteRtQuantizationPerTensor* per_tensor_quantization); + +// Get the per-channel quantization information for a given tensor if it has it. +LiteRtStatus LiteRtGetPerChannelQuantization( + LiteRtTensor tensor, + LiteRtQuantizationPerChannel* per_channel_quantization); + +// Get the block-wise quantization information for a given tensor if it has it. +LiteRtStatus LiteRtGetBlockWiseQuantization( + LiteRtTensor tensor, LiteRtQuantizationBlockWise* block_wise_quantization); + +// EDGES + +// Get all the ops that reference given tensor, and at what operand index. +LiteRtStatus LiteRtGetNumTensorUses(LiteRtTensor tensor, + LiteRtParamIndex* num_uses); +LiteRtStatus LiteRtGetTensorUse(LiteRtTensor tensor, LiteRtParamIndex use_index, + LiteRtOp* user, + LiteRtParamIndex* user_arg_index); + +// Get the op that defines this tensor and the corresponding output index. If +// tensor is a subgraph input, has_defining_op will be false. +LiteRtStatus LiteRtGetTensorDefiningOp(LiteRtTensor tensor, + bool* has_defining_op, + LiteRtTensorDefiningOp* defining_op); + +// WEIGHTS (constant data) + +// Get static weights associated with a given tensor. All tensors have weights, +// null weights have size = 0; +// +// Note: The returned LiteRtWeights is only valid during the LiteRtModel's +// lifetime. +LiteRtStatus LiteRtGetTensorWeights(LiteRtTensor tensor, + LiteRtWeights* weights); + +// +// LiteRtWeights +// + +// Get opaque array from given tensor weights. +LiteRtStatus LiteRtGetWeightsBytes(LiteRtWeights weights, const void** addr, + size_t* size); + +// Get the buffer id associated with the weights. Buffer id managed internally +// by the buffer manager. Buffer id starts from 1. +LiteRtStatus LiteRtGetWeightsBufferId(LiteRtWeights weights, + int32_t* buffer_id); +// +// LiteRtOp +// + +// Get code corresponding to operation type for given op. +LiteRtStatus LiteRtGetOpCode(LiteRtOp op, LiteRtOpCode* code); + +// Get custom code for given op, returns error if op is not a custom op. +LiteRtStatus LiteRtGetCustomCode(LiteRtOp op, const char** code); + +// Get custom options for given op. +LiteRtStatus LiteRtGetCustomOptions(LiteRtOp op, const uint8_t** custom_options, + int32_t* size); + +// Get input tensors of given op. +LiteRtStatus LiteRtGetNumOpInputs(LiteRtOp op, LiteRtParamIndex* num_inputs); +LiteRtStatus LiteRtGetOpInput(LiteRtOp op, LiteRtParamIndex input_index, + LiteRtTensor* input); + +// Get output tensors of given op. +LiteRtStatus LiteRtGetNumOpOutputs(LiteRtOp op, LiteRtParamIndex* num_outputs); +LiteRtStatus LiteRtGetOpOutput(LiteRtOp op, LiteRtParamIndex output_index, + LiteRtTensor* output); + +// +// LiteRtSubgraph +// + +// Get the string name associated with this subgraph. This is an optional +// attribute and if not set will return a zero-length string. +LiteRtStatus LiteRtGetSubgraphName(LiteRtSubgraph subgraph, const char** name); + +// Get input tensors for given subgraph. +// +// Note: The returned LiteRtTensor is only valid during the LiteRtModel's +// lifetime. +LiteRtStatus LiteRtGetNumSubgraphInputs(LiteRtSubgraph subgraph, + LiteRtParamIndex* num_inputs); +LiteRtStatus LiteRtGetSubgraphInput(LiteRtSubgraph subgraph, + LiteRtParamIndex input_index, + LiteRtTensor* input); + +// Get output tensors for given subgraph. +// +// Note: The returned LiteRtTensor is only valid during the LiteRtModel's +// lifetime. +LiteRtStatus LiteRtGetNumSubgraphOutputs(LiteRtSubgraph subgraph, + LiteRtParamIndex* num_outputs); +LiteRtStatus LiteRtGetSubgraphOutput(LiteRtSubgraph subgraph, + LiteRtParamIndex output_index, + LiteRtTensor* output); + +// Get all ops in given subgraph in a topological order. +LiteRtStatus LiteRtGetNumSubgraphOps(LiteRtSubgraph subgraph, + LiteRtParamIndex* num_ops); +LiteRtStatus LiteRtGetSubgraphOp(LiteRtSubgraph subgraph, + LiteRtParamIndex op_index, LiteRtOp* op); + +// +// LiteRtSignature +// + +// Get the signature key string defined in the model. +// The returned string pointer is owned by the LiteRtModel to which the given +// Signature belongs. It becomes invalid when the LiteRtModel is destroyed. +LiteRtStatus LiteRtGetSignatureKey(LiteRtSignature signature, + const char** signature_key); + +// Get the associated subgraph for the given signature. +LiteRtStatus LiteRtGetSignatureSubgraph(LiteRtSignature signature, + LiteRtSubgraph* subgraph); + +// Get the number of inputs for the given signature. +LiteRtStatus LiteRtGetNumSignatureInputs(LiteRtSignature signature, + LiteRtParamIndex* num_inputs); + +// Get the name of the i-th of input tensor name for the given signature. +// The returned string pointer is owned by the LiteRtModel to which the given +// Signature belongs. It becomes invalid when the LiteRtModel is destroyed. +LiteRtStatus LiteRtGetSignatureInputName(LiteRtSignature signature, + LiteRtParamIndex input_idx, + const char** input_name); + +// Get the input tensor for the given signature and input name. +// +// Note: The returned LiteRtTensor is only valid during the LiteRtModel's +// lifetime. +LiteRtStatus LiteRtGetSignatureInputTensor(LiteRtSignature signature, + const char* input_name, + LiteRtTensor* tensor); + +// Get the input tensor for the given signature and input index. +LiteRtStatus LiteRtGetSignatureInputTensorByIndex(LiteRtSignature signature, + LiteRtParamIndex input_idx, + LiteRtTensor* tensor); + +// Get the number of outputs for the given signature. +LiteRtStatus LiteRtGetNumSignatureOutputs(LiteRtSignature signature, + LiteRtParamIndex* num_outputs); + +// Get the name of the i-th of output tensor name for the given signature. +// The returned string pointer is owned by the LiteRtModel to which the given +// Signature belongs. It becomes invalid when the LiteRtModel is destroyed. +LiteRtStatus LiteRtGetSignatureOutputName(LiteRtSignature signature, + LiteRtParamIndex output_idx, + const char** output_name); + +// Get the output tensor for the given signature and output name. +// +// Note: The returned LiteRtTensor is only valid during the LiteRtModel's +// lifetime. +LiteRtStatus LiteRtGetSignatureOutputTensor(LiteRtSignature signature, + const char* output_name, + LiteRtTensor* tensor); + +// Get the output tensor for the given signature and output index. +LiteRtStatus LiteRtGetSignatureOutputTensorByIndex(LiteRtSignature signature, + LiteRtParamIndex output_idx, + LiteRtTensor* tensor); + +// +// LiteRtModel +// + +LiteRtStatus LiteRtCreateModelFromFile(LiteRtEnvironment environment, + const char* filename, + LiteRtModel* model); +// The caller must ensure that the buffer remains valid for the lifetime of +// the model. +LiteRtStatus LiteRtCreateModelFromBuffer(LiteRtEnvironment environment, + const void* buffer_addr, + size_t buffer_size, + LiteRtModel* model); +// Creates a model from the given file descriptor region. LiteRT duplicates the +// file descriptor internally; the caller retains ownership of `fd`. +LiteRtStatus LiteRtCreateModelFromFd(LiteRtEnvironment environment, int fd, + size_t offset, size_t size, + LiteRtModel* model); + +// Get the metadata buffer associated with given key if it exists. +LiteRtStatus LiteRtGetModelMetadata(LiteRtModel model, const char* metadata_key, + const void** metadata_buffer, + size_t* metadata_buffer_size); + +// Add metadata to the model. LiteRtModel copies key and metadata internally. It +// doesn't take ownership of the key and metadata, so users can free them after +// this API call. +LiteRtStatus LiteRtAddModelMetadata(LiteRtModel model, const char* metadata_key, + const void* metadata_buffer, + size_t metadata_buffer_size); + +// Get the index of the entry subgraph. +// TODO: b/365299994 - Figure out signatures. +LiteRtStatus LiteRtGetMainModelSubgraphIndex( + LiteRtModel model, LiteRtParamIndex* main_subgraph_index); + +// Get number of subgraphs in model. +LiteRtStatus LiteRtGetNumModelSubgraphs(LiteRtModel model, + LiteRtParamIndex* num_subgraphs); + +// Get subgraph at given index in model. +// +// Note: The returned LiteRtSubgraph is only valid during the LiteRtModel's +// lifetime. +LiteRtStatus LiteRtGetModelSubgraph(LiteRtModel model, + LiteRtParamIndex subgraph_index, + LiteRtSubgraph* subgraph); + +// Get the number of signatures defined in the model. +LiteRtStatus LiteRtGetNumModelSignatures(LiteRtModel model, + LiteRtParamIndex* num_signatures); + +// Get the signature at the given index in the model +// +// Note: The returned LiteRtSignature is only valid during the LiteRtModel's +// lifetime. +LiteRtStatus LiteRtGetModelSignature(LiteRtModel model, + LiteRtParamIndex signature_index, + LiteRtSignature* signature); + +// Destroy the given model, freeing any memory it owns. +void LiteRtDestroyModel(LiteRtModel model); + +// +// Utility Types +// + +// An append only list of ops. +LiteRtStatus LiteRtPushOp(LiteRtOpList op_list, LiteRtOp op, + LiteRtParamIndex partition_index); + +// +// Serialization related functions +// + +// Serializes model to valid tflite flatbuffer bytes with signatures. +// +// This destroys the model before it returns unless destroy_model is false. +// Caller takes ownership of `buf`. Flatbuffers are packed into their arrays +// back to front, so the valid flatbuffer is buf[offset, size]. See the above +// options for more details. +LiteRtStatus LiteRtSerializeModelWithSignatures( + LiteRtModel model, uint8_t** buf, size_t* size, size_t* offset, + bool destroy_model, char** signatures, LiteRtParamIndex num_signatures, + LiteRtModelSerializationOptions options); + +// Serializes model to valid tflite flatbuffer bytes. +// +// This destroys the model before it returns unless destroy_model is false. +// Caller takes ownership of `buf`. Flatbuffers are packed into their arrays +// back to front, so the valid flatbuffer is buf[offset, size]. See the above +// options for more details. +LiteRtStatus LiteRtSerializeModel(LiteRtModel model, uint8_t** buf, + size_t* size, size_t* offset, + bool destroy_model, + LiteRtModelSerializationOptions options); + +// Loading a model from an owned TFLite allocation. +// This is an internal experimetal API which is not available through +// libLiteRt.so. It's not part of the official LiteRT public C API. +// +// This function takes ownership of the `allocation` object. The caller must +// not use or attempt to delete the `allocation` after calling this function. +// The allocation will be automatically freed by this function even in case +// of failure. +LiteRtStatus LiteRtCreateModelFromAllocation(LiteRtEnvironment environment, + LiteRtAllocation allocation, + LiteRtModel* model); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_MODEL_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_model_types.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_model_types.h new file mode 100644 index 0000000000000000000000000000000000000000..7112d2b7e780c956f305da38175a186d56c30fa6 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_model_types.h @@ -0,0 +1,247 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_MODEL_TYPES_H_ +#define ODML_LITERT_LITERT_C_LITERT_MODEL_TYPES_H_ + +#include // NOLINT: To use bool type in C +#include +#include + +#include "litert/c/litert_common.h" +#include "litert/c/litert_layout.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// TENSOR TYPES + +// Primitive types for elements in a tensor. +// Matched to tensorflow/compiler/mlir/lite/core/c/tflite_types.h +typedef enum { + kLiteRtElementTypeNone = 0, // kTfLiteNoType, + kLiteRtElementTypeBool = 6, // kTfLiteBool, + kLiteRtElementTypeInt2 = 20, // kTfLiteInt2, + kLiteRtElementTypeInt4 = 18, // kTfLiteInt4, + kLiteRtElementTypeInt8 = 9, // kTfLiteInt8, + kLiteRtElementTypeInt16 = 7, // kTfLiteInt16, + kLiteRtElementTypeInt32 = 2, // kTfLiteInt32, + kLiteRtElementTypeInt64 = 4, // kTfLiteInt64, + kLiteRtElementTypeUInt4 = 21, // kTfLiteUInt4, + kLiteRtElementTypeUInt8 = 3, // kTfLiteUInt8, + kLiteRtElementTypeUInt16 = 17, // kTfLiteUInt16, + kLiteRtElementTypeUInt32 = 16, // kTfLiteUInt32, + kLiteRtElementTypeUInt64 = 13, // kTfLiteUInt64, + kLiteRtElementTypeFloat8E4M3FN = 22, // kTfLiteFloat8E4M3FN, + kLiteRtElementTypeFloat8E5M2 = 23, // kTfLiteFloat8E5M2, + kLiteRtElementTypeFloat16 = 10, // kTfLiteFloat16, + kLiteRtElementTypeBFloat16 = 19, // kTfLiteBFloat16, + kLiteRtElementTypeFloat32 = 1, // kTfLiteFloat32, + kLiteRtElementTypeFloat64 = 11, // kTfLiteFloat64, + kLiteRtElementTypeComplex64 = 8, // kTfLiteComplex64, + kLiteRtElementTypeComplex128 = 12, // kTfLiteComplex128, + kLiteRtElementTypeTfResource = 14, // kTfLiteResource, + kLiteRtElementTypeTfString = 5, // kTfLiteString, + kLiteRtElementTypeTfVariant = 15, // kTfLiteVariant, +} LiteRtElementType; + +/// Tensor type when its rank is dynamic. +/// +/// @note This concrete type is part of the public API and is ABI stable. +typedef struct { + // The primitive element type of the constituent data. + LiteRtElementType element_type; +} LiteRtUnrankedTensorType; + +#if defined(__cplusplus) && defined(__SIZEOF_POINTER__) && \ + __SIZEOF_POINTER__ == 8 +static_assert(sizeof(LiteRtUnrankedTensorType) == 4, + "LiteRtUnrankedTensorType size mismatch"); +static_assert(offsetof(LiteRtUnrankedTensorType, element_type) == 0, + "LiteRtUnrankedTensorType element_type offset mismatch"); +#endif // __cplusplus + +/// Tensor type when its rank is static but dimensions may be dynamic. +/// +/// @note This concrete type is part of the public API and is ABI stable. +typedef struct { + // The primitive element type of the constituent data. + LiteRtElementType element_type; + + // Shape information. + LiteRtLayout layout; +} LiteRtRankedTensorType; + +// `LiteRtRankedTensorType` embeds `LiteRtLayout`, whose layout is now identical +// across MSVC and GCC/Clang (see litert/c/litert_layout.h), so this size no +// longer diverges by compiler. The assert intentionally has no `_MSC_VER` +// branch. +#if defined(__cplusplus) && defined(__SIZEOF_POINTER__) && \ + __SIZEOF_POINTER__ == 8 +static_assert(sizeof(LiteRtRankedTensorType) == 72, + "LiteRtRankedTensorType size mismatch"); +static_assert(offsetof(LiteRtRankedTensorType, layout) == 4, + "LiteRtRankedTensorType layout offset mismatch"); +#endif // __cplusplus + +inline bool LiteRtIsSameUnrankedTensorType( + const LiteRtUnrankedTensorType* type1, + const LiteRtUnrankedTensorType* type2) { + return type1->element_type == type2->element_type; +} + +// The identifier for tensor type union. +typedef enum { + // Type with fixed rank and possibly dynamic dimensions. + kLiteRtRankedTensorType = 0, + + // Type with dynamic rank. + kLiteRtUnrankedTensorType = 1, +} LiteRtTensorTypeId; + +// QUANTIZATION + +// Schema for tensors quantized with one set of q-params. +/// +/// @note This concrete type is part of the public API and is ABI stable. +typedef struct { + // Scaling factor. + float scale; + + // The value that float:0 maps to in q-space. + int64_t zero_point; +} LiteRtQuantizationPerTensor; +#if defined(__cplusplus) && defined(__SIZEOF_POINTER__) && \ + __SIZEOF_POINTER__ == 8 +static_assert(sizeof(LiteRtQuantizationPerTensor) == 16, + "LiteRtQuantizationPerTensor size mismatch"); +static_assert(offsetof(LiteRtQuantizationPerTensor, scale) == 0, + "LiteRtQuantizationPerTensor scale offset mismatch"); +static_assert(offsetof(LiteRtQuantizationPerTensor, zero_point) == 8, + "LiteRtQuantizationPerTensor zero_point offset mismatch"); +#endif // __cplusplus + +// Schema for tensors quantized with one set of q-params per channel. +/// +/// @note This concrete type is part of the public API and is ABI stable. +typedef struct { + int32_t quantized_dimension; + uint64_t num_channels; + float* scales; + int64_t* zero_points; +} LiteRtQuantizationPerChannel; +#if defined(__cplusplus) && defined(__SIZEOF_POINTER__) && \ + __SIZEOF_POINTER__ == 8 +static_assert(sizeof(LiteRtQuantizationPerChannel) == 32, + "LiteRtQuantizationPerChannel size mismatch"); +static_assert( + offsetof(LiteRtQuantizationPerChannel, quantized_dimension) == 0, + "LiteRtQuantizationPerChannel quantized_dimension offset mismatch"); +static_assert(offsetof(LiteRtQuantizationPerChannel, num_channels) == 8, + "LiteRtQuantizationPerChannel num_channels offset mismatch"); +static_assert(offsetof(LiteRtQuantizationPerChannel, scales) == 16, + "LiteRtQuantizationPerChannel scales offset mismatch"); +static_assert(offsetof(LiteRtQuantizationPerChannel, zero_points) == 24, + "LiteRtQuantizationPerChannel zero_points offset mismatch"); +#endif // __cplusplus + +// Schema for tensors quantized across blocks of fixed size. +/// +/// @note This concrete type is part of the public API and is ABI stable. +typedef struct { + LiteRtTensor scales; + LiteRtTensor zero_points; + int32_t block_size; +} LiteRtQuantizationBlockWise; + +#if defined(__cplusplus) && defined(__SIZEOF_POINTER__) && \ + __SIZEOF_POINTER__ == 8 +static_assert(sizeof(LiteRtQuantizationBlockWise) == 24, + "LiteRtQuantizationBlockWise size mismatch"); +static_assert(offsetof(LiteRtQuantizationBlockWise, scales) == 0, + "LiteRtQuantizationBlockWise scales offset mismatch"); +static_assert(offsetof(LiteRtQuantizationBlockWise, zero_points) == 8, + "LiteRtQuantizationBlockWise zero_points offset mismatch"); +static_assert(offsetof(LiteRtQuantizationBlockWise, block_size) == 16, + "LiteRtQuantizationBlockWise block_size offset mismatch"); +#endif // __cplusplus + +// The identifier for quantization scheme type union. +/// +/// @note This concrete type is part of the public API and is ABI stable. +// LINT.IfChange(quantization_type_id) +typedef enum { + // Tag for tensors without quantization. + kLiteRtQuantizationNone = 0, + + // Basic quantization, one set of q-params per tensor. + kLiteRtQuantizationPerTensor = 1, + + // Q-params for each element across a single dimension. + kLiteRtQuantizationPerChannel = 2, + + // [NOT IMPLEMENTED YET] Q-params across blocks of fixed size (e.g. 2048). + kLiteRtQuantizationBlockWise = 3, +} LiteRtQuantizationTypeId; +// LINT.ThenChange(../cc/litert_model_types.h:quantization_type_id) +// Get the identifier for the type of quantization for a given tensor. +LiteRtStatus LiteRtGetQuantizationTypeId(LiteRtTensor tensor, + LiteRtQuantizationTypeId* q_type_id); + +// Get the per-tensor quantization information for a given tensor if it has it. +LiteRtStatus LiteRtGetPerTensorQuantization( + LiteRtTensor tensor, LiteRtQuantizationPerTensor* per_tensor_quantization); + +// Get the per-channel quantization information for a given tensor if it has it. +LiteRtStatus LiteRtGetPerChannelQuantization( + LiteRtTensor tensor, + LiteRtQuantizationPerChannel* per_channel_quantization); + +// Get the block-wise quantization information for a given tensor if it has it. +LiteRtStatus LiteRtGetBlockWiseQuantization( + LiteRtTensor tensor, LiteRtQuantizationBlockWise* block_wise_quantization); + +// EDGES + +// Information about the graph node that defines a tensor. +typedef struct LiteRtTensorDefiningOp { + // The defining op itself. + LiteRtOp op; + + // The op output index that defines the specific tensor. + LiteRtParamIndex op_output_index; +} LiteRtTensorDefiningOp; + +// Information about a reference to a tensor in the graph. +typedef struct LiteRtTensorUserOp { + // The referring op itself. + LiteRtOp op; + + // Index of which operand the op refers to a specific tensor on. + LiteRtParamIndex op_input_index; +} LiteRtTensorUserOp; + +// Options for model serialization. +typedef struct LiteRtModelSerializationOptions { + // Alignment for bytecode assets that are appended to the model. + // Alignment is enforced relative to the first byte of the flatbuffer. + size_t bytecode_alignment; +} LiteRtModelSerializationOptions; + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_MODEL_TYPES_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_op_code.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_op_code.h new file mode 100644 index 0000000000000000000000000000000000000000..ad631e1485bf3c865cb3f7dd395e4e9ca18e8854 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_op_code.h @@ -0,0 +1,251 @@ +// Copyright 2024 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_OP_CODE_H_ +#define ODML_LITERT_LITERT_C_LITERT_OP_CODE_H_ + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +typedef enum { + kLiteRtOpCodeTflAdd = 0, // kTfLiteBuiltinAdd + kLiteRtOpCodeTflAveragePool2d = 1, // kTfLiteBuiltinAveragePool2d + kLiteRtOpCodeTflConcatenation = 2, // kTfLiteBuiltinConcatenation + kLiteRtOpCodeTflConv2d = 3, // kTfLiteBuiltinConv2d + kLiteRtOpCodeTflDepthwiseConv2d = 4, // kTfLiteBuiltinDepthwiseConv2d + kLiteRtOpCodeTflDepthToSpace = 5, // kTfLiteBuiltinDepthToSpace + kLiteRtOpCodeTflDequantize = 6, // kTfLiteBuiltinDequantize + kLiteRtOpCodeTflEmbeddingLookup = 7, // kTfLiteBuiltinEmbeddingLookup + kLiteRtOpCodeTflFloor = 8, // kTfLiteBuiltinFloor + kLiteRtOpCodeTflFullyConnected = 9, // kTfLiteBuiltinFullyConnected + kLiteRtOpCodeTflHashtableLookup = 10, // kTfLiteBuiltinHashtableLookup + kLiteRtOpCodeTflL2Normalization = 11, // kTfLiteBuiltinL2Normalization + kLiteRtOpCodeTflL2Pool2d = 12, // kTfLiteBuiltinL2Pool2d + kLiteRtOpCodeTflLocalResponseNormalization = + 13, // kTfLiteBuiltinLocalResponseNormalization + kLiteRtOpCodeTflLogistic = 14, // kTfLiteBuiltinLogistic + kLiteRtOpCodeTflLshProjection = 15, // kTfLiteBuiltinLshProjection + kLiteRtOpCodeTflLstm = 16, // kTfLiteBuiltinLstm + kLiteRtOpCodeTflMaxPool2d = 17, // kTfLiteBuiltinMaxPool2d + kLiteRtOpCodeTflMul = 18, // kTfLiteBuiltinMul + kLiteRtOpCodeTflRelu = 19, // kTfLiteBuiltinRelu + kLiteRtOpCodeTflReluN1To1 = 20, // kTfLiteBuiltinReluN1To1 + kLiteRtOpCodeTflRelu6 = 21, // kTfLiteBuiltinRelu6 + kLiteRtOpCodeTflReshape = 22, // kTfLiteBuiltinReshape + kLiteRtOpCodeTflResizeBilinear = 23, // kTfLiteBuiltinResizeBilinear + kLiteRtOpCodeTflRnn = 24, // kTfLiteBuiltinRnn + kLiteRtOpCodeTflSoftmax = 25, // kTfLiteBuiltinSoftmax + kLiteRtOpCodeTflSpaceToDepth = 26, // kTfLiteBuiltinSpaceToDepth + kLiteRtOpCodeTflSvdf = 27, // kTfLiteBuiltinSvdf + kLiteRtOpCodeTflTanh = 28, // kTfLiteBuiltinTanh + kLiteRtOpCodeTflConcatEmbeddings = 29, // kTfLiteBuiltinConcatEmbeddings + kLiteRtOpCodeTflSkipGram = 30, // kTfLiteBuiltinSkipGram + kLiteRtOpCodeTflCall = 31, // kTfLiteBuiltinCall + kLiteRtOpCodeTflCustom = 32, // kTfLiteBuiltinCustom + kLiteRtOpCodeTflEmbeddingLookupSparse = + 33, // kTfLiteBuiltinEmbeddingLookupSparse + kLiteRtOpCodeTflPad = 34, // kTfLiteBuiltinPad + kLiteRtOpCodeTflUnidirectionalSequenceRnn = + 35, // kTfLiteBuiltinUnidirectionalSequenceRnn + kLiteRtOpCodeTflGather = 36, // kTfLiteBuiltinGather + kLiteRtOpCodeTflBatchToSpaceNd = 37, // kTfLiteBuiltinBatchToSpaceNd + kLiteRtOpCodeTflSpaceToBatchNd = 38, // kTfLiteBuiltinSpaceToBatchNd + kLiteRtOpCodeTflTranspose = 39, // kTfLiteBuiltinTranspose + kLiteRtOpCodeTflMean = 40, // kTfLiteBuiltinMean + kLiteRtOpCodeTflSub = 41, // kTfLiteBuiltinSub + kLiteRtOpCodeTflDiv = 42, // kTfLiteBuiltinDiv + kLiteRtOpCodeTflSqueeze = 43, // kTfLiteBuiltinSqueeze + kLiteRtOpCodeTflUnidirectionalSequenceLstm = + 44, // kTfLiteBuiltinUnidirectionalSequenceLstm + kLiteRtOpCodeTflStridedSlice = 45, // kTfLiteBuiltinStridedSlice + kLiteRtOpCodeTflBidirectionalSequenceRnn = + 46, // kTfLiteBuiltinBidirectionalSequenceRnn + kLiteRtOpCodeTflExp = 47, // kTfLiteBuiltinExp + kLiteRtOpCodeTflTopkV2 = 48, // kTfLiteBuiltinTopkV2 + kLiteRtOpCodeTflSplit = 49, // kTfLiteBuiltinSplit + kLiteRtOpCodeTflLogSoftmax = 50, // kTfLiteBuiltinLogSoftmax + kLiteRtOpCodeTflDelegate = 51, // kTfLiteBuiltinDelegate + kLiteRtOpCodeTflBidirectionalSequenceLstm = + 52, // kTfLiteBuiltinBidirectionalSequenceLstm + kLiteRtOpCodeTflCast = 53, // kTfLiteBuiltinCast + kLiteRtOpCodeTflPrelu = 54, // kTfLiteBuiltinPrelu + kLiteRtOpCodeTflMaximum = 55, // kTfLiteBuiltinMaximum + kLiteRtOpCodeTflArgMax = 56, // kTfLiteBuiltinArgMax + kLiteRtOpCodeTflMinimum = 57, // kTfLiteBuiltinMinimum + kLiteRtOpCodeTflLess = 58, // kTfLiteBuiltinLess + kLiteRtOpCodeTflNeg = 59, // kTfLiteBuiltinNeg + kLiteRtOpCodeTflPadv2 = 60, // kTfLiteBuiltinPadv2 + kLiteRtOpCodeTflGreater = 61, // kTfLiteBuiltinGreater + kLiteRtOpCodeTflGreaterEqual = 62, // kTfLiteBuiltinGreaterEqual + kLiteRtOpCodeTflLessEqual = 63, // kTfLiteBuiltinLessEqual + kLiteRtOpCodeTflSelect = 64, // kTfLiteBuiltinSelect + kLiteRtOpCodeTflSlice = 65, // kTfLiteBuiltinSlice + kLiteRtOpCodeTflSin = 66, // kTfLiteBuiltinSin + kLiteRtOpCodeTflTransposeConv = 67, // kTfLiteBuiltinTransposeConv + kLiteRtOpCodeTflSparseToDense = 68, // kTfLiteBuiltinSparseToDense + kLiteRtOpCodeTflTile = 69, // kTfLiteBuiltinTile + kLiteRtOpCodeTflExpandDims = 70, // kTfLiteBuiltinExpandDims + kLiteRtOpCodeTflEqual = 71, // kTfLiteBuiltinEqual + kLiteRtOpCodeTflNotEqual = 72, // kTfLiteBuiltinNotEqual + kLiteRtOpCodeTflLog = 73, // kTfLiteBuiltinLog + kLiteRtOpCodeTflSum = 74, // kTfLiteBuiltinSum + kLiteRtOpCodeTflSqrt = 75, // kTfLiteBuiltinSqrt + kLiteRtOpCodeTflRsqrt = 76, // kTfLiteBuiltinRsqrt + kLiteRtOpCodeTflShape = 77, // kTfLiteBuiltinShape + kLiteRtOpCodeTflPow = 78, // kTfLiteBuiltinPow + kLiteRtOpCodeTflArgMin = 79, // kTfLiteBuiltinArgMin + kLiteRtOpCodeTflFakeQuant = 80, // kTfLiteBuiltinFakeQuant + kLiteRtOpCodeTflReduceProd = 81, // kTfLiteBuiltinReduceProd + kLiteRtOpCodeTflReduceMax = 82, // kTfLiteBuiltinReduceMax + kLiteRtOpCodeTflPack = 83, // kTfLiteBuiltinPack + kLiteRtOpCodeTflLogicalOr = 84, // kTfLiteBuiltinLogicalOr + kLiteRtOpCodeTflOneHot = 85, // kTfLiteBuiltinOneHot + kLiteRtOpCodeTflLogicalAnd = 86, // kTfLiteBuiltinLogicalAnd + kLiteRtOpCodeTflLogicalNot = 87, // kTfLiteBuiltinLogicalNot + kLiteRtOpCodeTflUnpack = 88, // kTfLiteBuiltinUnpack + kLiteRtOpCodeTflReduceMin = 89, // kTfLiteBuiltinReduceMin + kLiteRtOpCodeTflFloorDiv = 90, // kTfLiteBuiltinFloorDiv + kLiteRtOpCodeTflReduceAny = 91, // kTfLiteBuiltinReduceAny + kLiteRtOpCodeTflSquare = 92, // kTfLiteBuiltinSquare + kLiteRtOpCodeTflZerosLike = 93, // kTfLiteBuiltinZerosLike + kLiteRtOpCodeTflFill = 94, // kTfLiteBuiltinFill + kLiteRtOpCodeTflFloorMod = 95, // kTfLiteBuiltinFloorMod + kLiteRtOpCodeTflRange = 96, // kTfLiteBuiltinRange + kLiteRtOpCodeTflResizeNearestNeighbor = + 97, // kTfLiteBuiltinResizeNearestNeighbor + kLiteRtOpCodeTflLeakyRelu = 98, // kTfLiteBuiltinLeakyRelu + kLiteRtOpCodeTflSquaredDifference = 99, // kTfLiteBuiltinSquaredDifference + kLiteRtOpCodeTflMirrorPad = 100, // kTfLiteBuiltinMirrorPad + kLiteRtOpCodeTflAbs = 101, // kTfLiteBuiltinAbs + kLiteRtOpCodeTflSplitV = 102, // kTfLiteBuiltinSplitV + kLiteRtOpCodeTflUnique = 103, // kTfLiteBuiltinUnique + kLiteRtOpCodeTflCeil = 104, // kTfLiteBuiltinCeil + kLiteRtOpCodeTflReverseV2 = 105, // kTfLiteBuiltinReverseV2 + kLiteRtOpCodeTflAddN = 106, // kTfLiteBuiltinAddN + kLiteRtOpCodeTflGatherNd = 107, // kTfLiteBuiltinGatherNd + kLiteRtOpCodeTflCos = 108, // kTfLiteBuiltinCos + kLiteRtOpCodeTflWhere = 109, // kTfLiteBuiltinWhere + kLiteRtOpCodeTflRank = 110, // kTfLiteBuiltinRank + kLiteRtOpCodeTflElu = 111, // kTfLiteBuiltinElu + kLiteRtOpCodeTflReverseSequence = 112, // kTfLiteBuiltinReverseSequence + kLiteRtOpCodeTflMatrixDiag = 113, // kTfLiteBuiltinMatrixDiag + kLiteRtOpCodeTflQuantize = 114, // kTfLiteBuiltinQuantize + kLiteRtOpCodeTflMatrixSetDiag = 115, // kTfLiteBuiltinMatrixSetDiag + kLiteRtOpCodeTflRound = 116, // kTfLiteBuiltinRound + kLiteRtOpCodeTflHardSwish = 117, // kTfLiteBuiltinHardSwish + kLiteRtOpCodeTflIf = 118, // kTfLiteBuiltinIf + kLiteRtOpCodeTflWhile = 119, // kTfLiteBuiltinWhile + kLiteRtOpCodeTflNonMaxSuppressionV4 = + 120, // kTfLiteBuiltinNonMaxSuppressionV4 + kLiteRtOpCodeTflNonMaxSuppressionV5 = + 121, // kTfLiteBuiltinNonMaxSuppressionV5 + kLiteRtOpCodeTflScatterNd = 122, // kTfLiteBuiltinScatterNd + kLiteRtOpCodeTflSelectV2 = 123, // kTfLiteBuiltinSelectV2 + kLiteRtOpCodeTflDensify = 124, // kTfLiteBuiltinDensify + kLiteRtOpCodeTflSegmentSum = 125, // kTfLiteBuiltinSegmentSum + kLiteRtOpCodeTflBatchMatmul = 126, // kTfLiteBuiltinBatchMatmul + kLiteRtOpCodeTflPlaceholderForGreaterOpCodeTfls = + 127, // kTfLiteBuiltinPlaceholderForGreaterOpCodes + kLiteRtOpCodeTflCumsum = 128, // kTfLiteBuiltinCumsum + kLiteRtOpCodeTflCallOnce = 129, // kTfLiteBuiltinCallOnce + kLiteRtOpCodeTflBroadcastTo = 130, // kTfLiteBuiltinBroadcastTo + kLiteRtOpCodeTflRfft2d = 131, // kTfLiteBuiltinRfft2d + kLiteRtOpCodeTflConv3d = 132, // kTfLiteBuiltinConv3d + kLiteRtOpCodeTflImag = 133, // kTfLiteBuiltinImag + kLiteRtOpCodeTflReal = 134, // kTfLiteBuiltinReal + kLiteRtOpCodeTflComplexAbs = 135, // kTfLiteBuiltinComplexAbs + kLiteRtOpCodeTflHashtable = 136, // kTfLiteBuiltinHashtable + kLiteRtOpCodeTflHashtableFind = 137, // kTfLiteBuiltinHashtableFind + kLiteRtOpCodeTflHashtableImport = 138, // kTfLiteBuiltinHashtableImport + kLiteRtOpCodeTflHashtableSize = 139, // kTfLiteBuiltinHashtableSize + kLiteRtOpCodeTflReduceAll = 140, // kTfLiteBuiltinReduceAll + kLiteRtOpCodeTflConv3dTranspose = 141, // kTfLiteBuiltinConv3dTranspose + kLiteRtOpCodeTflVarHandle = 142, // kTfLiteBuiltinVarHandle + kLiteRtOpCodeTflReadVariable = 143, // kTfLiteBuiltinReadVariable + kLiteRtOpCodeTflAssignVariable = 144, // kTfLiteBuiltinAssignVariable + kLiteRtOpCodeTflBroadcastArgs = 145, // kTfLiteBuiltinBroadcastArgs + kLiteRtOpCodeTflRandomStandardNormal = + 146, // kTfLiteBuiltinRandomStandardNormal + kLiteRtOpCodeTflBucketize = 147, // kTfLiteBuiltinBucketize + kLiteRtOpCodeTflRandomUniform = 148, // kTfLiteBuiltinRandomUniform + kLiteRtOpCodeTflMultinomial = 149, // kTfLiteBuiltinMultinomial + kLiteRtOpCodeTflGelu = 150, // kTfLiteBuiltinGelu + kLiteRtOpCodeTflDynamicUpdateSlice = 151, // kTfLiteBuiltinDynamicUpdateSlice + kLiteRtOpCodeTflRelu0To1 = 152, // kTfLiteBuiltinRelu0To1 + kLiteRtOpCodeTflUnsortedSegmentProd = + 153, // kTfLiteBuiltinUnsortedSegmentProd + kLiteRtOpCodeTflUnsortedSegmentMax = 154, // kTfLiteBuiltinUnsortedSegmentMax + kLiteRtOpCodeTflUnsortedSegmentSum = 155, // kTfLiteBuiltinUnsortedSegmentSum + kLiteRtOpCodeTflAtan2 = 156, // kTfLiteBuiltinAtan2 + kLiteRtOpCodeTflUnsortedSegmentMin = 157, // kTfLiteBuiltinUnsortedSegmentMin + kLiteRtOpCodeTflSign = 158, // kTfLiteBuiltinSign + kLiteRtOpCodeTflBitcast = 159, // kTfLiteBuiltinBitcast + kLiteRtOpCodeTflBitwiseXor = 160, // kTfLiteBuiltinBitwiseXor + kLiteRtOpCodeTflRightShift = 161, // kTfLiteBuiltinRightShift + kLiteRtOpCodeShloLogistic = 162, // kTfLiteBuiltinStablehloLogistic + kLiteRtOpCodeShloAdd = 163, // kTfLiteBuiltinStablehloAdd + kLiteRtOpCodeShloDivide = 164, // kTfLiteBuiltinStablehloDivide + kLiteRtOpCodeShloMultiply = 165, // kTfLiteBuiltinStablehloMultiply + kLiteRtOpCodeShloMaximum = 166, // kTfLiteBuiltinStablehloMaximum + kLiteRtOpCodeShloReshape = 167, // kTfLiteBuiltinStablehloReshape + kLiteRtOpCodeShloClamp = 168, // kTfLiteBuiltinStablehloClamp + kLiteRtOpCodeShloConcatenate = 169, // kTfLiteBuiltinStablehloConcatenate + kLiteRtOpCodeShloBroadcastInDim = + 170, // kTfLiteBuiltinStablehloBroadcastInDim + kLiteRtOpCodeShloConvolution = 171, // kTfLiteBuiltinStablehloConvolution + kLiteRtOpCodeShloSlice = 172, // kTfLiteBuiltinStablehloSlice + kLiteRtOpCodeShloCustomCall = 173, // kTfLiteBuiltinStablehloCustomCall + kLiteRtOpCodeShloReduce = 174, // kTfLiteBuiltinStablehloReduce + kLiteRtOpCodeShloAbs = 175, // kTfLiteBuiltinStablehloAbs + kLiteRtOpCodeShloAnd = 176, // kTfLiteBuiltinStablehloAnd + kLiteRtOpCodeShloCosine = 177, // kTfLiteBuiltinStablehloCosine + kLiteRtOpCodeShloExponential = 178, // kTfLiteBuiltinStablehloExponential + kLiteRtOpCodeShloFloor = 179, // kTfLiteBuiltinStablehloFloor + kLiteRtOpCodeShloLog = 180, // kTfLiteBuiltinStablehloLog + kLiteRtOpCodeShloMinimum = 181, // kTfLiteBuiltinStablehloMinimum + kLiteRtOpCodeShloNegate = 182, // kTfLiteBuiltinStablehloNegate + kLiteRtOpCodeShloOr = 183, // kTfLiteBuiltinStablehloOr + kLiteRtOpCodeShloPower = 184, // kTfLiteBuiltinStablehloPower + kLiteRtOpCodeShloRemainder = 185, // kTfLiteBuiltinStablehloRemainder + kLiteRtOpCodeShloRsqrt = 186, // kTfLiteBuiltinStablehloRsqrt + kLiteRtOpCodeShloSelect = 187, // kTfLiteBuiltinStablehloSelect + kLiteRtOpCodeShloSubtract = 188, // kTfLiteBuiltinStablehloSubtract + kLiteRtOpCodeShloTanh = 189, // kTfLiteBuiltinStablehloTanh + kLiteRtOpCodeShloScatter = 190, // kTfLiteBuiltinStablehloScatter + kLiteRtOpCodeShloCompare = 191, // kTfLiteBuiltinStablehloCompare + kLiteRtOpCodeShloConvert = 192, // kTfLiteBuiltinStablehloConvert + kLiteRtOpCodeShloDynamicSlice = 193, // kTfLiteBuiltinStablehloDynamicSlice + kLiteRtOpCodeShloDynamicUpdateSlice = + 194, // kTfLiteBuiltinStablehloDynamicUpdateSlice + kLiteRtOpCodeShloPad = 195, // kTfLiteBuiltinStablehloPad + kLiteRtOpCodeShloIota = 196, // kTfLiteBuiltinStablehloIota + kLiteRtOpCodeShloGeneral = 197, // kTfLiteBuiltinStablehloDotGeneral + kLiteRtOpCodeShloWindow = 198, // kTfLiteBuiltinStablehloReduceWindow + kLiteRtOpCodeShloSort = 199, // kTfLiteBuiltinStablehloSort + kLiteRtOpCodeShloWhile = 200, // kTfLiteBuiltinStablehloWhile + kLiteRtOpCodeShloGather = 201, // kTfLiteBuiltinStablehloGather + kLiteRtOpCodeShloTranspose = 202, // kTfLiteBuiltinStablehloTranspose + kLiteRtOpCodeTflDilate = 203, // kTfLiteBuiltinDilate + kLiteRtOpCodeShloRngBitGenerator = + 204, // kTfLiteBuiltinStablehloRngBitGenerator + kLiteRtOpCodeTflReduceWindow = 205, // kTfLiteBuiltinReduceWindow + kLiteRtOpCodeShloComposite = 206, // kTfLiteBuiltinStablehloComposite +} LiteRtOpCode; + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_OP_CODE_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_op_options.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_op_options.h new file mode 100644 index 0000000000000000000000000000000000000000..4ef92509fd5277db68d205fdae5a878c28dd8814 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_op_options.h @@ -0,0 +1,691 @@ +// Copyright 2024 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_OP_OPTIONS_H_ +#define ODML_LITERT_LITERT_C_LITERT_OP_OPTIONS_H_ + +#include // NOLINT: To use bool type in C +#include + +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// +// Op options, getter and builder APIs. +// + +//============================================================================== +// +// Get option APIs for LiteRt ADD op. +// Options: +// - FusedActivationOption : uint32_t +// +//============================================================================== +LiteRtStatus LiteRtGetAddFusedActivationOption(LiteRtOp op, + uint32_t* fused_activation); +LiteRtStatus LiteRtBuilderBuildAddOpOption(LiteRtBuilder builder, LiteRtOp op, + uint32_t* fused_activation); + +//============================================================================== +// +// Get option APIs for LiteRt BatchMatmul op. +// Options: +// - AdjXOption : bool +// - AdjYOption : bool +// - AsymmtericQuantizeInputOption : bool +// +//============================================================================== +LiteRtStatus LiteRtGetBatchMatmulAdjXOption(LiteRtOp op, bool* adj_x); +LiteRtStatus LiteRtGetBatchMatmulAdjYOption(LiteRtOp op, bool* adj_y); +LiteRtStatus LiteRtGetBatchMatmulAsymmetricQuantizeInputOption( + LiteRtOp op, bool* asymmetric_quantize_input); +LiteRtStatus LiteRtBuilderBuildBatchMatmulOpOption( + LiteRtBuilder builder, LiteRtOp op, bool* adj_x, bool* adj_y, + bool* asymmetric_quantize_input); + +//============================================================================== +// +// Get option APIs for LiteRt Concatenation op. +// Options: +// - FusedActivationOption : uint32_t +// - AxisOption : int32_t +// +//============================================================================== +LiteRtStatus LiteRtGetConcatenationFusedActivationOption( + LiteRtOp op, uint32_t* fused_activation); +LiteRtStatus LiteRtGetConcatenationAxisOption(LiteRtOp op, int32_t* axis); +LiteRtStatus LiteRtBuilderBuildConcatenationOpOption(LiteRtBuilder builder, + LiteRtOp op, + uint32_t* fused_activation, + int32_t* axis); + +//============================================================================== +// +// Get option APIs for LiteRt Div op. +// Options: +// - FusedActivationOption : uint32_t +// +//============================================================================== +LiteRtStatus LiteRtGetDivFusedActivationOption(LiteRtOp op, + uint32_t* fused_activation); +LiteRtStatus LiteRtBuilderBuildDivOpOption(LiteRtBuilder builder, LiteRtOp op, + uint32_t* fused_activation); + +//============================================================================== +// +// Get option APIs for LiteRt FullyConnected op. +// Options: +// - FusedActivationOption : uint32_t +// - WeightsFormatOption : uint32_t +// - KeepNumDimsOption : bool +// - QuantizedBiasTypeOption : uint32_t +// - AsymmtericQuantizeInputOption : bool +// +//============================================================================== +LiteRtStatus LiteRtGetFullyConnectedFusedActivationOption( + LiteRtOp op, uint32_t* fused_activation); +LiteRtStatus LiteRtGetFullyConnectedWeightsFormatOption( + LiteRtOp op, uint32_t* weights_format); +LiteRtStatus LiteRtGetFullyConnectedKeepNumDimsOption(LiteRtOp op, + bool* keep_num_dims); +LiteRtStatus LiteRtFullyConnectedGetQuantizedBiasTypeOption( + LiteRtOp op, uint32_t* quantized_bias_type); +LiteRtStatus LiteRtGetFullyConnectedAsymmetricQuantizeInputOption( + LiteRtOp op, bool* asymmetric_quantize_input); +LiteRtStatus LiteRtBuilderBuildFullyConnectedOpOption( + LiteRtBuilder builder, LiteRtOp op, uint32_t* fused_activation, + uint32_t* weights_format, bool* keep_num_dims, + uint32_t* quantized_bias_type, bool* asymmetric_quantize_input); + +//============================================================================== +// +// Get option APIs for LiteRt Mul op. +// Options: +// - FusedActivationOption : uint32_t +// +//============================================================================== +LiteRtStatus LiteRtGetMulFusedActivationOption(LiteRtOp op, + uint32_t* fused_activation); +LiteRtStatus LiteRtBuilderBuildMulOpOption(LiteRtBuilder builder, LiteRtOp op, + uint32_t* fused_activation); + +//============================================================================== +// +// Get option APIs for LiteRt Softmax op. +// Options: +// - BetaOption : float +// +//============================================================================== +LiteRtStatus LiteRtGetSoftmaxBetaOption(LiteRtOp op, float* beta); +LiteRtStatus LiteRtBuilderBuildSoftmaxOpOption(LiteRtBuilder builder, + LiteRtOp op, float* beta); + +//============================================================================== +// +// Get option APIs for LiteRt StridedSlice op. +// Options: +// - BeginMaskOption : int32_t +// - EndMaskOption : int32_t +// - EllipsisMaskOption : int32_t +// - NewAxisMaskOption : int32_t +// - ShrinkAxisMaskOption : int32_t +// - OffsetOption : bool + +//============================================================================== +LiteRtStatus LiteRtGetStridedSliceBeginMaskOption(LiteRtOp op, + int32_t* begin_mask); +LiteRtStatus LiteRtGetStridedSliceEndMaskOption(LiteRtOp op, int32_t* end_mask); +LiteRtStatus LiteRtGetStridedSliceEllipsisMaskOption(LiteRtOp op, + int32_t* ellipsis_mask); +LiteRtStatus LiteRtGetStridedSliceNewAxisMaskOption(LiteRtOp op, + int32_t* new_axis_mask); +LiteRtStatus LiteRtGetStridedSliceShrinkAxisMaskOption( + LiteRtOp op, int32_t* shrink_axis_mask); +LiteRtStatus LiteRtGetStridedSliceOffsetOption(LiteRtOp op, bool* offset); +LiteRtStatus LiteRtBuilderBuildStridedSliceOpOption( + LiteRtBuilder builder, LiteRtOp op, int32_t* begin_mask, int32_t* end_mask, + int32_t* ellipsis_mask, int32_t* new_axis_mask, int32_t* shrink_axis_mask, + bool* offset); + +//============================================================================== +// +// Get option APIs for LiteRt Sub op. +// Options: +// - FusedActivationOption : uint32_t +// - (Not supported) PotScaleInt16Option : bool +// +//============================================================================== +LiteRtStatus LiteRtGetSubFusedActivationOption(LiteRtOp op, + uint32_t* fused_activation); +LiteRtStatus LiteRtBuilderBuildSubOpOption(LiteRtBuilder builder, LiteRtOp op, + uint32_t* fused_activation); + +//============================================================================== +// +// Get option APIs for LiteRt Reshape op. +// Options: +// - new_shape : int32_t[] +// - new_shape_size : int32_t +// +// Note that for a Reshape op to unpack a tensor of one element to a scalar, the +// 'new_shape' may be set to nullptr and 'new_shape_size' may be set to 0. The +// return value is kLiteRtStatusOk in this case. +// +//============================================================================== +LiteRtStatus LiteRtGetReshapeNewShapeOption(LiteRtOp op, + const int32_t** new_shape, + int32_t* new_shape_size); +LiteRtStatus LiteRtBuilderBuildReshapeOpOption(LiteRtBuilder builder, + LiteRtOp op, int32_t* new_shape, + int32_t new_shape_size); + +//============================================================================== +// +// Get option APIs for LiteRt Sum op. +// Options: +// - KeepdimsOption : bool +// +//============================================================================== +LiteRtStatus LiteRtGetSumKeepDimsOption(LiteRtOp op, bool* keepdims); +LiteRtStatus LiteRtBuilderBuildSumOpOption(LiteRtBuilder builder, LiteRtOp op, + bool* keepdims); + +//============================================================================== +// +// Get option APIs for LiteRt ReduceMax op. +// Options: +// - KeepdimsOption : bool +// +//============================================================================== +LiteRtStatus LiteRtGetReduceMaxKeepDimsOption(LiteRtOp op, bool* keepdims); +LiteRtStatus LiteRtBuilderBuildReduceMaxOpOption(LiteRtBuilder builder, + LiteRtOp op, bool* keepdims); + +//============================================================================== +// +// Get option APIs for LiteRt ReduceMin op. +// Options: +// - KeepdimsOption : bool +// +//============================================================================== +LiteRtStatus LiteRtGetReduceMinKeepDimsOption(LiteRtOp op, bool* keepdims); +LiteRtStatus LiteRtBuilderBuildReduceMinOpOption(LiteRtBuilder builder, + LiteRtOp op, bool* keepdims); + +//============================================================================== +// +// Get option APIs for LiteRt ReduceAny op. +// Options: +// - KeepdimsOption : bool +// +//============================================================================== +LiteRtStatus LiteRtGetReduceAnyKeepDimsOption(LiteRtOp op, bool* keepdims); +LiteRtStatus LiteRtBuilderBuildReduceAnyOpOption(LiteRtBuilder builder, + LiteRtOp op, bool* keepdims); + +//============================================================================== +// +// Get option APIs for LiteRt ReduceAll op. +// Options: +// - KeepdimsOption : bool +// +//============================================================================== +LiteRtStatus LiteRtGetReduceAllKeepDimsOption(LiteRtOp op, bool* keepdims); +LiteRtStatus LiteRtBuilderBuildReduceAllOpOption(LiteRtBuilder builder, + LiteRtOp op, bool* keepdims); + +//============================================================================== +// +// Get option APIs for LiteRt Pack op. +// Options: +// - axis : int32_t +// - values_count : int32_t +// +//============================================================================== +LiteRtStatus LiteRtGetPackAxisOption(LiteRtOp op, int32_t* axis); +LiteRtStatus LiteRtGetPackValuesCountOption(LiteRtOp op, int32_t* values_count); +LiteRtStatus LiteRtBuilderBuildPackOpOption(LiteRtBuilder builder, LiteRtOp op, + int32_t* axis, + int32_t* values_count); + +//============================================================================== +// +// Get option APIs for LiteRt OneHot op. +// Options: +// - axis : int32_t +// +//============================================================================== +LiteRtStatus LiteRtGetOneHotAxisOption(LiteRtOp op, int32_t* axis); +LiteRtStatus LiteRtBuilderBuildOneHotOpOption(LiteRtBuilder builder, + LiteRtOp op, int32_t* axis); + +//============================================================================== +// +// Get option APIs for LiteRt Unpack op. +// Options: +// - axis : int32_t +// - num : int32_t +// +//============================================================================== +LiteRtStatus LiteRtGetUnpackAxisOption(LiteRtOp op, int32_t* axis); +LiteRtStatus LiteRtGetUnpackNumOption(LiteRtOp op, int32_t* num); +LiteRtStatus LiteRtBuilderBuildUnpackOpOption(LiteRtBuilder builder, + LiteRtOp op, int32_t* axis, + int32_t* num); + +//============================================================================== +// +// Get option APIs for LiteRt Gather op. +// Options: +// - axisOption : int32_t +// - batch_dims : int32_t +// +//============================================================================== +LiteRtStatus LiteRtGetGatherAxisOption(LiteRtOp op, int32_t* axis); +LiteRtStatus LiteRtGetGatherBatchDimsOption(LiteRtOp op, int32_t* batch_dims); +LiteRtStatus LiteRtBuilderBuildGatherOpOption(LiteRtBuilder builder, + LiteRtOp op, int32_t* axis, + int32_t* batch_dims); + +//============================================================================== +// +// Get option APIs for LiteRt Mean op. +// Options: +// - keepdimsOption : bool +// +//============================================================================== +LiteRtStatus LiteRtGetMeanKeepDimsOption(LiteRtOp op, bool* keepdims); +LiteRtStatus LiteRtBuilderBuildMeanOpOption(LiteRtBuilder builder, LiteRtOp op, + bool* keepdims); + +//============================================================================== +// +// Get option APIs for LiteRt Split op. +// Options: +// - num_splits : int32_t +// +//============================================================================== +LiteRtStatus LiteRtGetSplitNumSplitsOption(LiteRtOp op, int32_t* num_splits); +LiteRtStatus LiteRtBuilderBuildSplitOpOption(LiteRtBuilder builder, LiteRtOp op, + int32_t* num_splits); + +//============================================================================== +// +// Get option APIs for LiteRt SplitV op. +// Options: +// - num_splits : int32_t +// +//============================================================================== +LiteRtStatus LiteRtGetSplitVNumSplitsOption(LiteRtOp op, int32_t* num_splits); + +//============================================================================== +// +// Build option APIs for LiteRt SplitV op. +// Options: +// - num_splits : int32_t +// +//============================================================================== +LiteRtStatus LiteRtBuilderBuildSplitVOpOption(LiteRtBuilder builder, + LiteRtOp op, int32_t* num_splits); + +//============================================================================== +// +// Get option APIs for LiteRt SHLO Composite op. +// Options: +// - name : string +// - decomposition_subgraph_index : int32_t +// - attributes : uint8_t[] +// - version : int32_t +// +//============================================================================== + +// Returns the name of the SHLO composite op. +// The returned string pointer is owned by the LiteRtModel to which the given +// LiteRtOp belongs. It becomes invalid when the LiteRtModel is destroyed. +LiteRtStatus LiteRtGetSHLOCompositeOpName(LiteRtOp op, const char** name); +LiteRtStatus LiteRtGetSHLOCompositeOpDecompositionSubgraphIndex( + LiteRtOp op, int32_t* decomposition_subgraph_index); +LiteRtStatus LiteRtGetSHLOCompositeOpAttributes(LiteRtOp op, + const uint8_t** attributes, + int32_t* attributes_size); +LiteRtStatus LiteRtGetSHLOCompositeOpVersion(LiteRtOp op, int32_t* version); +LiteRtStatus LiteRtBuilderBuildShloCompositeOpOption( + LiteRtBuilder builder, LiteRtOp op, const char* name, + const int32_t* decomposition_subgraph_index, const int32_t* version, + const uint8_t* attributes, LiteRtParamIndex attributes_size); + +//============================================================================== +// +// Get option APIs for LiteRt Conv2d op. +// Options: +// - padding : uint32_t +// - stride_w : int32_t +// - stride_h : int32_t +// - fused_activation_function : uint32_t +// - dilation_w_factor : int32_t +// - dilation_h_factor : int32_t +// +//============================================================================== +LiteRtStatus LiteRtGetConv2dPaddingOption(LiteRtOp op, uint32_t* padding); +LiteRtStatus LiteRtGetConv2dStrideWOption(LiteRtOp op, int32_t* stride_w); +LiteRtStatus LiteRtGetConv2dStrideHOption(LiteRtOp op, int32_t* stride_h); +LiteRtStatus LiteRtGetConv2dFusedActivationOption( + LiteRtOp op, uint32_t* fused_activation_function); +LiteRtStatus LiteRtGetConv2dDilationWOption(LiteRtOp op, + int32_t* dilation_w_factor); +LiteRtStatus LiteRtGetConv2dDilationHOption(LiteRtOp op, + int32_t* dilation_h_factor); +LiteRtStatus LiteRtBuilderBuildConv2dOpOption( + LiteRtBuilder builder, LiteRtOp op, uint32_t* padding, int32_t* stride_w, + int32_t* stride_h, int32_t* dilation_w_factor, int32_t* dilation_h_factor, + uint32_t* fused_activation_function); + +//============================================================================== +// +// Get option APIs for LiteRt Conv3d op. +// Options: +// - padding : uint32_t +// - stride_d : int32_t +// - stride_w : int32_t +// - stride_h : int32_t +// - fused_activation_function : uint32_t +// - dilation_d_factor : int32_t +// - dilation_w_factor : int32_t +// - dilation_h_factor : int32_t +// +//============================================================================== +LiteRtStatus LiteRtGetConv3dPaddingOption(LiteRtOp op, uint32_t* padding); +LiteRtStatus LiteRtGetConv3dStrideDOption(LiteRtOp op, int32_t* stride_d); +LiteRtStatus LiteRtGetConv3dStrideWOption(LiteRtOp op, int32_t* stride_w); +LiteRtStatus LiteRtGetConv3dStrideHOption(LiteRtOp op, int32_t* stride_h); +LiteRtStatus LiteRtGetConv3dFusedActivationOption( + LiteRtOp op, uint32_t* fused_activation_function); +LiteRtStatus LiteRtGetConv3dDilationDOption(LiteRtOp op, + int32_t* dilation_d_factor); +LiteRtStatus LiteRtGetConv3dDilationWOption(LiteRtOp op, + int32_t* dilation_w_factor); +LiteRtStatus LiteRtGetConv3dDilationHOption(LiteRtOp op, + int32_t* dilation_h_factor); +LiteRtStatus LiteRtBuilderBuildConv3dOpOption( + LiteRtBuilder builder, LiteRtOp op, uint32_t* padding, int32_t* stride_w, + int32_t* stride_h, int32_t* stride_d, int32_t* dilation_w_factor, + int32_t* dilation_h_factor, int32_t* dilation_d_factor, + uint32_t* fused_activation_function); + +//============================================================================== +// +// Get option APIs for LiteRt DepthwiseConv2d op. +// Options: +// - padding : uint32_t +// - stride_w : int32_t +// - stride_h : int32_t +// - depth_multiplier : int32_t +// - fused_activation_function : uint32_t +// - dilation_w_factor : int32_t +// - dilation_h_factor : int32_t +// +//============================================================================== +LiteRtStatus LiteRtGetDepthwiseConv2dPaddingOption(LiteRtOp op, + uint32_t* padding); +LiteRtStatus LiteRtGetDepthwiseConv2dStrideWOption(LiteRtOp op, + int32_t* stride_w); +LiteRtStatus LiteRtGetDepthwiseConv2dStrideHOption(LiteRtOp op, + int32_t* stride_h); +LiteRtStatus LiteRtGetDepthwiseConv2dDepthMultiplierOption( + LiteRtOp op, int32_t* depth_multiplier); +LiteRtStatus LiteRtGetDepthwiseConv2dFusedActivationOption( + LiteRtOp op, uint32_t* fused_activation_function); +LiteRtStatus LiteRtGetDepthwiseConv2dDilationWOption( + LiteRtOp op, int32_t* dilation_w_factor); +LiteRtStatus LiteRtGetDepthwiseConv2dDilationHOption( + LiteRtOp op, int32_t* dilation_h_factor); +LiteRtStatus LiteRtBuilderBuildDepthwiseConv2dOpOption( + LiteRtBuilder builder, LiteRtOp op, uint32_t* padding, int32_t* stride_w, + int32_t* stride_h, int32_t* depth_multiplier, + uint32_t* fused_activation_function, int32_t* dilation_w_factor, + int32_t* dilation_h_factor); + +//============================================================================== +// +// Get option APIs for LiteRt TransposeConv op. +// Options: +// - padding : uint32_t +// - stride_w : int32_t +// - stride_h : int32_t +// - fused_activation_function : uint32_t +// +//============================================================================== +LiteRtStatus LiteRtGetTransposeConvPaddingOption(LiteRtOp op, + uint32_t* padding); +LiteRtStatus LiteRtGetTransposeConvStrideWOption(LiteRtOp op, + int32_t* stride_w); +LiteRtStatus LiteRtGetTransposeConvStrideHOption(LiteRtOp op, + int32_t* stride_h); +LiteRtStatus LiteRtGetTransposeConvFusedActivationOption( + LiteRtOp op, uint32_t* fused_activation_function); +LiteRtStatus LiteRtBuilderBuildTransposeConvOpOption( + LiteRtBuilder builder, LiteRtOp op, uint32_t* padding, int32_t* stride_w, + int32_t* stride_h, uint32_t* fused_activation_function); + +//============================================================================== +// +// Get option APIs for LiteRt AveragePool2d op. +// Options: +// - padding : uint32_t +// - stride_w : int32_t +// - stride_h : int32_t +// - filter_width : int32_t +// - filter_height : int32_t +// - fused_activation_function : uint32_t +// +//============================================================================== +LiteRtStatus LiteRtGetAveragePool2dPaddingOption(LiteRtOp op, + uint32_t* padding); +LiteRtStatus LiteRtGetAveragePool2dStrideWOption(LiteRtOp op, + int32_t* stride_w); +LiteRtStatus LiteRtGetAveragePool2dStrideHOption(LiteRtOp op, + int32_t* stride_h); +LiteRtStatus LiteRtGetAveragePool2dFilterWidthOption(LiteRtOp op, + int32_t* filter_width); +LiteRtStatus LiteRtGetAveragePool2dFilterHeightOption(LiteRtOp op, + int32_t* filter_height); +LiteRtStatus LiteRtGetAveragePool2dFusedActivationOption( + LiteRtOp op, uint32_t* fused_activation_function); +LiteRtStatus LiteRtBuilderBuildAveragePool2dOpOption( + LiteRtBuilder builder, LiteRtOp op, uint32_t* padding, int32_t* stride_w, + int32_t* stride_h, int32_t* filter_width, int32_t* filter_height, + uint32_t* fused_activation_function); + +//============================================================================== +// +// Get option APIs for LiteRt MaxPool2d op. +// Options: +// - padding : uint32_t +// - stride_w : int32_t +// - stride_h : int32_t +// - filter_width : int32_t +// - filter_height : int32_t +// - fused_activation_function : uint32_t +// +//============================================================================== +LiteRtStatus LiteRtGetMaxPool2dPaddingOption(LiteRtOp op, uint32_t* padding); +LiteRtStatus LiteRtGetMaxPool2dStrideWOption(LiteRtOp op, int32_t* stride_w); +LiteRtStatus LiteRtGetMaxPool2dStrideHOption(LiteRtOp op, int32_t* stride_h); +LiteRtStatus LiteRtGetMaxPool2dFilterWidthOption(LiteRtOp op, + int32_t* filter_width); +LiteRtStatus LiteRtGetMaxPool2dFilterHeightOption(LiteRtOp op, + int32_t* filter_height); +LiteRtStatus LiteRtGetMaxPool2dFusedActivationOption( + LiteRtOp op, uint32_t* fused_activation_function); +LiteRtStatus LiteRtBuilderBuildMaxPool2dOpOption( + LiteRtBuilder builder, LiteRtOp op, uint32_t* padding, int32_t* stride_w, + int32_t* stride_h, int32_t* filter_width, int32_t* filter_height, + uint32_t* fused_activation_function); + +//============================================================================== +// +// Get option APIs for LiteRt L2Pool2d op. +// Options: +// - padding : uint32_t +// - stride_w : int32_t +// - stride_h : int32_t +// - filter_width : int32_t +// - filter_height : int32_t +// - fused_activation_function : uint32_t +// +//============================================================================== +LiteRtStatus LiteRtGetL2Pool2dPaddingOption(LiteRtOp op, uint32_t* padding); +LiteRtStatus LiteRtGetL2Pool2dStrideWOption(LiteRtOp op, int32_t* stride_w); +LiteRtStatus LiteRtGetL2Pool2dStrideHOption(LiteRtOp op, int32_t* stride_h); +LiteRtStatus LiteRtGetL2Pool2dFilterWidthOption(LiteRtOp op, + int32_t* filter_width); +LiteRtStatus LiteRtGetL2Pool2dFilterHeightOption(LiteRtOp op, + int32_t* filter_height); +LiteRtStatus LiteRtGetL2Pool2dFusedActivationOption( + LiteRtOp op, uint32_t* fused_activation_function); +LiteRtStatus LiteRtBuilderBuildL2Pool2dOpOption( + LiteRtBuilder builder, LiteRtOp op, uint32_t* padding, int32_t* stride_w, + int32_t* stride_h, int32_t* filter_width, int32_t* filter_height, + uint32_t* fused_activation_function); + +//============================================================================== +// +// Get option APIs for LiteRt ResizeBilinear op. +// Options: +// - align_corners : bool +// - half_pixel_centers : bool +// +//============================================================================== +LiteRtStatus LiteRtGetResizeBilinearAlignCornersOption(LiteRtOp op, + bool* align_corners); +LiteRtStatus LiteRtGetResizeBilinearHalfPixelCenterOption( + LiteRtOp op, bool* half_pixel_centers); +LiteRtStatus LiteRtBuilderBuildResizeBilinearOpOption(LiteRtBuilder builder, + LiteRtOp op, + bool* align_corners, + bool* half_pixel_centers); + +//============================================================================== +// +// Get option APIs for LiteRt LeakyRelu op. +// Options: +// - alpha : float +// +//============================================================================== +LiteRtStatus LiteRtGetLeakyReluAlphaOption(LiteRtOp op, float* alpha); +LiteRtStatus LiteRtBuilderBuildLeakyReluOpOption(LiteRtBuilder builder, + LiteRtOp op, float* alpha); + +//============================================================================== +// +// Get option APIs for LiteRt DepthToSpace op. +// Options: +// - block_size : int32_t +// +//============================================================================== +LiteRtStatus LiteRtGetDepthToSpaceBlockSizeOption(LiteRtOp op, + int32_t* block_size); +LiteRtStatus LiteRtBuilderBuildDepthToSpaceOpOption(LiteRtBuilder builder, + LiteRtOp op, + int32_t* block_size); + +//============================================================================== +// +// Get option APIs for LiteRt SpaceToDepth op. +// Options: +// - block_size : int32_t +// +//============================================================================== +LiteRtStatus LiteRtGetSpaceToDepthBlockSizeOption(LiteRtOp op, + int32_t* block_size); +LiteRtStatus LiteRtBuilderBuildSpaceToDepthOpOption(LiteRtBuilder builder, + LiteRtOp op, + int32_t* block_size); + +//============================================================================== +// +// Get option APIs for LiteRt ResizeNearestNeighbor op. +// Options: +// - align_corners : bool +// - half_pixel_centers : bool +// +//============================================================================== +LiteRtStatus LiteRtGetResizeNearestNeighborAlignCornersOption( + LiteRtOp op, bool* align_corners); +LiteRtStatus LiteRtGetResizeNearestNeighborHalfPixelCenterOption( + LiteRtOp op, bool* half_pixel_centers); +LiteRtStatus LiteRtBuilderBuildResizeNearestNeighborOpOption( + LiteRtBuilder builder, LiteRtOp op, bool* align_corners, + bool* half_pixel_centers); + +//============================================================================== +// +// Get option APIs for LiteRt CumSum op. +// Options: +// - exclusive : bool +// - reverse : bool +// +//============================================================================== +LiteRtStatus LiteRtGetCumsumExclusiveOption(LiteRtOp op, bool* exclusive); +LiteRtStatus LiteRtGetCumsumReverseOption(LiteRtOp op, bool* reverse); +LiteRtStatus LiteRtBuilderBuildCumsumOpOption(LiteRtBuilder builder, + LiteRtOp op, bool* exclusive, + bool* reverse); + +//============================================================================== +// +// Get option APIs for LiteRt Gelu op. +// Options: +// - approximate : bool +// +//============================================================================== +LiteRtStatus LiteRtGetGeluApproximateOption(LiteRtOp op, bool* approximate); +LiteRtStatus LiteRtBuilderBuildGeluOpOption(LiteRtBuilder builder, LiteRtOp op, + bool* approximate); + +//============================================================================== +// +// Get option APIs for LiteRt Mirror Pad op. +// Options: +// - mode : uint32_t +// +//============================================================================== +LiteRtStatus LiteRtGetMirrorPadModeOption(LiteRtOp op, uint32_t* mode); +LiteRtStatus LiteRtBuilderBuildMirrorPadOpOption(LiteRtBuilder builder, + LiteRtOp op, uint32_t* mode); + +//============================================================================== +// +// Get option APIs for LiteRt Squeeze op. +// Options: +// - squeeze_dims : int32_t[] +// - num_squeeze_dims : int32_t +// +//============================================================================== +LiteRtStatus LiteRtGetSqueezeDimsOption(LiteRtOp op, + const int32_t** squeeze_dims, + int32_t* num_squeeze_dims); +LiteRtStatus LiteRtBuilderBuildSqueezeOpOption(LiteRtBuilder builder, + LiteRtOp op, + const int32_t* squeeze_dims, + int32_t num_squeeze_dims); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_OP_OPTIONS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_opaque_options.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_opaque_options.h new file mode 100644 index 0000000000000000000000000000000000000000..0aad46dd0b128b7c83020ecdd7b9383467f85f23 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_opaque_options.h @@ -0,0 +1,98 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_OPAQUE_OPTIONS_H_ +#define ODML_LITERT_LITERT_C_LITERT_OPAQUE_OPTIONS_H_ + +#include + +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// A linked list of type erased opaque options. List items +// include: +// +// - a unique payload identifier field (string), used to distinguish payloads of +// different types; +// +// - a payload field and associated payload destructor callback; + +LiteRtStatus LiteRtCreateOpaqueOptions( + const char* payload_identifier, void* payload_data, + void (*payload_destructor)(void* payload_data), + LiteRtOpaqueOptions* options); + +// Releases an entire options list starting from `options`. +// +// Warning: Once an `options` item has been appended to another `options` item, +// the user will no longer need to destoy the former `options` item manually +// with this function. +void LiteRtDestroyOpaqueOptions(LiteRtOpaqueOptions options); + +// Gets the patload identifier field of the first item in the given `options` +// list. +LiteRtStatus LiteRtGetOpaqueOptionsIdentifier(LiteRtOpaqueOptions options, + const char** payload_identifier); + +// Gets the payload data field of the first item in the given `options` list. +LiteRtStatus LiteRtGetOpaqueOptionsData(LiteRtOpaqueOptions options, + void** payload_data); + +// Gets the payload data for the `options` list item with a given +// payload identifier. Return kLiteRtStatusErrorNotFound if not such item is +// found. +LiteRtStatus LiteRtFindOpaqueOptionsData(LiteRtOpaqueOptions options, + const char* payload_identifier, + void** payload_data); + +// Iterate through the next item in the option list pointed by `options` and +// sets parameter `options` to null if there is no next item. +LiteRtStatus LiteRtGetNextOpaqueOptions(LiteRtOpaqueOptions* options); + +// Appends `next_options` to the list ponted by `options` and takes ownership of +// the appended object. While parameter `options` must be non-null, `*options` +// may however be null, in which case this call is equivalent to `*options = +// appended_options`. +LiteRtStatus LiteRtAppendOpaqueOptions(LiteRtOpaqueOptions* options, + LiteRtOpaqueOptions appended_options); + +// Removes and deallocates the last option in the linked list pointed by +// parameter `options`. +LiteRtStatus LiteRtPopOpaqueOptions(LiteRtOpaqueOptions* options); + +// A hash function that takes the payload data as input and returns a 64-bit +// hash. +typedef uint64_t (*LiteRtOpaqueOptionsHashFunc)(const void* payload_data); + +// Sets the payload hash function for the first item in the given `options` +// list. The hash function takes the payload data as input and returns a 64-bit +// hash. +LiteRtStatus LiteRtSetOpaqueOptionsHash( + LiteRtOpaqueOptions options, LiteRtOpaqueOptionsHashFunc payload_hash_func); + +// Computes and returns the payload hash for the first item in the given +// `options` list. +// +// Returns `kLiteRtStatusErrorUnsupported` if no hash function has been set +// for the given `options` via `LiteRtSetOpaqueOptionsPayloadHashFunc`. +LiteRtStatus LiteRtGetOpaqueOptionsHash(LiteRtOpaqueOptions options, + uint64_t* hash); +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // ODML_LITERT_LITERT_C_LITERT_OPAQUE_OPTIONS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_opencl_types.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_opencl_types.h new file mode 100644 index 0000000000000000000000000000000000000000..8bf0a20ffa02d6b248a0afd90804113ad1f14176 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_opencl_types.h @@ -0,0 +1,45 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_OPENCL_TYPES_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_OPENCL_TYPES_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/** + * Define LiteRT aliases for OpenCL types without requiring downstream users to + * include the OpenCL SDK headers just to compile LiteRT public headers. + * + * The OpenCL C API models both `cl_mem` and `cl_event` as opaque pointers to + * implementation-defined structs. Forward-declaring the same struct tags keeps + * LiteRT's public ABI compatible with code that later includes `CL/cl.h`, + * while avoiding a transitive dependency on the OpenCL headers for consumers + * that never bind directly to raw OpenCL objects. + */ +typedef struct _cl_mem* LiteRtClMem; +typedef struct _cl_event* LiteRtClEvent; +typedef int32_t LiteRtClInt; + +#define LITE_RT_CL_SUCCESS 0 +#define LITE_RT_CL_COMPLETE 0x0 + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_OPENCL_TYPES_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_options.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_options.h new file mode 100644 index 0000000000000000000000000000000000000000..0d0a5572dcba003ff6370649a46d6972e840ff9e --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_options.h @@ -0,0 +1,76 @@ +// Copyright 2024 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_OPTIONS_H_ +#define ODML_LITERT_LITERT_C_LITERT_OPTIONS_H_ + +#include "litert/c/litert_common.h" +#include "litert/c/litert_custom_op_kernel.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Creates a compilation option object. +LiteRtStatus LiteRtCreateOptions(LiteRtOptions* options); + +// Destroys a compilation option object. +void LiteRtDestroyOptions(LiteRtOptions options); + +// Sets the requested hardware accelerators to apply during model compilation. +LiteRtStatus LiteRtSetOptionsHardwareAccelerators( + LiteRtOptions options, LiteRtHwAcceleratorSet hardware_accelerators); + +// Gets the hardware accelerators to apply during model compilation. +LiteRtStatus LiteRtGetOptionsHardwareAccelerators( + LiteRtOptions options, LiteRtHwAcceleratorSet* hardware_accelerators); + +// Adds compilation options for a specific accelerator to the accelerator +// compilation option list. +// +// Note: Multiple accelerator options may be added to the options object. +// +// Note: `accelerator_compilation_options`'s ownership is transferred to +// `options`. +LiteRtStatus LiteRtAddOpaqueOptions(LiteRtOptions options, + LiteRtOpaqueOptions opaque_options); + +// Retrieves the head of the accelerator compilation option list. +// +// Note: The following elements may be retrieved with +// `LiteRtGetNextAcceleratorCompilationOptions`. +LiteRtStatus LiteRtGetOpaqueOptions(LiteRtOptions options, + LiteRtOpaqueOptions* opaque_options); + +// Adds a custom op kernel to the given options. +LiteRtStatus LiteRtAddCustomOpKernelOption( + LiteRtOptions options, const char* custom_op_name, int custom_op_version, + const LiteRtCustomOpKernel* custom_op_kernel, + void* custom_op_kernel_user_data); + +// Adds an external tensor binding to the given options. +// +// Note: `data` is owned by the caller and must outlive the lifetime of the +// CompiledModel. +// `size_bytes` must match the tensor's expected size. +LiteRtStatus LiteRtAddExternalTensorBinding(LiteRtOptions options, + const char* signature_name, + const char* tensor_name, void* data, + int size_bytes); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_OPTIONS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_platform_support.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_platform_support.h new file mode 100644 index 0000000000000000000000000000000000000000..ea8581e01c566e0838241cc74128e9c0f0551999 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_platform_support.h @@ -0,0 +1,92 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_PLATFORM_SUPPORT_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_PLATFORM_SUPPORT_H_ + +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +inline bool LiteRtHasOpenClSupport() { +#if LITERT_HAS_OPENCL_SUPPORT + return true; +#else + return false; +#endif +} + +inline bool LiteRtHasOpenGlSupport() { +#if LITERT_HAS_OPENGL_SUPPORT + return true; +#else + return false; +#endif +} + +inline bool LiteRtHasAhwbSupport() { +#if LITERT_HAS_AHWB_SUPPORT + return true; +#else + return false; +#endif +} + +inline bool LiteRtHasIonSupport() { +#if LITERT_HAS_ION_SUPPORT + return true; +#else + return false; +#endif +} + +inline bool LiteRtHasDmaBufSupport() { +#if LITERT_HAS_DMABUF_SUPPORT + return true; +#else + return false; +#endif +} + +inline bool LiteRtHasFastRpcSupport() { +#if LITERT_HAS_FASTRPC_SUPPORT + return true; +#else + return false; +#endif +} + +inline bool LiteRtHasSyncFenceSupport() { +#if LITERT_HAS_SYNC_FENCE_SUPPORT + return true; +#else + return false; +#endif +} + +inline bool LiteRtHasMetalSupport() { +#if LITERT_HAS_METAL_SUPPORT + return true; +#else + return false; +#endif +} + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_PLATFORM_SUPPORT_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_profiler.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_profiler.h new file mode 100644 index 0000000000000000000000000000000000000000..f391b2e1136230c25b30c947c188c689a0fa2d22 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_profiler.h @@ -0,0 +1,64 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_PROFILER_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_PROFILER_H_ + +#include "litert/c/litert_common.h" +#include "litert/c/litert_profiler_event.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Creates a compilation option object. +LiteRtStatus LiteRtCreateProfiler(int size, LiteRtProfiler* profiler); + +// Destroys a compilation option object. +void LiteRtDestroyProfiler(LiteRtProfiler profiler); + +// Starts profiling. +LiteRtStatus LiteRtStartProfiler(LiteRtProfiler profiler); + +// Stops profiling. +LiteRtStatus LiteRtStopProfiler(LiteRtProfiler profiler); + +// Resets the profiler. +LiteRtStatus LiteRtResetProfiler(LiteRtProfiler profiler); + +// Sets the current event source. +LiteRtStatus LiteRtSetProfilerCurrentEventSource( + LiteRtProfiler profiler, ProfiledEventSource event_source); + +// Gets the number of events. +LiteRtStatus LiteRtGetNumProfilerEvents(LiteRtProfiler profiler, + int* num_events); + +// Get events. The events are copied to the provided buffer, caller is +// responsible to allocate the buffer and provide the size of the buffer +// (num_events). +LiteRtStatus LiteRtGetProfilerEvents(LiteRtProfiler profiler, int num_events, + ProfiledEventData* events); + +// Gets the profile summary.The caller is responsible for freeing the memory of +// the `summary` string using C library `free()`. +LiteRtStatus LiteRtGetProfileSummary(LiteRtProfiler profiler, + LiteRtCompiledModel compiled_model, + const char** summary); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_PROFILER_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_profiler_event.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_profiler_event.h new file mode 100644 index 0000000000000000000000000000000000000000..7682a68fc433eb5636e6ec6c14ef09ac608c0631 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_profiler_event.h @@ -0,0 +1,91 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_PROFILER_EVENT_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_PROFILER_EVENT_H_ + +#include +#include + +// C-compatible version of 'tflite::Profiler::EventType' +typedef enum LiteRtProfilerEventType { + // Default event type, the metadata field has no special significance. + DEFAULT = 1, + + // The event is an operator invocation and the event_metadata field is the + // index of operator node. + OPERATOR_INVOKE_EVENT = 1 << 1, + + // The event is an invocation for an internal operator of a TFLite delegate. + // The event_metadata field is the index of operator node that's specific to + // the delegate. + DELEGATE_OPERATOR_INVOKE_EVENT = 1 << 2, + + // A delegate op invoke event that profiles a delegate op in the + // Operator-wise Profiling section and not in the Delegate internal section. + DELEGATE_PROFILED_OPERATOR_INVOKE_EVENT = 1 << 3, + + // The event is a recording of runtime instrumentation such as the overall + // TFLite runtime status, the TFLite delegate status (if a delegate + // is applied), and the overall model inference latency etc. + // Note, the delegate status and overall status are stored as separate + // event_metadata fields. In particular, the delegate status is encoded + // as DelegateStatus::full_status(). + GENERAL_RUNTIME_INSTRUMENTATION_EVENT = 1 << 4, + + // Telemetry events. Users and code instrumentations should invoke Telemetry + // calls instead of using the following types directly. + // See experimental/telemetry:profiler for definition of each metadata. + // + // A telemetry event that reports model and interpreter level events. + TELEMETRY_EVENT = 1 << 5, + // A telemetry event that reports model and interpreter level settings. + TELEMETRY_REPORT_SETTINGS = 1 << 6, + // A telemetry event that reports delegate level events. + TELEMETRY_DELEGATE_EVENT = 1 << 7, + // A telemetry event that reports delegate settings. + TELEMETRY_DELEGATE_REPORT_SETTINGS = 1 << 8, +} LiteRtProfilerEventType; + +// C-compatible version of 'tflite::profiling::memory::MemoryUsage' +// We define a C struct that matches the memory layout of the C++ one. +typedef struct LiteRtMemoryUsage { + size_t total_allocated_bytes; + size_t in_use_allocated_bytes; + size_t private_footprint_bytes; +} LiteRtMemoryUsage; + +// C-compatible version of 'Source' +typedef enum ProfiledEventSource { + LITERT, + TFLITE_INTERPRETER, + TFLITE_DELEGATE, +} ProfiledEventSource; + +// The C version of the struct uses only pure C types. +typedef struct ProfiledEventData { + const char* tag; // The tag of the event. The tag is copied and owned by the + // profiler, the caller does not need to keep the string + // alive. + LiteRtProfilerEventType event_type; + uint64_t start_timestamp_us; + uint64_t elapsed_time_us; + LiteRtMemoryUsage begin_mem_usage; + LiteRtMemoryUsage end_mem_usage; + uint64_t event_metadata1; + uint64_t event_metadata2; + ProfiledEventSource event_source; +} ProfiledEventData; + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_PROFILER_EVENT_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_profiler_types.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_profiler_types.h new file mode 100644 index 0000000000000000000000000000000000000000..a3e56fd02617b96dad84e6cc2f46aad1592f6bcd --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_profiler_types.h @@ -0,0 +1,43 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_PROFILER_TYPES_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_PROFILER_TYPES_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +typedef enum { + kLiteRtHookTypeRuntimeStart = 0, + kLiteRtHookTypeRuntimeStop = 1, + kLiteRtHookTypeCompilerStart = 2, + kLiteRtHookTypeCompilerStop = 3, + kLiteRtHookTypeStopAndProcess = 4, +} LiteRtHookType; + +// Callback signature for hooks. +// data: pointer to the trace or debug data buffer. +// size: size of the data buffer. +// user_data: user-provided context. +typedef void (*LiteRtHook)(LiteRtHookType type, const void* data, size_t size, + void* user_data); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_PROFILER_TYPES_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_tensor_buffer.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_tensor_buffer.h new file mode 100644 index 0000000000000000000000000000000000000000..0ea29ccb7b2ac3ae9d7af30c9784d1246884f72f --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_tensor_buffer.h @@ -0,0 +1,388 @@ +// Copyright 2024 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_TENSOR_BUFFER_H_ +#define ODML_LITERT_LITERT_C_LITERT_TENSOR_BUFFER_H_ + +#include + +#include "litert/c/litert_common.h" +#include "litert/c/litert_custom_tensor_buffer.h" +#include "litert/c/litert_gl_types.h" +#include "litert/c/litert_model_types.h" +#include "litert/c/litert_opencl_types.h" +#include "litert/c/litert_tensor_buffer_types.h" +#include "litert/c/litert_webgpu_types.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// ///////////////////////////////////////////////////////////////////////////// +// TensorBuffers. +// ///////////////////////////////////////////////////////////////////////////// + +// Create a tensor buffer from an existing host memory buffer of a given size, +// with optional host memory buffer deallocator (it can be NULL). Return an +// error if the passed host memory buffer doesn't satisfy +// LITERT_HOST_MEMORY_BUFFER_ALIGNMENT alignment. +// +// When interfacing with hardware accelerators that require custom alignment, +// check the buffer requirements dynamically using +// LiteRtGetTensorBufferRequirementsAlignment(). +// +// Caller owns the returned LiteRtTensorBuffer. The owner is responsible for +// calling LiteRtDestroyTensorBuffer() to release the object. +// NULL deallocator means that the host buffer is not managed by the tensor +// buffer and therefore must be released separately by the caller. +LiteRtStatus LiteRtCreateTensorBufferFromHostMemory( + const LiteRtRankedTensorType* tensor_type, void* host_buffer_addr, + size_t host_buffer_size, LiteRtHostMemoryDeallocator deallocator, + LiteRtTensorBuffer* buffer); + +// Return an error if the backing buffer is not allocated on the host memory. +LiteRtStatus LiteRtGetTensorBufferHostMemory(LiteRtTensorBuffer tensor_buffer, + void** host_memory_addr); + +// Create a tensor buffer from an existing AHardwareBuffer, with optional +// AHardwareBuffer deallocator (it can be NULL). An non-zero `buffer_offset` can +// be used to specify multiple tensor buffers sharing the same underlying AHWB, +// in which case the provided AHWB must be sufficiently large to accomodate for +// the allocation needed for all tensor buffers sharing it. +// +// Caller owns the returned LiteRtTensorBuffer. The owner is responsible for +// calling LiteRtDestroyTensorBuffer() to release the object. +// NULL deallocator means that the AHardwareBuffer is not managed by the tensor +// buffer and therefore must be released separately by the caller. +// +// @warning kLiteRtStatusErrorUnsupported is returned if AHWB is not supported. +LiteRtStatus LiteRtCreateTensorBufferFromAhwb( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + AHardwareBuffer* ahwb, size_t ahwb_offset, + LiteRtAhwbDeallocator deallocator, LiteRtTensorBuffer* buffer); + +// Return an error if the backing buffer is not an AhardwareBuffer. +// +// @warning kLiteRtStatusErrorUnsupported is returned if AHWB is not supported. +LiteRtStatus LiteRtGetTensorBufferAhwb(LiteRtTensorBuffer tensor_buffer, + AHardwareBuffer** ahwb); + +// Create a tensor buffer from an existing ION buffer of a given size, with +// optional ION buffer deallocator (it can be NULL). An non-zero +// `ion_buffer_offset` can be used to specify multiple tensor buffers sharing +// the same underlying ION buffer, in which case parameter `ion_buffer_size` +// must be the entire size of the underlying ION memory buffer, including the +// allocation needed for all tensor buffers sharing it. +// +// Caller owns the returned LiteRtTensorBuffer. The owner is responsible for +// calling LiteRtDestroyTensorBuffer() to release the object. +// NULL deallocator means that the ION buffer is not managed by the tensor +// buffer and therefore must be released separately by the caller. +// +// @warning kLiteRtStatusErrorUnsupported is returned if ION is not supported. +LiteRtStatus LiteRtCreateTensorBufferFromIonBuffer( + const LiteRtRankedTensorType* tensor_type, void* ion_buffer_addr, + int ion_buffer_fd, size_t ion_buffer_size, size_t ion_buffer_offset, + LiteRtIonDeallocator deallocator, LiteRtTensorBuffer* buffer); + +// Return an error if the backing buffer is not an ION buffer. +// +// @warning kLiteRtStatusErrorUnsupported is returned if ION is not supported. +LiteRtStatus LiteRtGetTensorBufferIonBuffer(LiteRtTensorBuffer buffer, + void** ion_buffer_addr, + int* ion_buffer_fd); + +// Create a tensor buffer from an existing DMA-BUF buffer of a given size, with +// optional DMA-BUF buffer deallocator (it can be NULL). An non-zero +// `dmabuf_buffer_offset` can be used to specify multiple tensor buffers sharing +// the same underlying ION buffer, in which case parameter `ion_buffer_size` +// must be the entire size of the underlying ION memory buffer, including the +// allocation needed for all tensor buffers sharing it. +// +// Caller owns the returned LiteRtTensorBuffer. The owner is responsible for +// calling LiteRtDestroyTensorBuffer() to release the object. +// NULL deallocator means that the DMA-BUF buffer is not managed by the tensor +// buffer and therefore must be released separately by the caller. +// +// @warning kLiteRtStatusErrorUnsupported is returned if DMABUF is not +// supported. +LiteRtStatus LiteRtCreateTensorBufferFromDmaBufBuffer( + const LiteRtRankedTensorType* tensor_type, void* dmabuf_buffer_addr, + int dmabuf_buffer_fd, size_t dmabuf_buffer_size, + size_t dmabuf_buffer_offset, LiteRtDmaBufDeallocator deallocator, + LiteRtTensorBuffer* buffer); + +// Return an error if the backing buffer is not an DMA-BUF buffer. +// +// @warning kLiteRtStatusErrorUnsupported is returned if DMABUF is not +// supported. +LiteRtStatus LiteRtGetTensorBufferDmaBufBuffer(LiteRtTensorBuffer tensor_buffer, + void** dmabuf_buffer_addr, + int* dmabuf_buffer_fd); + +// Create a tensor buffer from an existing FastRPC memory buffer of a given +// size, with optional FastRPC memory buffer deallocator (it can be NULL). An +// non-zero `fastrpc_buffer_offset` can be used to specify multiple tensor +// buffers sharing the same underlying FastRPC memory buffer, in which case +// parameter `fastrpc_buffer_size` must be the entire size of the underlying +// FastRPC memory buffer, including the allocation needed for all tensor buffers +// sharing it. +// +// Caller owns the returned LiteRtTensorBuffer. The owner is responsible for +// calling LiteRtDestroyTensorBuffer() to release the object. +// NULL deallocator means that the FastRPC buffer is not managed by the tensor +// buffer and therefore must be released separately by the caller. +// +// @warning kLiteRtStatusErrorUnsupported is returned if FASTRPC is not +// supported. +LiteRtStatus LiteRtCreateTensorBufferFromFastRpcBuffer( + const LiteRtRankedTensorType* tensor_type, void* fastrpc_buffer_addr, + int fastrpc_buffer_fd, size_t fastrpc_buffer_size, + size_t fastrpc_buffer_offset, LiteRtFastRpcDeallocator deallocator, + LiteRtTensorBuffer* tensor_buffer); + +// Return an error if the backing buffer is not a FastRPC memory buffer. +// +// @warning kLiteRtStatusErrorUnsupported is returned if FASTRPC is not +// supported. +LiteRtStatus LiteRtGetTensorBufferFastRpcBuffer( + LiteRtTensorBuffer tensor_buffer, void** fastrpc_buffer_addr, + int* fastrpc_buffer_fd); + +// Create a tensor buffer from an existing OpenCL memory of a given size, with +// optional opencl memory buffer deallocator (it can be NULL). +// +// Caller owns the returned LiteRtTensorBuffer. The owner is responsible for +// calling LiteRtDestroyTensorBuffer() to release the object. +// NULL deallocator means that the OpenCL buffer is not managed by the tensor +// buffer and therefore must be released separately by the caller. +// +// @warning kLiteRtStatusErrorUnsupported is returned if OPENCL is not +// supported. +LiteRtStatus LiteRtCreateTensorBufferFromOpenClMemory( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + LiteRtTensorBufferType buffer_type, LiteRtClMem cl_mem_addr, + size_t opencl_buffer_size, LiteRtOpenClDeallocator deallocator, + LiteRtTensorBuffer* buffer); + +// Return an error if the backing buffer is not a OpenCL memory. +// +// @warning kLiteRtStatusErrorUnsupported is returned if OPENCL is not +// supported. +LiteRtStatus LiteRtGetTensorBufferOpenClMemory(LiteRtTensorBuffer tensor_buffer, + LiteRtClMem* cl_mem_addr); + +// Return an error if the backing buffer is not a custom tensor buffer. +// +// Caller should know the type of `tensor_buffer` and how to interpret the +// custom buffer handle into an actual HW buffer type. +LiteRtStatus LiteRtGetTensorBufferCustomTensorBufferHandle( + LiteRtTensorBuffer tensor_buffer, HwMemoryHandle* hw_memory_handle); + +// Create a tensor buffer from an existing OpenGL Buffer. +// +// Caller owns the returned LiteRtTensorBuffer. The owner is responsible for +// calling LiteRtDestroyTensorBuffer() to release the object. +// NULL deallocator means that the OpenGL buffer is not managed by the tensor +// buffer and therefore must be released separately by the caller. +LiteRtStatus LiteRtCreateTensorBufferFromGlBuffer( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + LiteRtGLenum target, LiteRtGLuint id, size_t size_bytes, size_t offset, + LiteRtGlBufferDeallocator deallocator, LiteRtTensorBuffer* buffer); + +LiteRtStatus LiteRtGetTensorBufferGlBuffer(LiteRtTensorBuffer tensor_buffer, + LiteRtGLenum* target, + LiteRtGLuint* id, size_t* size_bytes, + size_t* offset); + +// Create a tensor buffer from an existing OpenGL Texture. +// +// Caller owns the returned LiteRtTensorBuffer. The owner is responsible for +// calling LiteRtDestroyTensorBuffer() to release the object. +// NULL deallocator means that the GL texture is not managed by the tensor +// buffer and therefore must be released separately by the caller. +LiteRtStatus LiteRtCreateTensorBufferFromGlTexture( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + LiteRtGLenum target, LiteRtGLuint id, LiteRtGLenum format, + size_t size_bytes, LiteRtGLint layer, + LiteRtGlTextureDeallocator deallocator, LiteRtTensorBuffer* buffer); + +LiteRtStatus LiteRtGetTensorBufferGlTexture( + LiteRtTensorBuffer tensor_buffer, LiteRtGLenum* target, LiteRtGLuint* id, + LiteRtGLenum* format, size_t* size_bytes, LiteRtGLint* layer); + +// Create a tensor buffer from an existing WebGPU memory of a given size, with +// optional WebGPU memory buffer deallocator (it can be NULL). +// +// Caller owns the returned LiteRtTensorBuffer. The owner is responsible for +// releasing the object. NULL deallocator means that the Metal buffer is not +// managed by the tensor buffer and therefore must be released separately by the +// caller. +// +// @warning kLiteRtStatusErrorUnsupported is returned if WEBGPU is not +// supported. +LiteRtStatus LiteRtCreateTensorBufferFromWebGpuBuffer( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + LiteRtTensorBufferType buffer_type, LiteRtWGPUBuffer wgpu_buffer, + size_t wgpu_buffer_size, LiteRtWebGpuBufferDeallocator deallocator, + LiteRtTensorBuffer* tensor_buffer); + +// Create a tensor buffer from an existing WebGPU texture of a given size, with +// optional webgpu texture deallocator (it can be NULL). +// +// Caller owns the returned LiteRtTensorBuffer. The owner is responsible for +// releasing the object. NULL deallocator means that the WebGPU texture is not +// managed by the tensor buffer and therefore must be released separately by the +// caller. +// +// @warning kLiteRtStatusErrorUnsupported is returned if WEBGPU is not +// supported. +LiteRtStatus LiteRtCreateTensorBufferFromWebGpuTexture( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + void* webgpu_texture, size_t webgpu_texture_size, + LiteRtWebGpuTextureDeallocator deallocator, + LiteRtTensorBuffer* tensor_buffer); + +// Return an error if the backing buffer is not a WebGpu buffer. +// +// @warning kLiteRtStatusErrorUnsupported is returned if WEBGPU is not +// supported. +LiteRtStatus LiteRtGetTensorBufferWebGpuBuffer( + LiteRtTensorBuffer tensor_buffer, HwMemoryHandle* hw_memory_handle); + +// Create a tensor buffer from an existing Metal memory of a given size, with +// optional metal memory buffer deallocator (it can be NULL). +// +// Caller owns the returned LiteRtTensorBuffer. The owner is responsible for +// releasing the object. NULL deallocator means that the Metal buffer is not +// managed by the tensor buffer and therefore must be released separately by the +// caller. +// +// @warning kLiteRtStatusErrorUnsupported is returned if METAL is not supported. +LiteRtStatus LiteRtCreateTensorBufferFromMetalMemory( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + LiteRtTensorBufferType buffer_type, void* metal_buffer, + size_t metal_buffer_size, LiteRtMetalDeallocator deallocator, + LiteRtTensorBuffer* tensor_buffer); + +// Return an error if the backing buffer is not a Metal memory. +// +// @warning kLiteRtStatusErrorUnsupported is returned if METAL is not supported. +LiteRtStatus LiteRtGetTensorBufferMetalMemory(LiteRtTensorBuffer tensor_buffer, + HwMemoryHandle* hw_memory_handle); + +// Return an error if the backing buffer is not a Vulkan device memory. +// +// @warning kLiteRtStatusErrorUnsupported is returned if VULKAN is not +// supported. +LiteRtStatus LiteRtGetTensorBufferVulkanMemory( + LiteRtTensorBuffer tensor_buffer, HwMemoryHandle* hw_memory_handle); + +// Create a managed TensorBuffer for a given size and type. +// +// Caller owns the returned LiteRtTensorBuffer. The owner is responsible for +// calling LiteRtDestroyTensorBuffer() to release the object. +LiteRtStatus LiteRtCreateManagedTensorBuffer( + LiteRtEnvironment env, LiteRtTensorBufferType buffer_type, + const LiteRtRankedTensorType* tensor_type, size_t buffer_size, + LiteRtTensorBuffer* buffer); + +// Create a managed TensorBuffer from buffer requirements. +// This function will use the alignment specified in the requirements. +// +// Caller owns the returned LiteRtTensorBuffer. The owner is responsible for +// calling LiteRtDestroyTensorBuffer() to release the object. +LiteRtStatus LiteRtCreateManagedTensorBufferFromRequirements( + LiteRtEnvironment env, const LiteRtRankedTensorType* tensor_type, + LiteRtTensorBufferRequirements requirements, LiteRtTensorBuffer* buffer); + +// Create a duplicate of the current tensor buffer. It will increase the +// reference count of a managed tensor buffer. And the number decreases when +// LiteRtDestroyTensorBuffer() is called. +LiteRtStatus LiteRtDuplicateTensorBuffer(LiteRtTensorBuffer tensor_buffer); + +LiteRtStatus LiteRtGetTensorBufferType(LiteRtTensorBuffer tensor_buffer, + LiteRtTensorBufferType* buffer_type); + +LiteRtStatus LiteRtGetTensorBufferTensorType( + LiteRtTensorBuffer tensor_buffer, LiteRtRankedTensorType* tensor_type); + +// Returns the size of the underlying H/W tensor buffer. This size can be +// different to the PackedSize() if there is stride and padding exists. +LiteRtStatus LiteRtGetTensorBufferSize(LiteRtTensorBuffer tensor_buffer, + size_t* size); + +// Returns the size of the tensor buffer in packed bytes. This size is used to +// read / write data on locked tensor buffer. +LiteRtStatus LiteRtGetTensorBufferPackedSize(LiteRtTensorBuffer tensor_buffer, + size_t* size); + +LiteRtStatus LiteRtGetTensorBufferOffset(LiteRtTensorBuffer tensor_buffer, + size_t* offset); + +LiteRtStatus LiteRtHasTensorBufferEvent(LiteRtTensorBuffer tensor_buffer, + bool* has_event); + +// Return an event attached a given tensor buffer, or NULL if no such event +// exists. The tensor buffer retains ownership of the returned event. +LiteRtStatus LiteRtGetTensorBufferEvent(LiteRtTensorBuffer tensor_buffer, + LiteRtEvent* event); + +// Attach a given event to a given tensor buffer. The tensor buffer takes +// ownership of the event. +LiteRtStatus LiteRtSetTensorBufferEvent(LiteRtTensorBuffer tensor_buffer, + LiteRtEvent event); + +// Remove any event that may have been previously attached to the given tensor +// buffer and deallocate such event. +LiteRtStatus LiteRtClearTensorBufferEvent(LiteRtTensorBuffer tensor_buffer); + +// Lock a tensor buffer and map it to host memory, potentially synchronizing on +// an event that was previously attached to the tensor buffer with +// `LiteRtSetTensorBufferEvent`. +// +// NOTE: If the underlying H/W buffer has a stride the data will be converted to +// the packed buffer. +// TODO b/413449050 - Update behavior to return raw H/W buffer as it is. +LiteRtStatus LiteRtLockTensorBuffer(LiteRtTensorBuffer tensor_buffer, + void** host_mem_addr, + LiteRtTensorBufferLockMode lock_mode); + +// Unlock a tensor buffer and (potentially) unmap it from host memory. +// +// NOTE: If the underlying H/W buffer has a stride the data will be converted to +// the strided buffer. +// TODO b/413449050 - Update behavior to upload contents without conversion. +LiteRtStatus LiteRtUnlockTensorBuffer(LiteRtTensorBuffer buffer); + +// Clear a tensor buffer possibly asynchronously. +// +// It may return immediately after scheduling a clear operation though it +// guarantees that Read() will return data cleared, i.e. all zeros. +// It may return kLiteRtStatusErrorUnsupported if the underlying buffer type +// does not support efficient clearing. In that case, the client should be able +// to clear the buffer by writing all zeros with Write() which clears the buffer +// synchronously. +LiteRtStatus LiteRtClearTensorBuffer(LiteRtTensorBuffer buffer); + +// Destroy an owned tensor buffer. If the tensor buffer is managed, the number +// of references to it is decreased and released the underlying TensorBufferT +// when the last reference is removed. +void LiteRtDestroyTensorBuffer(LiteRtTensorBuffer buffer); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_TENSOR_BUFFER_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_tensor_buffer_requirements.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_tensor_buffer_requirements.h new file mode 100644 index 0000000000000000000000000000000000000000..9cdae4d6cdad3823feed3736aa86e539782c1c5f --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_tensor_buffer_requirements.h @@ -0,0 +1,87 @@ +// Copyright 2024 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_TENSOR_BUFFER_REQUIREMENTS_H_ +#define ODML_LITERT_LITERT_C_LITERT_TENSOR_BUFFER_REQUIREMENTS_H_ + +#include +#include + +#include "litert/c/litert_common.h" +#include "litert/c/litert_tensor_buffer_types.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Create a LiteRtTensorBufferRequirements from a list of supported tensor +// buffer types, buffer size, strides, and alignment. +// +// Caller owns the returned LiteRtTensorBufferRequirements. The owner is +// responsible for calling LiteRtDestroyTensorBufferRequirements() to release +// the object. +LiteRtStatus LiteRtCreateTensorBufferRequirements( + int num_supported_tensor_buffer_types, + const LiteRtTensorBufferType* supported_tensor_buffer_types, + size_t buffer_size, int num_strides, const uint32_t* strides, + LiteRtTensorBufferRequirements* requirements); + +// Create a LiteRtTensorBufferRequirements from a list of supported tensor +// buffer types, buffer size, strides, and alignment. +// +// Caller owns the returned LiteRtTensorBufferRequirements. The owner is +// responsible for calling LiteRtDestroyTensorBufferRequirements() to release +// the object. +LiteRtStatus LiteRtCreateTensorBufferRequirementsWithAlignment( + int num_supported_tensor_buffer_types, + const LiteRtTensorBufferType* supported_tensor_buffer_types, + size_t buffer_size, int num_strides, const uint32_t* strides, + size_t alignment, LiteRtTensorBufferRequirements* requirements); + +LiteRtStatus LiteRtGetNumTensorBufferRequirementsSupportedBufferTypes( + LiteRtTensorBufferRequirements requirements, int* num_types); + +LiteRtStatus LiteRtGetTensorBufferRequirementsSupportedTensorBufferType( + LiteRtTensorBufferRequirements requirements, int type_index, + LiteRtTensorBufferType* type); + +LiteRtStatus LiteRtGetTensorBufferRequirementsBufferSize( + LiteRtTensorBufferRequirements requirements, size_t* buffer_size); + +// Returns the strides of the tensor buffer requirements. +// If the strides are not specified, num_strides is 0 and strides is nullptr is +// returned. +LiteRtStatus LiteRtGetTensorBufferRequirementsStrides( + LiteRtTensorBufferRequirements requirements, int* num_strides, + const uint32_t** strides); + +LiteRtStatus LiteRtGetTensorBufferRequirementsAlignment( + LiteRtTensorBufferRequirements requirements, size_t* alignment); + +// Join requirements from two sources and return an error if the join returns an +// empty set of requirements. +LiteRtStatus LiteRtJoinTensorBufferRequirements( + LiteRtTensorBufferRequirements src_requirements_1, + LiteRtTensorBufferRequirements src_requirements_2, + LiteRtTensorBufferRequirements* joined_requirements); + +// Destroy an owned LiteRtTensorBufferRequirements object. +void LiteRtDestroyTensorBufferRequirements( + LiteRtTensorBufferRequirements requirements); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_TENSOR_BUFFER_REQUIREMENTS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_tensor_buffer_types.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_tensor_buffer_types.h new file mode 100644 index 0000000000000000000000000000000000000000..abcadf2fe7a15f05ee476dd815d3cc8c645eebb9 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_tensor_buffer_types.h @@ -0,0 +1,208 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_LITERT_TENSOR_BUFFER_TYPES_H_ +#define ODML_LITERT_LITERT_C_LITERT_TENSOR_BUFFER_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +typedef struct AHardwareBuffer AHardwareBuffer; + +// The required byte alignment for host memory tensor buffers on CPU. +// +// This is an immutable ABI constant guaranteed across all LiteRT versions and +// runtime environments (including LiteRT in Google Play services). Callers +// using host memory for CPU inference must ensure their buffers are aligned to +// at least this boundary. Changing this value is a breaking ABI change that +// requires increasing the LiteRT major version. +// +// Hardware accelerators or custom delegates with different alignment +// requirements specify them dynamically via LiteRtTensorBufferRequirements. +// LINT.IfChange(host_memory_buffer_alignment) +#define LITERT_HOST_MEMORY_BUFFER_ALIGNMENT 64 +// LINT.ThenChange(internal/litert_runtime_c_api.h:version_number) + +typedef void (*LiteRtHostMemoryDeallocator)(void* addr); +typedef void (*LiteRtAhwbDeallocator)(AHardwareBuffer* ahwb); +typedef void (*LiteRtIonDeallocator)(void* ion_buffer_addr); +typedef void (*LiteRtDmaBufDeallocator)(void* dmabuf_buffer_addr); +typedef void (*LiteRtFastRpcDeallocator)(void* fastrpc_buffer_addr); +typedef void (*LiteRtOpenClDeallocator)(void* opencl_buffer_addr); +typedef void (*LiteRtGlBufferDeallocator)(void* gl_buffer_addr); +typedef void (*LiteRtGlTextureDeallocator)(void* gl_texture_addr); +typedef void (*LiteRtWebGpuBufferDeallocator)(void* webgpu_buffer_addr); +typedef void (*LiteRtWebGpuTextureDeallocator)(void* webgpu_texture_addr); +typedef void (*LiteRtMetalDeallocator)(void* metal_buffer_addr); +typedef void (*LiteRtVulkanMemoryDeallocator)(void* vulkan_memory_addr); + +// LINT.IfChange(tensor_buffer_types) +typedef enum { + kLiteRtTensorBufferTypeUnknown = 0, + kLiteRtTensorBufferTypeHostMemory = 1, + kLiteRtTensorBufferTypeAhwb = 2, + kLiteRtTensorBufferTypeIon = 3, + kLiteRtTensorBufferTypeDmaBuf = 4, + kLiteRtTensorBufferTypeFastRpc = 5, + kLiteRtTensorBufferTypeGlBuffer = 6, + kLiteRtTensorBufferTypeGlTexture = 7, + + // 10-19 are reserved for OpenCL memory objects. + // TODO b/421905729 - May consider reorganize the enum values with the next + // LiteRT release. + kLiteRtTensorBufferTypeOpenClBuffer = 10, + kLiteRtTensorBufferTypeOpenClBufferFp16 = 11, + kLiteRtTensorBufferTypeOpenClTexture = 12, + kLiteRtTensorBufferTypeOpenClTextureFp16 = 13, + kLiteRtTensorBufferTypeOpenClBufferPacked = 14, + kLiteRtTensorBufferTypeOpenClImageBuffer = 15, + kLiteRtTensorBufferTypeOpenClImageBufferFp16 = 16, + + // 20-29 are reserved for WebGPU memory objects. + kLiteRtTensorBufferTypeWebGpuBuffer = 20, + kLiteRtTensorBufferTypeWebGpuBufferFp16 = 21, + kLiteRtTensorBufferTypeWebGpuTexture = 22, + kLiteRtTensorBufferTypeWebGpuTextureFp16 = 23, + kLiteRtTensorBufferTypeWebGpuImageBuffer = 24, + kLiteRtTensorBufferTypeWebGpuImageBufferFp16 = 25, + kLiteRtTensorBufferTypeWebGpuBufferPacked = 26, + + // 30-39 are reserved for Metal memory objects. + kLiteRtTensorBufferTypeMetalBuffer = 30, + kLiteRtTensorBufferTypeMetalBufferFp16 = 31, + kLiteRtTensorBufferTypeMetalTexture = 32, + kLiteRtTensorBufferTypeMetalTextureFp16 = 33, + kLiteRtTensorBufferTypeMetalBufferPacked = 34, + + // 40-49 are reserved for Vulkan memory objects. + // WARNING: Vulkan support is experimental. + kLiteRtTensorBufferTypeVulkanBuffer = 40, + kLiteRtTensorBufferTypeVulkanBufferFp16 = 41, + kLiteRtTensorBufferTypeVulkanTexture = 42, + kLiteRtTensorBufferTypeVulkanTextureFp16 = 43, + kLiteRtTensorBufferTypeVulkanImageBuffer = 44, + kLiteRtTensorBufferTypeVulkanImageBufferFp16 = 45, + kLiteRtTensorBufferTypeVulkanBufferPacked = 46, + + // 100 - 199 are reserved for users custom memory objects. + // They should provide CPU access via lock() and unlock(). + kLiteRtTensorBufferTypeUserCustomBuffer = 100, + kLiteRtTensorBufferTypeOpenVINOTensorBuffer = 100, + kLiteRtTensorBufferTypeUserCustomBufferEnd = 199, +} LiteRtTensorBufferType; +// LINT.ThenChange( +// ../kotlin/src/main/kotlin/com/google/ai/edge/litert/TensorBuffer.kt:tensor_buffer_types, +// ../objc/apis/LRTTensorBuffer.h:tensor_buffer_types +// ) + +inline bool IsUserCustomBuffer(LiteRtTensorBufferType buffer_type) { + return buffer_type >= kLiteRtTensorBufferTypeUserCustomBuffer && + buffer_type <= kLiteRtTensorBufferTypeUserCustomBufferEnd; +} + +inline bool IsOpenClMemory(LiteRtTensorBufferType buffer_type) { + return buffer_type == kLiteRtTensorBufferTypeOpenClBuffer || + buffer_type == kLiteRtTensorBufferTypeOpenClBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeOpenClTexture || + buffer_type == kLiteRtTensorBufferTypeOpenClTextureFp16 || + buffer_type == kLiteRtTensorBufferTypeOpenClBufferPacked || + buffer_type == kLiteRtTensorBufferTypeOpenClImageBuffer || + buffer_type == kLiteRtTensorBufferTypeOpenClImageBufferFp16; +} + +inline bool IsWebGpuMemory(LiteRtTensorBufferType buffer_type) { + return buffer_type == kLiteRtTensorBufferTypeWebGpuBuffer || + buffer_type == kLiteRtTensorBufferTypeWebGpuBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeWebGpuTexture || + buffer_type == kLiteRtTensorBufferTypeWebGpuTextureFp16 || + buffer_type == kLiteRtTensorBufferTypeWebGpuImageBuffer || + buffer_type == kLiteRtTensorBufferTypeWebGpuImageBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeWebGpuBufferPacked; +} + +inline bool IsMetalMemory(LiteRtTensorBufferType buffer_type) { + return buffer_type == kLiteRtTensorBufferTypeMetalBuffer || + buffer_type == kLiteRtTensorBufferTypeMetalBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeMetalTexture || + buffer_type == kLiteRtTensorBufferTypeMetalTextureFp16 || + buffer_type == kLiteRtTensorBufferTypeMetalBufferPacked; +} + +inline bool IsVulkanMemory(LiteRtTensorBufferType buffer_type) { + return buffer_type == kLiteRtTensorBufferTypeVulkanBuffer || + buffer_type == kLiteRtTensorBufferTypeVulkanBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeVulkanTexture || + buffer_type == kLiteRtTensorBufferTypeVulkanTextureFp16 || + buffer_type == kLiteRtTensorBufferTypeVulkanImageBuffer || + buffer_type == kLiteRtTensorBufferTypeVulkanImageBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeVulkanBufferPacked; +} + +inline bool IsGpuBuffer(LiteRtTensorBufferType buffer_type) { + return buffer_type == kLiteRtTensorBufferTypeGlBuffer || + buffer_type == kLiteRtTensorBufferTypeOpenClBuffer || + buffer_type == kLiteRtTensorBufferTypeOpenClBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeOpenClBufferPacked || + buffer_type == kLiteRtTensorBufferTypeWebGpuBuffer || + buffer_type == kLiteRtTensorBufferTypeWebGpuBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeWebGpuBufferPacked || + buffer_type == kLiteRtTensorBufferTypeMetalBuffer || + buffer_type == kLiteRtTensorBufferTypeMetalBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeMetalBufferPacked || + buffer_type == kLiteRtTensorBufferTypeVulkanBuffer || + buffer_type == kLiteRtTensorBufferTypeVulkanBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeVulkanBufferPacked; +} + +inline bool IsGpuTexture(LiteRtTensorBufferType buffer_type) { + return buffer_type == kLiteRtTensorBufferTypeGlTexture || + buffer_type == kLiteRtTensorBufferTypeOpenClTexture || + buffer_type == kLiteRtTensorBufferTypeOpenClTextureFp16 || + buffer_type == kLiteRtTensorBufferTypeWebGpuTexture || + buffer_type == kLiteRtTensorBufferTypeWebGpuTextureFp16 || + buffer_type == kLiteRtTensorBufferTypeMetalTexture || + buffer_type == kLiteRtTensorBufferTypeMetalTextureFp16 || + buffer_type == kLiteRtTensorBufferTypeVulkanTexture || + buffer_type == kLiteRtTensorBufferTypeVulkanTextureFp16; +} + +inline bool IsGpuImageBuffer(LiteRtTensorBufferType buffer_type) { + return buffer_type == kLiteRtTensorBufferTypeOpenClImageBuffer || + buffer_type == kLiteRtTensorBufferTypeOpenClImageBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeWebGpuImageBuffer || + buffer_type == kLiteRtTensorBufferTypeWebGpuImageBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeVulkanImageBuffer || + buffer_type == kLiteRtTensorBufferTypeVulkanImageBufferFp16; +} + +inline bool IsGpuFloat16Memory(LiteRtTensorBufferType buffer_type) { + return buffer_type == kLiteRtTensorBufferTypeOpenClBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeOpenClTextureFp16 || + buffer_type == kLiteRtTensorBufferTypeOpenClImageBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeWebGpuBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeWebGpuTextureFp16 || + buffer_type == kLiteRtTensorBufferTypeWebGpuImageBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeMetalBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeMetalTextureFp16 || + buffer_type == kLiteRtTensorBufferTypeVulkanBufferFp16 || + buffer_type == kLiteRtTensorBufferTypeVulkanTextureFp16 || + buffer_type == kLiteRtTensorBufferTypeVulkanImageBufferFp16; +} + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_LITERT_TENSOR_BUFFER_TYPES_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_webgpu_types.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_webgpu_types.h new file mode 100644 index 0000000000000000000000000000000000000000..5e57ee046aa02660e172fd48126e016ec4228e1d --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/litert_webgpu_types.h @@ -0,0 +1,37 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_WEBGPU_TYPES_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_WEBGPU_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/** + * Define LiteRT alias for WebGPU type WGPUBuffer, + * but ensure that it is always defined, even if WebGPU isn't supported. + */ +#if LITERT_HAS_WEBGPU_SUPPORT +typedef struct WGPUBufferImpl LiteRtWGPUBufferImpl; +#else +typedef struct LiteRtWGPUBufferImpl LiteRtWGPUBufferImpl; +#endif // LITERT_HAS_WEBGPU_SUPPORT +typedef LiteRtWGPUBufferImpl* LiteRtWGPUBuffer; + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_LITERT_WEBGPU_TYPES_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_arm_options.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_arm_options.h new file mode 100644 index 0000000000000000000000000000000000000000..8a1373298a1bbc8e2baa8efe8096ff3b4993bc2d --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_arm_options.h @@ -0,0 +1,55 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-FileCopyrightText: Copyright 2026 Arm Limited and/or its affiliates +// SPDX-License-Identifier: Apache-2.0 +// + +#ifndef ODML_LITERT_LITERT_C_OPTIONS_LITERT_ARM_OPTIONS_H_ +#define ODML_LITERT_LITERT_C_OPTIONS_LITERT_ARM_OPTIONS_H_ + +#include + +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +LITERT_DEFINE_HANDLE(LrtArmOptions); + +LiteRtStatus LrtCreateArmOptions(LrtArmOptions* options); + +LiteRtStatus LrtCreateArmOptionsFromToml(const char* toml_payload, + LrtArmOptions* options); + +void LrtDestroyArmOptions(LrtArmOptions options); + +LiteRtStatus LrtGetOpaqueArmOptionsData(LrtArmOptions options, + const char** identifier, void** payload, + void (**payload_deleter)(void*)); + +const char* LrtArmOptionsGetIdentifier(); + +LiteRtStatus LrtArmOptionsSetEnableJustInTime(LrtArmOptions options, + bool enable_just_in_time); + +LiteRtStatus LrtArmOptionsGetEnableJustInTime(LrtArmOptions options, + bool* enable_just_in_time); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_OPTIONS_LITERT_ARM_OPTIONS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_compiler_options.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_compiler_options.h new file mode 100644 index 0000000000000000000000000000000000000000..e19da79b3538d8fd07a4b84b4ae5d55e446fb7d8 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_compiler_options.h @@ -0,0 +1,95 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_COMPILER_OPTIONS_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_COMPILER_OPTIONS_H_ + +#include + +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct LrtCompilerOptions LrtCompilerOptions; + +// Partition strategy for the compiler. +// +// Default: +// Default partition strategy is to partition the graph based on the naive +// cutting algorithm. +// +// Weakly connected (experimental feature): +// Partitions the graph into weakly connected components, this may result in +// incorrect partition where there exists a path from a selected to another, +// where there is an unselected node in between. This feature is currently in +// experimental stage. +typedef enum LiteRtCompilerOptionsPartitionStrategy { + kLiteRtCompilerOptionsPartitionStrategyDefault = 0, + kLiteRtCompilerOptionsPartitionStrategyWeaklyConnected = 1, +} LiteRtCompilerOptionsPartitionStrategy; + +// Creates a compiler options object. +// The caller is responsible for freeing the returned options using +// `LrtDestroyCompilerOptions`. +LiteRtStatus LrtCreateCompilerOptions(LrtCompilerOptions** options); + +// Destroys a compiler options object. +void LrtDestroyCompilerOptions(LrtCompilerOptions* options); + +// Serializes compiler options and returns the components needed to create +// opaque options. The caller is responsible for passing these to +// `LiteRtCreateOpaqueOptions`. +LiteRtStatus LrtGetOpaqueCompilerOptionsData(const LrtCompilerOptions* options, + const char** identifier, + void** payload, + void (**payload_deleter)(void*)); + +// Gets the identifier for Compiler options stored in opaque options. +const char* LrtGetCompilerOptionsIdentifier(); + +// Sets the partition strategy for the compiler. +LiteRtStatus LrtSetCompilerOptionsPartitionStrategy( + LrtCompilerOptions* options, + LiteRtCompilerOptionsPartitionStrategy partition_strategy); + +// Gets the partition strategy from compiler options. +// Returns kLiteRtStatusErrorNotFound if not set. +LiteRtStatus LrtGetCompilerOptionsPartitionStrategy( + const LrtCompilerOptions* options, + LiteRtCompilerOptionsPartitionStrategy* partition_strategy); + +// Sets the dummy option for testing. +LiteRtStatus LrtSetCompilerOptionsDummyOption(LrtCompilerOptions* options, + bool dummy_option); + +// Gets the dummy option from compiler options. +LiteRtStatus LrtGetCompilerOptionsDummyOption(const LrtCompilerOptions* options, + bool* dummy_option); + +// Sets the maximum number of partitions allowed. +// A value of 0 means unlimited. +LiteRtStatus LrtSetCompilerOptionsMaxPartitions( + LrtCompilerOptions* options, size_t max_partitions); + +// Gets the maximum number of partitions allowed. +LiteRtStatus LrtGetCompilerOptionsMaxPartitions( + const LrtCompilerOptions* options, size_t* max_partitions); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_COMPILER_OPTIONS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_cpu_options.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_cpu_options.h new file mode 100644 index 0000000000000000000000000000000000000000..fd69e259dc7ba6c3d767b83ecaa51d542d0e5f72 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_cpu_options.h @@ -0,0 +1,125 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_CPU_OPTIONS_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_CPU_OPTIONS_H_ + +#include + +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct LrtCpuOptions LrtCpuOptions; + +// Selects how CPU ops are executed. +typedef enum LiteRtCpuKernelMode { + // Use the CPU delegate pipeline. This is the default CPU mode. + // XNNPACK delegates CPU ops, and an enabled YNNPACK delegate runs first + // when it was compiled into the runtime. + kLiteRtCpuKernelModeDelegate = 0, + // Legacy source-compatible alias for the delegate mode. + kLiteRtCpuKernelModeXnnpack = kLiteRtCpuKernelModeDelegate, + // Use LiteRT's built-in reference kernels instead of CPU delegates. + kLiteRtCpuKernelModeReference = 1, + // Use LiteRT's built-in optimized kernels instead of CPU delegates. + kLiteRtCpuKernelModeBuiltin = 2, +} LiteRtCpuKernelMode; + +// Creates a cpu options object. +// The caller is responsible for freeing the returned options using +// `LrtDestroyCpuOptions`. +LiteRtStatus LrtCreateCpuOptions(LrtCpuOptions** options); + +// Destroys a cpu options object. +void LrtDestroyCpuOptions(LrtCpuOptions* options); + +// Serializes cpu options and returns the components needed to create opaque +// options. The caller is responsible for passing these to +// `LiteRtCreateOpaqueOptions`. +LiteRtStatus LrtGetOpaqueCpuOptionsData(const LrtCpuOptions* options, + const char** identifier, void** payload, + void (**payload_deleter)(void*)); + +// Gets the identifier for CPU options stored in opaque options. +const char* LrtGetCpuOptionsIdentifier(); + +// Sets how LiteRT should execute CPU ops. +LiteRtStatus LrtSetCpuOptionsKernelMode(LrtCpuOptions* options, + LiteRtCpuKernelMode mode); + +// Gets the CPU kernel mode that was set. +LiteRtStatus LrtGetCpuOptionsKernelMode(const LrtCpuOptions* options, + LiteRtCpuKernelMode* mode); + +// Enables YNNPACK to delegate supported CPU ops before XNNPACK. Requires a +// build with `--define litert_enable_ynnpack=true`; otherwise XNNPACK is used. +LiteRtStatus LrtSetCpuOptionsEnableYNNPack(LrtCpuOptions* options, + bool enable_ynnpack); + +// Gets whether YNNPACK delegation was enabled. +LiteRtStatus LrtGetCpuOptionsEnableYNNPack(const LrtCpuOptions* options, + bool* enable_ynnpack); + +// Sets the number of CPU threads used by the CPU accelerator. +LiteRtStatus LrtSetCpuOptionsNumThread(LrtCpuOptions* options, int num_threads); + +// Gets the number of CPU threads used by the CPU accelerator. +LiteRtStatus LrtGetCpuOptionsNumThread(const LrtCpuOptions* options, + int* num_threads); + +// Sets the XNNPack flags used by XNNPACK in delegate mode. +LiteRtStatus LrtSetCpuOptionsXNNPackFlags(LrtCpuOptions* options, + uint32_t flags); + +// Gets the XNNPack flags used by XNNPACK in delegate mode. +LiteRtStatus LrtGetCpuOptionsXNNPackFlags(const LrtCpuOptions* options, + uint32_t* flags); + +// Sets whether to hint at fully delegating to a single delegate. +LiteRtStatus LrtSetCpuOptionsHintFullyDelegatedToSingleDelegate( + LrtCpuOptions* options, bool hint_fully_delegated_to_single_delegate); + +// Sets the XNNPack weight cache file path used by XNNPACK in delegate +// mode. +// Weight cache file path and descriptor must not both be set. +// The `path` string is copied into the options object. +LiteRtStatus LrtSetCpuOptionsXnnPackWeightCachePath(LrtCpuOptions* options, + const char* path); + +// Gets the XNNPack weight cache file path used by XNNPACK in delegate +// mode. +// The returned string pointer is owned by the options object and is valid +// as long as the options object is valid and the path is not modified. +LiteRtStatus LrtGetCpuOptionsXnnPackWeightCachePath( + const LrtCpuOptions* options, const char** path); + +// Sets the XNNPack weight cache file descriptor used by XNNPACK in +// delegate mode. +// Weight cache file path and descriptor must not both be set. +LiteRtStatus LrtSetCpuOptionsXnnPackWeightCacheFileDescriptor( + LrtCpuOptions* options, int fd); + +// Gets the XNNPack weight cache file descriptor used by XNNPACK in +// delegate mode. +LiteRtStatus LrtGetCpuOptionsXnnPackWeightCacheFileDescriptor( + const LrtCpuOptions* options, int* fd); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_CPU_OPTIONS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_google_tensor_options.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_google_tensor_options.h new file mode 100644 index 0000000000000000000000000000000000000000..d2be77053b9dbe5163e9f2ef232c6b3f86a9537f --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_google_tensor_options.h @@ -0,0 +1,213 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_GOOGLE_TENSOR_OPTIONS_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_GOOGLE_TENSOR_OPTIONS_H_ + +#include "litert/c/litert_common.h" +#include "litert/c/options/litert_google_tensor_options_type.h" + +#ifdef __cplusplus +#include +#include + +extern "C" { +#endif // __cplusplus + +LITERT_DEFINE_HANDLE(LrtGoogleTensorOptions); + +LiteRtStatus LrtCreateGoogleTensorOptions(LrtGoogleTensorOptions* options); + +void LrtDestroyGoogleTensorOptions(LrtGoogleTensorOptions options); + +// The a string identifier that discriminates GoogleTensor options within +// type erased options. +const char* LrtGoogleTensorOptionsGetIdentifier(); + +LiteRtStatus LrtGetOpaqueGoogleTensorOptionsData( + LrtGoogleTensorOptions options, const char** identifier, void** payload, + void (**payload_deleter)(void*)); + +// Creates a google_tensor options object from a TOML payload. +LiteRtStatus LrtCreateGoogleTensorOptionsFromToml( + const char* toml_payload, LrtGoogleTensorOptions* options); + +// COMPILATION OPTIONS ///////////////////////////////////////////////////////// + +LiteRtStatus LrtGoogleTensorOptionsSetFloatTruncationType( + LrtGoogleTensorOptions options, + LrtGoogleTensorOptionsTruncationType truncation_type); + +LiteRtStatus LrtGoogleTensorOptionsGetFloatTruncationType( + LrtGoogleTensorOptions options, + LrtGoogleTensorOptionsTruncationType* truncation_type); + +// int64_to_int32_truncation --------------------------------------------------- + +LiteRtStatus LrtGoogleTensorOptionsSetInt64ToInt32Truncation( + LrtGoogleTensorOptions options, bool int64_to_int32_truncation); + +LiteRtStatus LrtGoogleTensorOptionsGetInt64ToInt32Truncation( + LrtGoogleTensorOptions options, bool* int64_to_int32_truncation); + +// output_dir ------------------------------------------------------------------ + +// Sets the output directory for the generated files. +// The `output_dir` string is copied and stored in the `options` object. +LiteRtStatus LrtGoogleTensorOptionsSetOutputDir(LrtGoogleTensorOptions options, + const char* output_dir); + +// Returns the output directory for the generated files. +// The `output_dir` string is owned by the `options` object. +LiteRtStatus LrtGoogleTensorOptionsGetOutputDir(LrtGoogleTensorOptions options, + const char** output_dir); + +// dump_op_timings ------------------------------------------------------------- + +LiteRtStatus LrtGoogleTensorOptionsSetDumpOpTimings( + LrtGoogleTensorOptions options, bool dump_op_timings); + +LiteRtStatus LrtGoogleTensorOptionsGetDumpOpTimings( + LrtGoogleTensorOptions options, bool* dump_op_timings); + +// enable_large_model_support -------------------------------------------------- + +LiteRtStatus LrtGoogleTensorOptionsSetEnableLargeModelSupport( + LrtGoogleTensorOptions options, bool enable_large_model_support); + +LiteRtStatus LrtGoogleTensorOptionsGetEnableLargeModelSupport( + LrtGoogleTensorOptions options, bool* enable_large_model_support); + +// enable_4bit_compilation ----------------------------------------------------- +LiteRtStatus LrtGoogleTensorOptionsSetEnable4BitCompilation( + LrtGoogleTensorOptions options, bool enable_4bit_compilation); + +LiteRtStatus LrtGoogleTensorOptionsGetEnable4BitCompilation( + LrtGoogleTensorOptions options, bool* enable_4bit_compilation); + +// sharding intensity --------------------------------------------------------- + +LiteRtStatus LrtGoogleTensorOptionsSetShardingIntensity( + LrtGoogleTensorOptions options, + LrtGoogleTensorOptionsShardingIntensity sharding_intensity); + +LiteRtStatus LrtGoogleTensorOptionsGetShardingIntensity( + LrtGoogleTensorOptions options, + LrtGoogleTensorOptionsShardingIntensity* sharding_intensity); + +// enable_dynamic_range_quantization ----------------------------------------- +LiteRtStatus LrtGoogleTensorOptionsSetEnableDynamicRangeQuantization( + LrtGoogleTensorOptions options, bool enable_dynamic_range_quantization); + +LiteRtStatus LrtGoogleTensorOptionsGetEnableDynamicRangeQuantization( + LrtGoogleTensorOptions options, bool* enable_dynamic_range_quantization); + +// performance mode ---------------------------------------------------- + +LiteRtStatus LrtGoogleTensorOptionsSetPerformanceMode( + LrtGoogleTensorOptions options, + LiteRtGoogleTensorOptionsPerformanceMode mode); + +LiteRtStatus LrtGoogleTensorOptionsGetPerformanceMode( + LrtGoogleTensorOptions options, + LiteRtGoogleTensorOptionsPerformanceMode* mode); + +// op_filters_proto -------------------------------------------------- + +LiteRtStatus LrtGoogleTensorOptionsSetOpFiltersProto( + LrtGoogleTensorOptions options, const char* op_filters_proto); + +LiteRtStatus LrtGoogleTensorOptionsGetOpFiltersProto( + LrtGoogleTensorOptions options, const char** op_filters_proto); + +// extra_options_path -------------------------------------------------- + +LiteRtStatus LrtGoogleTensorOptionsSetExtraOptionsPath( + LrtGoogleTensorOptions options, const char* extra_options_path); + +LiteRtStatus LrtGoogleTensorOptionsGetExtraOptionsPath( + LrtGoogleTensorOptions options, const char** extra_options_path); + +// input_coherency -------------------------------------------------- + +// Sets whether the specified input tensor should use coherent memory. +// The `signature_name` and `tensor_name` strings are copied and stored in the +// `options` object. +LiteRtStatus LrtGoogleTensorOptionsSetInputCoherency( + LrtGoogleTensorOptions options, const char* signature_name, + const char* tensor_name, bool prefer_coherent); + +// Gets whether the specified input tensor should use coherent memory. +LiteRtStatus LrtGoogleTensorOptionsGetInputCoherency( + LrtGoogleTensorOptions options, const char* signature_name, + const char* tensor_name, bool* prefer_coherent); + +// Gets the number of input coherency entries configured. +LiteRtStatus LrtGoogleTensorOptionsGetNumInputCoherencyEntries( + LrtGoogleTensorOptions options, int* num_entries); + +// Gets the input coherency entry at the specified index. +// The `signature_name` and `tensor_name` strings are owned by the `options` +// object. +LiteRtStatus LrtGoogleTensorOptionsGetInputCoherencyEntry( + LrtGoogleTensorOptions options, int entry_idx, const char** signature_name, + const char** tensor_name, bool* prefer_coherent); + +// output_coherency -------------------------------------------------- + +// Sets whether the specified output tensor should use coherent memory. +// The `signature_name` and `tensor_name` strings are copied and stored in the +// `options` object. +LiteRtStatus LrtGoogleTensorOptionsSetOutputCoherency( + LrtGoogleTensorOptions options, const char* signature_name, + const char* tensor_name, bool prefer_coherent); + +// Gets whether the specified output tensor should use coherent memory. +LiteRtStatus LrtGoogleTensorOptionsGetOutputCoherency( + LrtGoogleTensorOptions options, const char* signature_name, + const char* tensor_name, bool* prefer_coherent); + +// Gets the number of output coherency entries configured. +LiteRtStatus LrtGoogleTensorOptionsGetNumOutputCoherencyEntries( + LrtGoogleTensorOptions options, int* num_entries); + +// Gets the output coherency entry at the specified index. +// The `signature_name` and `tensor_name` strings are owned by the `options` +// object. +LiteRtStatus LrtGoogleTensorOptionsGetOutputCoherencyEntry( + LrtGoogleTensorOptions options, int entry_idx, const char** signature_name, + const char** tensor_name, bool* prefer_coherent); + +// extra_options -------------------------------------------------- + +LiteRtStatus LrtGoogleTensorOptionsSetExtraOptions( + LrtGoogleTensorOptions options, const char* extra_options); + +LiteRtStatus LrtGoogleTensorOptionsGetExtraOptions( + LrtGoogleTensorOptions options, const char** extra_options); + +// copybara:uncomment_begin(google-only) +// // experimental_enable_input_validator --------------------------------- +// +// LiteRtStatus LrtGoogleTensorOptionsSetExperimentalEnableInputValidator( +// LrtGoogleTensorOptions options, bool experimental_enable_input_validator); +// +// LiteRtStatus LrtGoogleTensorOptionsGetExperimentalEnableInputValidator( +// LrtGoogleTensorOptions options, bool* experimental_enable_input_validator); +// copybara:uncomment_end +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_GOOGLE_TENSOR_OPTIONS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_google_tensor_options_type.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_google_tensor_options_type.h new file mode 100644 index 0000000000000000000000000000000000000000..e76ab57dba1ecbb7b48dbf821be40b1c21a24b09 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_google_tensor_options_type.h @@ -0,0 +1,52 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_GOOGLE_TENSOR_OPTIONS_TYPE_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_GOOGLE_TENSOR_OPTIONS_TYPE_H_ + +// float_truncation_type ------------------------------------------------------- + +typedef enum LrtGoogleTensorOptionsTruncationType { + kLiteRtGoogleTensorFloatTruncationTypeAuto = 0, + kLiteRtGoogleTensorFloatTruncationTypeNoTruncation = 1, + kLiteRtGoogleTensorFloatTruncationTypeBfloat16 = 2, + kLiteRtGoogleTensorFloatTruncationTypeHalf = 3, +} LrtGoogleTensorOptionsTruncationType; + +typedef enum LrtGoogleTensorOptionsShardingIntensity { + kLiteRtGoogleTensorShardingIntensityUnspecified = -1, + kLiteRtGoogleTensorShardingIntensityMinimal = 0, + kLiteRtGoogleTensorShardingIntensityModerate = 1, + kLiteRtGoogleTensorShardingIntensityExtensive = 2, + kLiteRtGoogleTensorShardingIntensityMaximum = 3, +} LrtGoogleTensorOptionsShardingIntensity; + +// Enum for Google Tensor performance mode. +typedef enum LiteRtGoogleTensorOptionsPerformanceMode { + kLiteRtGoogleTensorOptionsPerformanceModeExtremePowerSaver = + 0, // Maximum power saving, lowest performance. + kLiteRtGoogleTensorOptionsPerformanceModePowerSaver = + 1, // Balanced for background tasks with power efficiency. + kLiteRtGoogleTensorOptionsPerformanceModeBalanced = + 2, // Default state providing a mix of speed and efficiency. + kLiteRtGoogleTensorOptionsPerformanceModeHighPerformance = + 3, // High clock speeds for low-latency interactive tasks. + kLiteRtGoogleTensorOptionsPerformanceModeSustainedPerformance = + 4, // Optimized for long-running heavy workloads to avoid thermal + // throttling. + kLiteRtGoogleTensorOptionsPerformanceModeBurst = + 5 // Absolute maximum performance for short durations. +} LiteRtGoogleTensorOptionsPerformanceMode; + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_GOOGLE_TENSOR_OPTIONS_TYPE_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_gpu_options.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_gpu_options.h new file mode 100644 index 0000000000000000000000000000000000000000..74c6fdff448f626ad6ca99988db5329e8f279a96 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_gpu_options.h @@ -0,0 +1,391 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_GPU_OPTIONS_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_GPU_OPTIONS_H_ + +#include + +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct LrtGpuOptions LrtGpuOptions; + +// Creates a GPU options object. +// The caller is responsible for freeing the returned options using +// `LrtDestroyGpuOptions`. +LiteRtStatus LrtCreateGpuOptions(LrtGpuOptions** options); + +// Creates a GPU options object from a TOML string. +// The caller is responsible for freeing the returned options using +// `LrtDestroyGpuOptions`. +LiteRtStatus LrtCreateGpuOptionsFromToml(const char* toml_string, + LrtGpuOptions** options); + +// Destroys a GPU options object. +void LrtDestroyGpuOptions(LrtGpuOptions* options); + +// Serializes GPU options and returns the components needed to create opaque +// options. The caller is responsible for passing these to +// `LiteRtCreateOpaqueOptions`. +LiteRtStatus LrtGetOpaqueGpuOptionsData(const LrtGpuOptions* options, + const char** identifier, void** payload, + void (**payload_deleter)(void*)); + +// Enables the GPU accelerator constant tensor sharing to enable sharing of +// constant tensors between different subgraphs. +LiteRtStatus LrtSetGpuOptionsConstantTensorsSharing(LrtGpuOptions* gpu_options, + bool enable); + +// Enables the GPU accelerator infinite float capping to enforce capping +// inf/-inf to max float values for the softmax input and padding +LiteRtStatus LrtSetGpuOptionsInfiniteFloatCapping(LrtGpuOptions* gpu_options, + bool enable); + +// Enables the GPU accelerator benchmark mode. This will disable some +// optimizations that are not needed for benchmarking. +LiteRtStatus LrtSetGpuOptionsBenchmarkMode(LrtGpuOptions* gpu_options, + bool enable); + +// Sets the GPU backend. +LiteRtStatus LrtSetGpuOptionsGpuBackend(LrtGpuOptions* gpu_options, + LiteRtGpuBackend backend); + +// Set to true to run in external tensors mode. This allows GPU +// Accelerator to always use external tensors (PHWC4 format) as inputs and +// outputs. This mode mostly gives a slightly lower performance but it reduces +// additional GPU-GPU copies for input and output tensors. +// +// WARNING: This is an experimental feature and subject to change. +LiteRtStatus LrtSetGpuOptionsExternalTensorsMode(LrtGpuOptions* gpu_options, + bool enable); + +// Add a prefix pattern to match external tensors. When ExternalTensorsMode is +// not used (default behavior), all input and output tensors requires PHWC4 +// layout conversion. This pattern is useful for state tensors to reduce the +// layout conversion. For example, if the prefix pattern is "kv_cache_", then +// all tensors whose names begin with "kv_cache_" will be exempted. +LiteRtStatus LrtAddGpuOptionsExternalTensorPattern(LrtGpuOptions* gpu_options, + const char* pattern); + +// Add a prefix pattern to match buffer storage tensors. When this pattern is +// matched, the tensor will use buffer storage type. +// +// WARNING: This is an experimental feature and subject to change. +LiteRtStatus LrtAddGpuOptionsBufferStorageTensorPattern( + LrtGpuOptions* gpu_options, const char* pattern); + +// Sets the GPU priority. Low priority helps to unblock UI workloads. +// +// WARNING: This is an experimental feature and subject to change. +LiteRtStatus LrtSetGpuOptionsGpuPriority(LrtGpuOptions* gpu_options, + LiteRtGpuPriority priority); + +// This enables dynamic range quantization of the input tensor for large sized +// fully connected and convolution operations, if the device supports it. This +// will result in accuracy loss, since the input tensor will be quantized to +// 8-bit. Turning this on will also increase the initialization time to +// calculate some extra constant tensor. `enable_constant_tensors_sharing` must +// be true to use this. +LiteRtStatus LrtSetGpuAcceleratorCompilationOptionsAllowSrcQuantizedFcConvOps( + LrtGpuOptions* gpu_options, bool enable); + +// If true, the delegate hints waiting for completion. This is for some +// backends, for example OpenCL on Mali, to wait for the enqueued commands to be +// completed after each invoke. +LiteRtStatus LrtSetGpuAcceleratorRuntimeOptionsHintWaitingForCompletion( + LrtGpuOptions* gpu_options, bool enable); + +// Sets the GPU kernel batch size for one flush. +LiteRtStatus LrtSetGpuAcceleratorRuntimeOptionsKernelBatchSize( + LrtGpuOptions* gpu_options, int kernel_batch_size); + +// Sets the GPU accelerator precision. e.g. FP16, FP32, etc. +LiteRtStatus LrtSetGpuAcceleratorCompilationOptionsPrecision( + LrtGpuOptions* gpu_options, LiteRtDelegatePrecision precision); + +// Sets the GPU buffer storage type. If true, the delegate will use buffer +// storage type. +LiteRtStatus LrtSetGpuAcceleratorCompilationOptionsUseBufferStorageType( + LrtGpuOptions* gpu_options, + LiteRtDelegateBufferStorageType buffer_storage_type); + +// If true, the delegate will prefer to use textures rather than buffers for +// weights. Use option when weights in texture has better performance. +LiteRtStatus LrtSetGpuAcceleratorCompilationOptionsPreferTextureWeights( + LrtGpuOptions* gpu_options, bool prefer_texture_weights); + +// The nul-terminated directory to use for serialization. +// Whether serialization actually happens or not is dependent on backend used +// and validity of this directory. +// Set to nullptr implies the delegate will not try serialization. +// +// NOTE: Users should ensure that this directory is private to the app to +// avoid data access issues. +// Delegate stores the pointer to the string and doesn't take ownership of the +// memory. The string memory must outlive the `gpu_options` object. +LiteRtStatus LrtSetGpuAcceleratorCompilationOptionsSerializationDir( + LrtGpuOptions* gpu_options, const char* serialization_dir); + +// The unique nul-terminated token string that acts as a 'namespace' for +// all serialization entries. +// Should be unique to a particular model (graph & constants). +// For an example of how to generate this from a TFLite model, see +// StrFingerprint() in lite/delegates/serialization.h. +// +// Set to nullptr implies the delegate will not try serialization. +// Delegate stores the pointer to the string and doesn't take ownership of the +// memory. The string memory must outlive the `gpu_options` object. +LiteRtStatus LrtSetGpuAcceleratorCompilationOptionsModelCacheKey( + LrtGpuOptions* gpu_options, const char* model_cache_key); + +// The file descriptor to use for program caching. +// If set, the delegate will use this file descriptor to read and write the +// program cache. +// If it is not set, the delegate will use the serialization_dir + model_token +// to determine where to read and write the program cache from. +LiteRtStatus LrtSetGpuAcceleratorCompilationOptionsProgramCacheFd( + LrtGpuOptions* gpu_options, int program_cache_fd); + +// The file descriptor to use for weight caching. +// If set, the delegate will use this file descriptor to read and write the +// weight cache. +// If it is not set, the delegate will use the serialization_dir + model_token +// to determine where to read and write the weight cache from. +LiteRtStatus LrtSetGpuAcceleratorCompilationOptionsWeightCacheFd( + LrtGpuOptions* gpu_options, int weight_cache_fd); + +// When set to true AND the serialization_dir and model_cache_key are also set, +// the delegate will serialize the program cache. +LiteRtStatus LrtSetGpuAcceleratorCompilationOptionsSerializeProgramCache( + LrtGpuOptions* gpu_options, bool serialize_program_cache); + +// If true, only the compiled programs will be cached. +// If false, gpu graph info including work group sizes (and all compiled +// programs depending on backend) will be cached. +LiteRtStatus LrtSetGpuAcceleratorCompilationOptionsCacheCompiledProgramsOnly( + LrtGpuOptions* gpu_options, bool cache_only_compiled_programs); + +// Set to true to serialize immutable external tensors. By default only the +// non-external tensors are serialized. +LiteRtStatus LrtSetGpuAcceleratorCompilationOptionsSerializeExternalTensors( + LrtGpuOptions* gpu_options, bool serialize_external_tensors); + +// Sets whether to madvise the original shared tensors after use. Note that +// this boolean flag is to disable madvise which is enabled by default. +LiteRtStatus LrtSetGpuAcceleratorCompilationOptionsMadviseOriginalSharedTensors( + LrtGpuOptions* gpu_options, bool madvise_original_shared_tensors); + +// Sets whether to disable Vulkan kernel shader optimization. +LiteRtStatus LrtSetGpuAcceleratorCompilationOptionsDisableShaderOptimization( + LrtGpuOptions* gpu_options, bool disable_shader_optimization); + +// Sets the pointer to the shared tensor maps. +// The pointer must point to a litert::ml_drift::SharedTensorMaps struct. +// The caller is responsible for maintaining the lifetime of the struct +// until the model is destroyed. +// +// WARNING: This API is not ABI-stable and only for internal usage. It works +// only when the client is built together with the LiteRT and ML Drift delegate. +// Unless you know what you are doing, do not use this API. +LiteRtStatus LrtSetGpuAcceleratorCompilationOptionsSharedTensorMaps( + LrtGpuOptions* gpu_options, void* shared_tensor_maps); + +// Sets the number of steps of command buffer preparations. +LiteRtStatus +LrtSetGpuAcceleratorRuntimeOptionsNumStepsOfCommandBufferPreparations( + LrtGpuOptions* gpu_options, int num_steps_of_command_buffer_preparations); + +// Sets whether to use Metal argument buffers. +LiteRtStatus LrtSetGpuOptionsUseMetalArgumentBuffers( + LrtGpuOptions* gpu_options, bool use_metal_argument_buffers); + +// Sets whether to use MTLResidencySet to prevent memory swapping on Metal +// backend. Requires macOS 15.0+ or iOS 18.0+. +LiteRtStatus LrtSetGpuOptionsMetalResidencySet(LrtGpuOptions* gpu_options, + bool enable); + +// Sets the wait type. +LiteRtStatus LrtSetGpuAcceleratorRuntimeOptionsWaitType( + LrtGpuOptions* gpu_options, LiteRtGpuWaitType wait_type); + +// Sets the preferred device substring. +LiteRtStatus LrtSetGpuAcceleratorRuntimeOptionsPreferredDeviceSubstr( + LrtGpuOptions* gpu_options, const char* preferred_device_substr); + +// Sets the number of threads for webgpu upload. +LiteRtStatus LrtSetGpuAcceleratorRuntimeOptionsNumThreadsToUpload( + LrtGpuOptions* gpu_options, int num_threads_to_upload); + +// Sets the number of threads for webgpu kernel shader compilation. +LiteRtStatus LrtSetGpuAcceleratorRuntimeOptionsNumThreadsToCompile( + LrtGpuOptions* gpu_options, int num_threads_to_compile); + +// Sets whether to convert weights on GPU. It's an experimental feature. +LiteRtStatus LrtSetGpuAcceleratorRuntimeOptionsConvertWeightsOnGpu( + LrtGpuOptions* gpu_options, bool convert_weights_on_gpu); + +// Sets whether to wait for weights conversion on GPU complete. +// It's an experimental feature and should only be used when converting +// weights on GPU. +LiteRtStatus LrtSetGpuAcceleratorRuntimeOptionsWaitForWeightsConversionComplete( + LrtGpuOptions* gpu_options, bool wait); + +// Sets the hint to fully delegate to single delegate. +// This is an ADVANCED option and should only be set if every subgraph is +// known to be fully delegated to a single delegate. This flag can be used to +// skip unnecessary memory allocations. +LiteRtStatus LrtSetGpuOptionsHintFullyDelegatedToSingleDelegate( + LrtGpuOptions* gpu_options, bool hint_fully_delegated_to_single_delegate); + +// Sets whether to use IrModel instead of legacy GraphFloat32. +LiteRtStatus LrtSetGpuOptionsUseIrModel(LrtGpuOptions* gpu_options, + bool enable); + +// Declarations below this point are meant to be used by accelerator code. + +const char* LrtGetGpuOptionsIdentifier(); + +LiteRtStatus LrtGetGpuOptionsConstantTensorsSharing( + bool* enabled, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuOptionsInfiniteFloatCapping(bool* enabled, + const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuOptionsBenchmarkMode(bool* enabled, + const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuOptionsGpuBackend(LiteRtGpuBackend* backend, + const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuOptionsExternalTensorsMode(bool* enabled, + const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsAllowSrcQuantizedFcConvOps( + bool* enabled, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorRuntimeOptionsHintWaitingForCompletion( + bool* enabled, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorRuntimeOptionsKernelBatchSize( + int* kernel_batch_size, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsPrecision( + LiteRtDelegatePrecision* precision, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsBufferStorageType( + LiteRtDelegateBufferStorageType* type, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsPreferTextureWeights( + bool* prefer_texture_weights, const LrtGpuOptions* options); + +// Returns serialization directory. +// The returned string pointer is owned by the user of +// LrtSetGpuAcceleratorCompilationOptionsSerializationDir() API. +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsSerializationDir( + const char** serialization_dir, const LrtGpuOptions* options); + +// Returns model cache key. +// The returned string pointer is owned by the user of +// LrtSetGpuAcceleratorCompilationOptionsModelCacheKey() API. +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsModelCacheKey( + const char** model_cache_key, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsProgramCacheFd( + int* program_cache_fd, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsWeightCacheFd( + int* weight_cache_fd, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsSerializeProgramCache( + bool* serialize_program_cache, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsCacheCompiledProgramsOnly( + bool* cache_only_compiled_programs, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsSerializeExternalTensors( + bool* serialize_external_tensors, const LrtGpuOptions* options); + +LiteRtStatus LrtGetNumGpuAcceleratorCompilationOptionsExternalTensorPatterns( + int* num_patterns, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsExternalTensorPattern( + const char** external_tensor_pattern, int pattern_index, + const LrtGpuOptions* options); + +LiteRtStatus +LrtGetNumGpuAcceleratorCompilationOptionsBufferStorageTensorPatterns( + int* num_patterns, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsBufferStorageTensorPattern( + const char** buffer_storage_tensor_pattern, int pattern_index, + const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuOptionsGpuPriority(LiteRtGpuPriority* priority, + const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsMadviseOriginalSharedTensors( + bool* madvise_original_shared_tensors, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsDisableShaderOptimization( + bool* disable_shader_optimization, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorCompilationOptionsSharedTensorMaps( + void** shared_tensor_maps, const LrtGpuOptions* gpu_options); + +LiteRtStatus +LrtGetGpuAcceleratorRuntimeOptionsNumStepsOfCommandBufferPreparations( + int* num_steps_of_command_buffer_preparations, + const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuOptionsUseMetalArgumentBuffers( + const LrtGpuOptions* options, bool* use_metal_argument_buffers); + +LiteRtStatus LrtGetGpuOptionsMetalResidencySet(const LrtGpuOptions* options, + bool* enabled); + +LiteRtStatus LrtGetGpuAcceleratorRuntimeOptionsWaitType( + LiteRtGpuWaitType* wait_type, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorRuntimeOptionsPreferredDeviceSubstr( + const char** preferred_device_substr, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorRuntimeOptionsNumThreadsToUpload( + int* num_threads_to_upload, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorRuntimeOptionsNumThreadsToCompile( + int* num_threads_to_compile, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorRuntimeOptionsConvertWeightsOnGpu( + bool* convert_weights_on_gpu, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuAcceleratorRuntimeOptionsWaitForWeightsConversionComplete( + bool* wait, const LrtGpuOptions* options); + +LiteRtStatus LrtGetGpuOptionsHintFullyDelegatedToSingleDelegate( + bool* hint_fully_delegated_to_single_delegate, + const LrtGpuOptions* options); + +// Returns kLiteRtStatusErrorNotFound if not set. +LiteRtStatus LrtGetGpuOptionsUseIrModel(bool* enabled, + const LrtGpuOptions* options); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_GPU_OPTIONS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_intel_openvino_options.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_intel_openvino_options.h new file mode 100644 index 0000000000000000000000000000000000000000..5d134b8d3466ac1075f4dff3e2afcd756aefb4ed --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_intel_openvino_options.h @@ -0,0 +1,175 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright (c) Qualcomm Innovation Center, Inc. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_INTEL_OPENVINO_OPTIONS_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_INTEL_OPENVINO_OPTIONS_H_ +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +LITERT_DEFINE_HANDLE(LrtIntelOpenVinoOptions); + +// Create an Intel OpenVINO options object. +LiteRtStatus LrtIntelOpenVinoOptionsCreate(LrtIntelOpenVinoOptions* options); + +// Destroy the options object. +void LrtDestroyIntelOpenVinoOptions(LrtIntelOpenVinoOptions options); + +// Serializes intel openvino options and returns the components needed to create +// opaque options. The caller is responsible for passing these to +// `LiteRtCreateOpaqueOptions`. +LiteRtStatus LrtGetOpaqueIntelOpenVinoOptionsData( + LrtIntelOpenVinoOptions options, const char** identifier, void** payload, + void (**payload_deleter)(void*)); + +// Gets the identifier for Intel OpenVINO options stored in opaque options. +const char* LrtGetIntelOpenVinoOptionsIdentifier(); + +// Parses a TOML string into the C API representation. +LiteRtStatus LrtCreateIntelOpenVinoOptionsFromToml( + const char* payload, LrtIntelOpenVinoOptions* options); + +// COMPILATION OPTIONS ///////////////////////////////////////////////////////// + +// graph_backend -------------------------------------------------------------- +// +// The OpenVINO target device for a graph (partition). Each partition in a +// compiled model carries its own graph type and is dispatched on the +// corresponding OpenVINO device. There is no longer a model-wide "device +// type"; configure each partition individually via the per-graph API below. +typedef enum LiteRtIntelOpenVinoGraphBackend { + kLiteRtIntelOpenVinoGraphBackendCPU = 0, + kLiteRtIntelOpenVinoGraphBackendGPU = 1, + kLiteRtIntelOpenVinoGraphBackendNPU = 2, + kLiteRtIntelOpenVinoGraphBackendMax = 3, +} LiteRtIntelOpenVinoGraphBackend; + +// performance_mode ----------------------------------------------------------- + +// Configures OpenVINO devices to optimize for performance or efficiency. +// See ov::hint::PerformanceMode in OpenVINO. By default, it +// will use LATENCY mode. + +typedef enum LiteRtIntelOpenVinoPerformanceMode { + /* Optimize for low latency */ + kLiteRtIntelOpenVinoPerformanceModeLatency = 0, + /* Optimize for high throughput */ + kLiteRtIntelOpenVinoPerformanceModeThroughput = 1, + /* Optimize for cumulative throughput */ + kLiteRtIntelOpenVinoPerformanceModeCumulativeThroughput = 2, +} LiteRtIntelOpenVinoPerformanceMode; + +LiteRtStatus LrtIntelOpenVinoOptionsSetPerformanceMode( + LrtIntelOpenVinoOptions options, + LiteRtIntelOpenVinoPerformanceMode performance_mode); + +LiteRtStatus LrtIntelOpenVinoOptionsGetPerformanceMode( + LrtIntelOpenVinoOptions options, + LiteRtIntelOpenVinoPerformanceMode* performance_mode); + +// enable_weight_sharing ------------------------------------------------------ +// Controls whether multiple subgraphs may share the same weight pool when the +// backend supports it. Defaults to true for Intel OpenVINO. +LiteRtStatus LrtIntelOpenVinoOptionsSetEnableWeightSharing( + LrtIntelOpenVinoOptions options, bool enable_weight_sharing); + +LiteRtStatus LrtIntelOpenVinoOptionsGetEnableWeightSharing( + LrtIntelOpenVinoOptions options, bool* enable_weight_sharing); + +// configs_map ---------------------------------------------------------------- + +// Set a custom configuration option with a string key-value pair. +// The key and value strings are copied internally, so their lifetime does not +// need to extend beyond this function call. +LiteRtStatus LrtIntelOpenVinoOptionsSetConfigsMapOption( + LrtIntelOpenVinoOptions options, const char* key, const char* value); + +// Get the number of custom configuration options +LiteRtStatus LrtIntelOpenVinoOptionsGetNumConfigsMapOptions( + LrtIntelOpenVinoOptions options, int* num_options); + +// Get a custom configuration option by index. +// The returned key and value pointers point to internal string data +// and are valid for the lifetime of the options object. +// The caller should not free these pointers. +LiteRtStatus LrtIntelOpenVinoOptionsGetConfigsMapOption( + LrtIntelOpenVinoOptions options, int index, const char** key, + const char** value); + +// per-graph backend overrides ------------------------------------------------ +// +// The OpenVINO compiler plugin compiles each partition for its configured +// graph type (device), and the dispatcher imports each partition's bytecode +// on that same device automatically. +// +// `graph_index` corresponds to the partition index produced by the LiteRT +// partitioner (i.e. the order of subgraphs in the partitioned model passed +// to `LiteRtCompilerPluginCompile`). Applications that want to map a model +// signature key to a graph index should resolve that mapping themselves and +// pass the resulting integer index here. + +// Sets the OpenVINO graph backend (target device) for a specific graph +// (partition) index. Pass `graph_index = -1` as a wildcard to set the default +// backend used by all graphs that do not have an explicit per-index override. +// Partitions without either an explicit or wildcard override fall back to NPU. +LiteRtStatus LrtIntelOpenVinoOptionsSetGraphBackend( + LrtIntelOpenVinoOptions options, int graph_index, + enum LiteRtIntelOpenVinoGraphBackend graph_backend); + +// Gets the graph backend override for a specific graph index. Falls back to +// the wildcard (`graph_index = -1`) entry when no per-index override exists. +// Returns `kLiteRtStatusErrorNotFound` when neither is set. +LiteRtStatus LrtIntelOpenVinoOptionsGetGraphBackend( + LrtIntelOpenVinoOptions options, int graph_index, + enum LiteRtIntelOpenVinoGraphBackend* graph_backend); + +// Sets an OpenVINO config map option for a specific graph index. These +// per-graph configs are merged on top of the model-wide configs at compile +// time, with the per-graph values taking precedence. +LiteRtStatus LrtIntelOpenVinoOptionsSetGraphConfigsMapOption( + LrtIntelOpenVinoOptions options, int graph_index, const char* key, + const char* value); + +// Number of graphs that have at least one per-graph override (device and/or +// config map entries). +LiteRtStatus LrtIntelOpenVinoOptionsGetNumGraphOverrides( + LrtIntelOpenVinoOptions options, int* num_overrides); + +// Returns the graph index at slot `slot_index`. Use together with +// `LrtIntelOpenVinoOptionsGetNumGraphOverrides` to enumerate overrides. +LiteRtStatus LrtIntelOpenVinoOptionsGetGraphOverrideIndex( + LrtIntelOpenVinoOptions options, int slot_index, int* graph_index); + +// Number of per-graph config map entries set for `graph_index`. Returns 0 +// if no overrides are set for that graph. +LiteRtStatus LrtIntelOpenVinoOptionsGetNumGraphConfigsMapOptions( + LrtIntelOpenVinoOptions options, int graph_index, int* num_options); + +// Returns the (key, value) of the `index`-th config map entry for +// `graph_index`. +LiteRtStatus LrtIntelOpenVinoOptionsGetGraphConfigsMapOption( + LrtIntelOpenVinoOptions options, int graph_index, int index, + const char** key, const char** value); + +#ifdef __cplusplus + +} // extern "C" + +#endif // __cplusplus +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_INTEL_OPENVINO_OPTIONS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_mediatek_options.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_mediatek_options.h new file mode 100644 index 0000000000000000000000000000000000000000..34912836bf114449cfb570f96f94020d8d1a9db4 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_mediatek_options.h @@ -0,0 +1,216 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_MEDIATEK_OPTIONS_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_MEDIATEK_OPTIONS_H_ + +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +typedef struct LrtMediatekOptions LrtMediatekOptions; + +// Creates a mediatek options object. +// The caller is responsible for freeing the returned options using +// `LrtDestroyMediatekOptions`. +LiteRtStatus LrtCreateMediatekOptions(LrtMediatekOptions** options); + +// Creates a mediatek options object from a TOML payload. +LiteRtStatus LrtCreateMediatekOptionsFromToml(const char* toml_payload, + LrtMediatekOptions** options); + +// Destroys a mediatek options object. +void LrtDestroyMediatekOptions(LrtMediatekOptions* options); + +// Serializes mediatek options and returns the components needed to create +// opaque options. The caller is responsible for passing these to +// `LiteRtCreateOpaqueOptions` and freeing the returned payload using +// `payload_deleter`. +LiteRtStatus LrtGetOpaqueMediatekOptionsData(const LrtMediatekOptions* options, + const char** identifier, + void** payload, + void (**payload_deleter)(void*)); + +// COMPILATION OPTIONS ///////////////////////////////////////////////////////// + +// sdk_version_type ---------------------------------------------------------- +typedef enum LiteRtMediatekOptionsNeronSDKVersionType { + kLiteRtMediatekOptionsNeronSDKVersionTypeVersion7 = 0, + kLiteRtMediatekOptionsNeronSDKVersionTypeVersion8 = 1, + kLiteRtMediatekOptionsNeronSDKVersionTypeVersion9 = 2, +} LiteRtMediatekOptionsNeronSDKVersion; + +LiteRtStatus LrtSetMediatekOptionsNeronSDKVersionType( + LrtMediatekOptions* options, + enum LiteRtMediatekOptionsNeronSDKVersionType sdk_version_type); + +LiteRtStatus LrtGetMediatekOptionsNeronSDKVersionType( + const LrtMediatekOptions* options, + enum LiteRtMediatekOptionsNeronSDKVersionType* sdk_version_type); + +// gemma_compiler_optimizations ---------------------------------------------- +LiteRtStatus LrtSetMediatekOptionsGemmaCompilerOptimizations( + LrtMediatekOptions* options, bool gemma_compiler_optimizations); + +LiteRtStatus LrtGetMediatekOptionsGemmaCompilerOptimizations( + const LrtMediatekOptions* options, bool* gemma_compiler_optimizations); + +// option_bundle ------------------------------------------------------------- + +// The Neuron compiler `--option-bundle=` value used when +// `gemma_compiler_optimizations` is enabled. These have no effect unless that +// flag is set. +// +// The bundle is selected per subgraph: the decode partition uses +// `option_bundle_decode` and the prefill partition uses +// `option_bundle_prefill`. Any other subgraph falls back to +// `option_bundle_decode`. +// +// `option_bundle` is an override that applies to every subgraph. It is unset +// by default (empty string); when non-empty it takes precedence over both the +// decode and prefill bundles. Use it for models that have more than the two +// decode/prefill signatures. +// +// Leaving all three unset preserves the historical behavior of hardcoding +// "gemma-decode-accuracy" and "gemma-prefill-accuracy". + +// Overrides the bundle for every subgraph. Empty means unset. +LiteRtStatus LrtSetMediatekOptionsOptionBundle(LrtMediatekOptions* options, + const char* option_bundle); + +// Returns the override bundle for every subgraph. +// Note: The returned string pointer is owned by `options` (or points to static +// storage) and remains valid as long as `options` is alive and has not been +// modified. It must not be freed or modified by the caller. +LiteRtStatus LrtGetMediatekOptionsOptionBundle( + const LrtMediatekOptions* options, const char** option_bundle); + +// Bundle for the decode partition. Defaults to "gemma-decode-accuracy". +LiteRtStatus LrtSetMediatekOptionsOptionBundleDecode( + LrtMediatekOptions* options, const char* option_bundle_decode); + +// Returns the bundle for the decode partition. +// Note: The returned string pointer is owned by `options` (or points to static +// storage) and remains valid as long as `options` is alive and has not been +// modified. It must not be freed or modified by the caller. +LiteRtStatus LrtGetMediatekOptionsOptionBundleDecode( + const LrtMediatekOptions* options, const char** option_bundle_decode); + +// Bundle for the prefill partition. Defaults to "gemma-prefill-accuracy". +LiteRtStatus LrtSetMediatekOptionsOptionBundlePrefill( + LrtMediatekOptions* options, const char* option_bundle_prefill); + +// Returns the bundle for the prefill partition. +// Note: The returned string pointer is owned by `options` (or points to static +// storage) and remains valid as long as `options` is alive and has not been +// modified. It must not be freed or modified by the caller. +LiteRtStatus LrtGetMediatekOptionsOptionBundlePrefill( + const LrtMediatekOptions* options, const char** option_bundle_prefill); + +// neuron_adapter_peformance_mode -------------------------------------------- + +// Configures MTK devices to optimize for performance or power efficiency. +// See NeuronAdapterPreferenceCode in mtk_sdk. By default, it +// will use Sustained Speed answer. + +typedef enum LiteRtMediatekNeuronAdapterPerformanceMode { + /* Prefer executing in a way that minimizes battery drain. */ + kLiteRtMediatekNeuronAdapterPerformanceModeNeuronPreferLowPower = 0, + /* Prefer executing as fast as possible. (more power consumption)*/ + kLiteRtMediatekNeuronAdapterPerformanceModeNeuronPreferFastSingleAnswer = 1, + /* Prefer maximizing the throughput of successive frames */ + kLiteRtMediatekNeuronAdapterPerformanceModeNeuronPreferSustainedSpeed = 2, + /* Prefer executing with turbo boost. (most power consumption) */ + kLiteRtMediatekNeuronAdapterPerformanceModeNeuronPreferTurboBoost = 3, +} LiteRtMediatekNeuronAdapterPerformanceMode; + +LiteRtStatus LrtSetMediatekOptionsPerformanceMode( + LrtMediatekOptions* options, + LiteRtMediatekNeuronAdapterPerformanceMode performance_mode); + +LiteRtStatus LrtGetMediatekOptionsPerformanceMode( + const LrtMediatekOptions* options, + LiteRtMediatekNeuronAdapterPerformanceMode* performance_mode); + +// l1_cache_optimizations ---------------------------------------------------- +LiteRtStatus LrtSetMediatekOptionsL1CacheOptimizations( + LrtMediatekOptions* options, bool l1_cache_optimizations); + +LiteRtStatus LrtGetMediatekOptionsL1CacheOptimizations( + const LrtMediatekOptions* options, bool* l1_cache_optimizations); + +// neuron_optimization_hints ------------------------------------------------- + +// Configures MTK devices with optimization hints.. +// By default, it will use NEURON_OPTIMIZATION_NORMAL. + +typedef enum LiteRtMediatekNeuronAdapterOptimizationHint { + /* Normal optimization. Default Value */ + kLiteRtMediatekNeuronAdapterOptimizationHintNormal = 0, + /* Reduce latency by utilizing as many APU cores as possible.*/ + kLiteRtMediatekNeuronAdapterOptimizationHintLowLatency = 1 << 0, + /* Reducing DRAM access as more as possible.*/ + kLiteRtMediatekNeuronAdapterOptimizationHintDeepFusion = 1 << 1, + /*Reduce latency by using as many APU cores as possible in batch-dimension. + * (For models with batch > 1)*/ + kLiteRtMediatekNeuronAdapterOptimizationHintBatchProcessing = 1 << 2, +} LiteRtMediatekNeuronAdapterOptimizationHint; + +LiteRtStatus LrtSetMediatekOptionsOptimizationHint( + LrtMediatekOptions* options, + LiteRtMediatekNeuronAdapterOptimizationHint optimization_hint); + +LiteRtStatus LrtGetMediatekOptionsOptimizationHint( + const LrtMediatekOptions* options, + LiteRtMediatekNeuronAdapterOptimizationHint* optimization_hint); + +// disable_dla_dir_removal --------------------------------------------------- +LiteRtStatus LrtSetMediatekOptionsDisableDlaDirRemoval( + LrtMediatekOptions* options, bool disable_dla_dir_removal); + +LiteRtStatus LrtGetMediatekOptionsDisableDlaDirRemoval( + const LrtMediatekOptions* options, bool* disable_dla_dir_removal); + +// use_get_supported_operations ---------------------------------------------- +// Controls whether partitioning queries the Neuron compiler via +// get_supported_operations (richer view of what the SDK can run) or just +// uses the plugin's static IsOpSupported list. Defaults to true. +LiteRtStatus LrtSetMediatekOptionsUseGetSupportedOperations( + LrtMediatekOptions* options, bool use_get_supported_operations); + +LiteRtStatus LrtGetMediatekOptionsUseGetSupportedOperations( + const LrtMediatekOptions* options, bool* use_get_supported_operations); + +// mediatek_dla_dir ---------------------------------------------------------- + +LiteRtStatus LrtSetMediatekOptionsMediatekDlaDir(LrtMediatekOptions* options, + const char* mediatek_dla_dir); + +LiteRtStatus LrtGetMediatekOptionsMediatekDlaDir( + const LrtMediatekOptions* options, const char** mediatek_dla_dir); + +// AoT compilation options -------------------------------------------- +LiteRtStatus LrtSetMediatekOptionsAotCompilationOptions( + LrtMediatekOptions* options, const char* aot_compilation_options); + +LiteRtStatus LrtGetMediatekOptionsAotCompilationOptions( + const LrtMediatekOptions* options, const char** aot_compilation_options); + +#ifdef __cplusplus + +} // extern "C" + +#endif // __cplusplus +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_MEDIATEK_OPTIONS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_qualcomm_options.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_qualcomm_options.h new file mode 100644 index 0000000000000000000000000000000000000000..4106ca18d5790879e9857039a9afb264515b5c3b --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_qualcomm_options.h @@ -0,0 +1,547 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Copyright (c) Qualcomm Innovation Center, Inc. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_QUALCOMM_OPTIONS_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_QUALCOMM_OPTIONS_H_ + +#include +#include + +#include "litert/c/litert_common.h" + +// User-facing options for Qualcomm. This is not built as part of +// libLiteRt_QualcommXXX.so, and should not include `vendor/` or qnn sdk +// headers. + +// C-API for an opaque options type relevant to Qualcomm (both dspatch and +// plugin). +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +LITERT_DEFINE_HANDLE(LrtQualcommOptions); + +// The string identifier that discriminates qualcomm options within +// type erased options. +const char* LrtQualcommOptionsGetIdentifier(); + +// Create a qualcomm options object. +LiteRtStatus LrtCreateQualcommOptions(LrtQualcommOptions* options); + +#ifdef __cplusplus +// Create a qualcomm options object mapped from a TOML payload. +LiteRtStatus LrtCreateQualcommOptionsFromToml(const char* toml_payload, + LrtQualcommOptions* options); +#endif // __cplusplus + +// Destroy a qualcomm options object. +void LrtDestroyQualcommOptions(LrtQualcommOptions options); + +LiteRtStatus LrtGetOpaqueQualcommOptionsData(LrtQualcommOptions options, + const char** identifier, + void** payload, + void (**payload_deleter)(void*)); + +// GENERAL SDK SETTINGS //////////////////////////////////////////////////////// + +// log_level + +// This determines the logging level of all underlying qualcomm sdk libraries. +// Does not effect litert logging. Defaults to INFO. + +typedef enum LrtQualcommOptionsLogLevel { + kLiteRtQualcommLogOff = 0, + kLiteRtQualcommLogLevelError = 1, + kLiteRtQualcommLogLevelWarn = 2, + kLiteRtQualcommLogLevelInfo = 3, + kLiteRtQualcommLogLevelVerbose = 4, + kLiteRtQualcommLogLevelDebug = 5, +} LrtQualcommOptionsLogLevel; + +LiteRtStatus LrtQualcommOptionsSetLogLevel( + LrtQualcommOptions options, LrtQualcommOptionsLogLevel log_level); + +LiteRtStatus LrtQualcommOptionsGetLogLevel( + LrtQualcommOptions options, LrtQualcommOptionsLogLevel* log_level); + +// profiling + +// This option controls the profiling level. A higher level results in a more +// detailed report after execution. Defaults to off. Read at both compile time +// (context creation) and dispatch time (graph execution). + +typedef enum LrtQualcommOptionsProfiling { + kLiteRtQualcommProfilingOff = 0, + kLiteRtQualcommProfilingBasic, + kLiteRtQualcommProfilingDetailed, + kLiteRtQualcommProfilingLinting, + kLiteRtQualcommProfilingOptrace, +} LrtQualcommOptionsProfiling; + +LiteRtStatus LrtQualcommOptionsSetProfiling( + LrtQualcommOptions options, LrtQualcommOptionsProfiling profiling); + +LiteRtStatus LrtQualcommOptionsGetProfiling( + LrtQualcommOptions options, LrtQualcommOptionsProfiling* profiling); + +// COMPILATION OPTIONS ///////////////////////////////////////////////////////// + +// use_htp_preference +// @deprecated This option is deprecated and will be no-op. + +// This option controls whether to convert a LiteRt operation to QNN operations +// which are preferred by the HTP backend. Defaults to false. + +LiteRtStatus LrtQualcommOptionsSetUseHtpPreference(LrtQualcommOptions options, + bool use_htp_preference); + +LiteRtStatus LrtQualcommOptionsGetUseHtpPreference(LrtQualcommOptions options, + bool* use_htp_preference); + +// use_qint16_as_quint16 +// @deprecated This option is deprecated and will be no-op. + +// This option controls whether to convert a quantized int16 model to a +// quantized uint16 model. Defaults to false. + +LiteRtStatus LrtQualcommOptionsSetUseQint16AsQuint16( + LrtQualcommOptions options, bool use_qint16_as_quint16); + +LiteRtStatus LrtQualcommOptionsGetUseQint16AsQuint16( + LrtQualcommOptions options, bool* use_qint16_as_quint16); + +// use_int64_bias_as_int32 + +// This option controls whether to convert bias tensors of FullyConnected +// and Conv2D Ops from int64 to int32 . Defaults to true. + +LiteRtStatus LrtQualcommOptionsSetUseInt64BiasAsInt32( + LrtQualcommOptions options, bool use_int64_bias_as_int32); + +LiteRtStatus LrtQualcommOptionsGetUseInt64BiasAsInt32( + LrtQualcommOptions options, bool* use_int64_bias_as_int32); + +// enable_weight_sharing + +// Weight sharing indicates whether different subgraphs may share weight +// tensors. This is only supported on x86 AOT. Defaults to false. +// +// Note: weight sharing is mutually exclusive with HTP DLBC weights (QAIRT +// 2.36+). When both are requested, weight sharing wins and DLBC weights is +// forced off. + +LiteRtStatus LrtQualcommOptionsSetEnableWeightSharing( + LrtQualcommOptions options, bool enable_weight_sharing); + +LiteRtStatus LrtQualcommOptionsGetEnableWeightSharing( + LrtQualcommOptions options, bool* enable_weight_sharing); + +// enable_just_in_time + +// Just-In-Time allows passing the QNN Context directly from the compiler plugin +// to the dispatcher in-memory, bypassing graph finalization and serialization. +// Defaults to false. + +LiteRtStatus LrtQualcommOptionsSetEnableJustInTime(LrtQualcommOptions options, + bool enable_just_in_time); + +LiteRtStatus LrtQualcommOptionsGetEnableJustInTime(LrtQualcommOptions options, + bool* enable_just_in_time); + +LiteRtStatus LrtQualcommOptionsSetDumpTensorIds(LrtQualcommOptions options, + const int32_t* ids, + size_t number_of_ids); + +LiteRtStatus LrtQualcommOptionsGetDumpTensorIds(LrtQualcommOptions options, + const int32_t** ids, + size_t* number_of_ids); + +// When using short conv hmx, one might have better performance, but convolution +// that have short depth and/or weights that are not symmetric could exhibit +// inaccurate results. + +LiteRtStatus LrtQualcommOptionsSetUseConvHMX(LrtQualcommOptions options, + bool use_conv_hmx); + +LiteRtStatus LrtQualcommOptionsGetUseConvHMX(LrtQualcommOptions options, + bool* use_conv_hmx); + +// When using fold relu, one might have better performance. This optimization is +// correct when quantization ranges for convolution are equal to or are subset +// of the Relu operation. + +LiteRtStatus LrtQualcommOptionsSetUseFoldReLU(LrtQualcommOptions options, + bool use_fold_relu); + +LiteRtStatus LrtQualcommOptionsGetUseFoldReLU(LrtQualcommOptions options, + bool* use_fold_relu); + +// graph_io_tensor_mem_type + +// This controls whether graph inputs and outputs use MemHandle or Raw buffers +// during compilation. + +typedef enum LrtQualcommOptionsGraphIOTensorMemType { + kLiteRtQualcommGraphIOTensorMemTypeRaw = 0, + kLiteRtQualcommGraphIOTensorMemTypeMemHandle, +} LrtQualcommOptionsGraphIOTensorMemType; + +LiteRtStatus LrtQualcommOptionsSetGraphIOTensorMemType( + LrtQualcommOptions options, + LrtQualcommOptionsGraphIOTensorMemType mem_type); + +LiteRtStatus LrtQualcommOptionsGetGraphIOTensorMemType( + LrtQualcommOptions options, + LrtQualcommOptionsGraphIOTensorMemType* mem_type); + +// P points are experimental (HTP backend with O3 only) and map to predefined +// compiler configurations affecting latency and DRAM bandwidth. + +LiteRtStatus LrtQualcommOptionsSetHtpPPoint(LrtQualcommOptions options, + int32_t htp_p_point); + +LiteRtStatus LrtQualcommOptionsGetHtpPPoint(LrtQualcommOptions options, + int32_t* htp_p_point); + +// DISPATCH OPTIONS //////////////////////////////////////////////////////////// + +// htp_performance_mode + +// Configures the HTP device to optimize for performance or power efficiency. +// See QnnHtpPerfInfrastructure_SetPowerConfigFn_t in qnn_sdk. By default, it +// will be decided by the backend (unknown). + +typedef enum LrtQualcommOptionsHtpPerformanceMode { + kLiteRtQualcommHtpPerformanceModeDefault = 0, + kLiteRtQualcommHtpPerformanceModeSustainedHighPerformance = 1, + kLiteRtQualcommHtpPerformanceModeBurst = 2, + kLiteRtQualcommHtpPerformanceModeHighPerformance = 3, + kLiteRtQualcommHtpPerformanceModePowerSaver = 4, + kLiteRtQualcommHtpPerformanceModeLowPowerSaver = 5, + kLiteRtQualcommHtpPerformanceModeHighPowerSaver = 6, + kLiteRtQualcommHtpPerformanceModeLowBalanced = 7, + kLiteRtQualcommHtpPerformanceModeBalanced = 8, + kLiteRtQualcommHtpPerformanceModeExtremePowerSaver = 9, +} LrtQualcommOptionsHtpPerformanceMode; + +LiteRtStatus LrtQualcommOptionsSetHtpPerformanceMode( + LrtQualcommOptions options, + LrtQualcommOptionsHtpPerformanceMode htp_performance_mode); + +LiteRtStatus LrtQualcommOptionsGetHtpPerformanceMode( + LrtQualcommOptions options, + LrtQualcommOptionsHtpPerformanceMode* htp_performance_mode); + +// dsp_performance_mode + +typedef enum LrtQualcommOptionsDspPerformanceMode { + kLiteRtQualcommDspPerformanceModeDefault = 0, + kLiteRtQualcommDspPerformanceModeSustainedHighPerformance = 1, + kLiteRtQualcommDspPerformanceModeBurst = 2, + kLiteRtQualcommDspPerformanceModeHighPerformance = 3, + kLiteRtQualcommDspPerformanceModePowerSaver = 4, + kLiteRtQualcommDspPerformanceModeLowPowerSaver = 5, + kLiteRtQualcommDspPerformanceModeHighPowerSaver = 6, + kLiteRtQualcommDspPerformanceModeLowBalanced = 7, + kLiteRtQualcommDspPerformanceModeBalanced = 8, +} LrtQualcommOptionsDspPerformanceMode; + +LiteRtStatus LrtQualcommOptionsSetDspPerformanceMode( + LrtQualcommOptions options, + LrtQualcommOptionsDspPerformanceMode dsp_performance_mode); + +LiteRtStatus LrtQualcommOptionsGetDspPerformanceMode( + LrtQualcommOptions options, + LrtQualcommOptionsDspPerformanceMode* dsp_performance_mode); + +// perf_ctrl_mode + +// Controls whether per-inference performance voting with a 300ms debounce +// timer is enabled (auto) or whether the caller manages voting manually +// (manual, the default). +typedef enum LrtQualcommOptionsHtpPerfCtrlMode { + kLiteRtQualcommHtpPerfCtrlModeManual = 0, + kLiteRtQualcommHtpPerfCtrlModeAuto = 1, +} LrtQualcommOptionsHtpPerfCtrlMode; + +LiteRtStatus LrtQualcommOptionsSetHtpPerfCtrlMode( + LrtQualcommOptions options, + LrtQualcommOptionsHtpPerfCtrlMode htp_perf_ctrl_mode); + +LiteRtStatus LrtQualcommOptionsGetHtpPerfCtrlMode( + LrtQualcommOptions options, + LrtQualcommOptionsHtpPerfCtrlMode* htp_perf_ctrl_mode); + +// Selects the HTP Process Domain session. The default is unsigned, preserving +// the existing HTP device configuration and performance behavior. +typedef enum LrtQualcommOptionsHtpPdSession { + kLiteRtQualcommHtpUnsignedPd = 0, + kLiteRtQualcommHtpSignedPd = 1, + kLiteRtQualcommHtpAdaptivePd = 2, +} LrtQualcommOptionsHtpPdSession; + +LiteRtStatus LrtQualcommOptionsSetHtpPdSession( + LrtQualcommOptions options, LrtQualcommOptionsHtpPdSession htp_pd_session); + +LiteRtStatus LrtQualcommOptionsGetHtpPdSession( + LrtQualcommOptions options, LrtQualcommOptionsHtpPdSession* htp_pd_session); + +typedef enum LrtQualcommOptionsDspPerfCtrlMode { + kLiteRtQualcommDspPerfCtrlModeManual = 0, + kLiteRtQualcommDspPerfCtrlModeAuto = 1, +} LrtQualcommOptionsDspPerfCtrlMode; + +LiteRtStatus LrtQualcommOptionsSetDspPerfCtrlMode( + LrtQualcommOptions options, + LrtQualcommOptionsDspPerfCtrlMode dsp_perf_ctrl_mode); + +LiteRtStatus LrtQualcommOptionsGetDspPerfCtrlMode( + LrtQualcommOptions options, + LrtQualcommOptionsDspPerfCtrlMode* dsp_perf_ctrl_mode); + +// Selects the DSP Process Domain session. The default is unsigned. Adaptive +// selects unsigned only when the DSP advertises unsigned PD support. +typedef enum LrtQualcommOptionsDspPdSession { + kLiteRtQualcommDspUnsignedPd = 0, + kLiteRtQualcommDspSignedPd = 1, + kLiteRtQualcommDspAdaptivePd = 2, +} LrtQualcommOptionsDspPdSession; + +LiteRtStatus LrtQualcommOptionsSetDspPdSession( + LrtQualcommOptions options, LrtQualcommOptionsDspPdSession dsp_pd_session); + +LiteRtStatus LrtQualcommOptionsGetDspPdSession( + LrtQualcommOptions options, LrtQualcommOptionsDspPdSession* dsp_pd_session); + +typedef enum LrtQualcommOptionsDspEncoding { + kLiteRtQualcommDspEncodingStatic = 0, + kLiteRtQualcommDspEncodingDynamic = 1, +} LrtQualcommOptionsDspEncoding; + +LiteRtStatus LrtQualcommOptionsSetDspEncoding( + LrtQualcommOptions options, LrtQualcommOptionsDspEncoding dsp_encoding); + +LiteRtStatus LrtQualcommOptionsGetDspEncoding( + LrtQualcommOptions options, LrtQualcommOptionsDspEncoding* dsp_encoding); + +LiteRtStatus LrtQualcommOptionsSetIrJsonDir(LrtQualcommOptions options, + const char* ir_json_dir); + +LiteRtStatus LrtQualcommOptionsGetIrJsonDir(LrtQualcommOptions options, + const char** ir_json_dir); + +LiteRtStatus LrtQualcommOptionsSetDlcDir(LrtQualcommOptions options, + const char* dlc_dir); + +LiteRtStatus LrtQualcommOptionsGetDlcDir(LrtQualcommOptions options, + const char** dlc_dir); + +LiteRtStatus LrtQualcommOptionsSetGraphTransform(LrtQualcommOptions options, + const char* graph_transform); + +LiteRtStatus LrtQualcommOptionsGetGraphTransform(LrtQualcommOptions options, + const char** graph_transform); + +LiteRtStatus LrtQualcommOptionsSetVtcmSize(LrtQualcommOptions options, + uint32_t vtcm_size); + +LiteRtStatus LrtQualcommOptionsGetVtcmSize(LrtQualcommOptions options, + uint32_t* vtcm_size); + +LiteRtStatus LrtQualcommOptionsSetNumHvxThreads(LrtQualcommOptions options, + uint32_t num_hvx_threads); + +LiteRtStatus LrtQualcommOptionsGetNumHvxThreads(LrtQualcommOptions options, + uint32_t* num_hvx_threads); + +typedef enum LrtQualcommOptionsOptimizationLevel { + kHtpOptimizeForInference = 0, + kHtpOptimizeForPrepare, + kHtpOptimizeForInferenceO3, +} LrtQualcommOptionsOptimizationLevel; + +LiteRtStatus LrtQualcommOptionsSetOptimizationLevel( + LrtQualcommOptions options, + LrtQualcommOptionsOptimizationLevel optimization_level); + +LiteRtStatus LrtQualcommOptionsGetOptimizationLevel( + LrtQualcommOptions options, + LrtQualcommOptionsOptimizationLevel* optimization_level); + +typedef enum LrtQualcommOptionsGraphPriority { + kLiteRTQualcommGraphPriorityDefault = 0, + kLiteRTQualcommGraphPriorityLow, + kLiteRTQualcommGraphPriorityNormal, + kLiteRTQualcommGraphPriorityNormalHigh, + kLiteRTQualcommGraphPriorityHigh, +} LrtQualcommOptionsGraphPriority; + +LiteRtStatus LrtQualcommOptionsSetGraphPriority( + LrtQualcommOptions options, LrtQualcommOptionsGraphPriority graph_priority); + +LiteRtStatus LrtQualcommOptionsGetGraphPriority( + LrtQualcommOptions options, + LrtQualcommOptionsGraphPriority* graph_priority); + +typedef enum LrtQualcommOptionsBackend { + kLiteRtQualcommBackendUndefined = 0, + kLiteRtQualcommBackendGpu, + kLiteRtQualcommBackendHtp, + kLiteRtQualcommBackendDsp, + kLiteRtQualcommBackendIr, + kLiteRtQualcommBackendLpai, +} LrtQualcommOptionsBackend; + +LiteRtStatus LrtQualcommOptionsSetBackend( + LrtQualcommOptions options, LrtQualcommOptionsBackend qnn_backend); + +LiteRtStatus LrtQualcommOptionsGetBackend( + LrtQualcommOptions options, LrtQualcommOptionsBackend* qnn_backend); + +LiteRtStatus LrtQualcommOptionsSetSaverOutputDir(LrtQualcommOptions options, + const char* saver_output_dir); + +LiteRtStatus LrtQualcommOptionsGetSaverOutputDir(LrtQualcommOptions options, + const char** saver_output_dir); + +LiteRtStatus LrtQualcommOptionsSetSchematicDir(LrtQualcommOptions options, + const char* schematic_dir); + +LiteRtStatus LrtQualcommOptionsGetSchematicDir(LrtQualcommOptions options, + const char** schematic_dir); + +LiteRtStatus LrtQualcommOptionsSetCustomOpPackage( + LrtQualcommOptions options, const char* name, + const char* interface_provider, const char* compile_package_path, + const char* dispatch_package_path, const char* target); + +LiteRtStatus LrtQualcommOptionsGetCustomOpPackage( + LrtQualcommOptions options, const char** name, + const char** interface_provider, const char** compile_package_path, + const char** dispatch_package_path, const char** target); + +// LPAI OPTIONS //////////////////////////////////////////////////////////////// + +typedef enum LrtQualcommOptionsLpaiTarget { + kLiteRtQualcommLpaiTargetX86 = 0, + kLiteRtQualcommLpaiTargetArm = 1, + kLiteRtQualcommLpaiTargetAdsp = 2, + kLiteRtQualcommLpaiTargetTensilica = 3, +} LrtQualcommOptionsLpaiTarget; + +LiteRtStatus LrtQualcommOptionsSetLpaiTarget( + LrtQualcommOptions options, LrtQualcommOptionsLpaiTarget lpai_target); + +LiteRtStatus LrtQualcommOptionsGetLpaiTarget( + LrtQualcommOptions options, LrtQualcommOptionsLpaiTarget* lpai_target); + +LiteRtStatus LrtQualcommOptionsSetLpaiFps(LrtQualcommOptions options, + uint32_t lpai_fps); + +LiteRtStatus LrtQualcommOptionsGetLpaiFps(LrtQualcommOptions options, + uint32_t* lpai_fps); + +LiteRtStatus LrtQualcommOptionsSetLpaiFtrtRatio(LrtQualcommOptions options, + uint32_t lpai_ftrt_ratio); + +LiteRtStatus LrtQualcommOptionsGetLpaiFtrtRatio(LrtQualcommOptions options, + uint32_t* lpai_ftrt_ratio); +typedef enum LrtQualcommOptionsLpaiClientPerfType { + kLiteRtQualcommLpaiClientPerfTypeDefault = 0, + kLiteRtQualcommLpaiClientPerfTypeRealTime = 1, + kLiteRtQualcommLpaiClientPerfTypeNonRealTime = 2, +} LrtQualcommOptionsLpaiClientPerfType; + +LiteRtStatus LrtQualcommOptionsSetLpaiClientPerfType( + LrtQualcommOptions options, + LrtQualcommOptionsLpaiClientPerfType lpai_client_perf_type); + +LiteRtStatus LrtQualcommOptionsGetLpaiClientPerfType( + LrtQualcommOptions options, + LrtQualcommOptionsLpaiClientPerfType* lpai_client_perf_type); + +typedef enum LrtQualcommOptionsLpaiCoreAffinityType { + kLiteRtQualcommLpaiCoreAffinityTypeDefault = 0, + kLiteRtQualcommLpaiCoreAffinityTypeSoft = 1, + kLiteRtQualcommLpaiCoreAffinityTypeHard = 2, +} LrtQualcommOptionsLpaiCoreAffinityType; + +LiteRtStatus LrtQualcommOptionsSetLpaiCoreAffinityType( + LrtQualcommOptions options, + LrtQualcommOptionsLpaiCoreAffinityType lpai_core_affinity_type); + +LiteRtStatus LrtQualcommOptionsGetLpaiCoreAffinityType( + LrtQualcommOptions options, + LrtQualcommOptionsLpaiCoreAffinityType* lpai_core_affinity_type); + +LiteRtStatus LrtQualcommOptionsSetLpaiCoreSelection( + LrtQualcommOptions options, uint32_t lpai_core_selection); + +LiteRtStatus LrtQualcommOptionsGetLpaiCoreSelection( + LrtQualcommOptions options, uint32_t* lpai_core_selection); + +// qnn_lib_dir + +// Sets the directory where CPU host QNN SDK shared libraries (libQnnSystem.so, +// libQnnHtp.so, etc.) are located. +// When set, this directory takes top priority when loading QNN host libraries. +// If not set (or if loading from this path fails), library loading falls back +// to the plugin directory (shared_library_dir), and finally to standard system +// dynamic loader search paths (preserving backward compatibility). +// Also acts as a fallback directory for configuring ADSP_LIBRARY_PATH if +// dsp_skel_dir is not explicitly set. +// The `qnn_lib_dir` string is copied into the `options` object, so the caller +// retains ownership of it and does not need to keep it alive. +LiteRtStatus LrtQualcommOptionsSetQnnLibDir(LrtQualcommOptions options, + const char* qnn_lib_dir); + +// Retrieves the configured CPU host QNN shared library directory. +// Returns an empty string if not set. +// The returned string pointer is owned by the `options` object. It remains +// valid until the value is overwritten by LrtQualcommOptionsSetQnnLibDir() or +// until `options` is destroyed, whichever comes first. Callers that need the +// value beyond that point must make their own copy. +LiteRtStatus LrtQualcommOptionsGetQnnLibDir(LrtQualcommOptions options, + const char** qnn_lib_dir); + +// dsp_skel_dir + +// Sets the directory where Hexagon DSP Skel shared libraries +// (libQnnHtpV*Skel.so) are located. Used to configure ADSP_LIBRARY_PATH for +// FastRPC. +// When set, this directory takes top priority for ADSP_LIBRARY_PATH. +// If not set, ADSP_LIBRARY_PATH falls back to qnn_lib_dir (if provided), and +// finally to the plugin directory (shared_library_dir), preserving backward +// compatibility. +// The `dsp_skel_dir` string is copied into the `options` object, so the caller +// retains ownership of it and does not need to keep it alive. +LiteRtStatus LrtQualcommOptionsSetDspSkelDir(LrtQualcommOptions options, + const char* dsp_skel_dir); + +// Retrieves the configured DSP Skel shared library directory. +// Returns an empty string if not set. +// The returned string pointer is owned by the `options` object. It remains +// valid until the value is overwritten by LrtQualcommOptionsSetDspSkelDir() or +// until `options` is destroyed, whichever comes first. Callers that need the +// value beyond that point must make their own copy. +LiteRtStatus LrtQualcommOptionsGetDspSkelDir(LrtQualcommOptions options, + const char** dsp_skel_dir); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_QUALCOMM_OPTIONS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_runtime_options.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_runtime_options.h new file mode 100644 index 0000000000000000000000000000000000000000..79da8da0ee7c73395713e4133cc04f76a2469a1f --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_runtime_options.h @@ -0,0 +1,119 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file defines the C API for LiteRt runtime options. +// It contains the following methods: +// - LrtCreateRuntimeOptions: Creates a concrete options object holding +// runtime options. +// - LrtDestroyRuntimeOptions: Destroys a created runtime options object. +// - LrtCreateOpaqueRuntimeOptions: Creates an opaque options object +// holding +// serialized options. +// - LrtGetRuntimeOptionsIdentifier: Gets the identifier for Runtime +// options stored in opaque options. +// Example usage: +// LrtRuntimeOptions* options = nullptr; +// LITERT_ASSERT_OK(LrtCreateRuntimeOptions(&options)); +// LITERT_ASSERT_OK(LrtSetRuntimeOptionsEnableProfiling(options, true); +// LiteRtOpaqueOptions opaque_options = nullptr; +// LITERT_ASSERT_OK(LrtCreateOpaqueRuntimeOptions(options, +// &opaque_options)); +// LrtDestroyRuntimeOptions(options); + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_RUNTIME_OPTIONS_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_RUNTIME_OPTIONS_H_ + +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +#include +#include + +extern "C" { +#endif + +typedef struct LrtRuntimeOptions LrtRuntimeOptions; + +// Creates a runtime options object. +// The caller is responsible for freeing the returned options using +// `LrtDestroyRuntimeOptions`. +LiteRtStatus LrtCreateRuntimeOptions(LrtRuntimeOptions** options); + +// Destroys a runtime options object. +void LrtDestroyRuntimeOptions(LrtRuntimeOptions* options); + +// Serializes runtime options and returns the components needed to create opaque +// options. The caller is responsible for passing these to +// `LiteRtCreateOpaqueOptions` and freeing the returned payload using +// `payload_deleter`. +LiteRtStatus LrtGetOpaqueRuntimeOptionsData(const LrtRuntimeOptions* options, + const char** identifier, + void** payload, + void (**payload_deleter)(void*)); + +// Gets the identifier for Runtime options stored in opaque options. +const char* LrtGetRuntimeOptionsIdentifier(); + +// Sets the profiling flag in runtime options. +LiteRtStatus LrtSetRuntimeOptionsEnableProfiling(LrtRuntimeOptions* options, + bool enable_profiling); + +// Gets the profiling flag from runtime options. +LiteRtStatus LrtGetRuntimeOptionsEnableProfiling( + const LrtRuntimeOptions* options, bool* enable_profiling); + +// Sets the error reporter mode in runtime options. +LiteRtStatus LrtSetRuntimeOptionsErrorReporterMode( + LrtRuntimeOptions* options, LiteRtErrorReporterMode error_reporter_mode); + +// Gets the error reporter mode from runtime options. +LiteRtStatus LrtGetRuntimeOptionsErrorReporterMode( + const LrtRuntimeOptions* options, + LiteRtErrorReporterMode* error_reporter_mode); + +// Sets whether to compress per-channel quantization zero-points when all +// zero-points are identical. +LiteRtStatus LrtSetRuntimeOptionsCompressQuantizationZeroPoints( + LrtRuntimeOptions* options, bool compress_zero_points); + +// Gets whether per-channel quantization zero-points compression is enabled. +LiteRtStatus LrtGetRuntimeOptionsCompressQuantizationZeroPoints( + const LrtRuntimeOptions* options, bool* compress_zero_points); + +// Sets whether to disable delegate clustering. +LiteRtStatus LrtSetRuntimeOptionsDisableDelegateClustering( + LrtRuntimeOptions* options, bool disable_delegate_clustering); + +// Gets whether delegate clustering is disabled. +LiteRtStatus LrtGetRuntimeOptionsDisableDelegateClustering( + const LrtRuntimeOptions* options, bool* disable_delegate_clustering); + +#ifdef __cplusplus +// Sets the TFLite model signatures that compiled models created with these +// options prepare for execution. The selected keys identify root subgraphs. +// When applying NPU compiler plugins, selection also prunes unused signatures +// and unreachable graphs before serialization where graph references can be +// safely remapped. Already compiled models keep their stored graph structure. +// +// Validates that options is non-null, keys is non-empty, each key is non-empty, +// and all keys are unique. The strings are copied. +LiteRtStatus LrtSetRuntimeOptionsSelectedSignatures( + LrtRuntimeOptions* options, const std::vector& keys); +#endif // __cplusplus + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_RUNTIME_OPTIONS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_samsung_options.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_samsung_options.h new file mode 100644 index 0000000000000000000000000000000000000000..c67fc60d7654bbdf056e7ea9048129131135d98d --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_samsung_options.h @@ -0,0 +1,65 @@ +// Copyright 2026 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ODML_LITERT_LITERT_C_OPTIONS_LITERT_SAMSUNG_OPTIONS_H_ +#define ODML_LITERT_LITERT_C_OPTIONS_LITERT_SAMSUNG_OPTIONS_H_ + +#include "litert/c/litert_common.h" + +// C-API for an opaque options type relevant to Samsung (both dspatch and +// plugin). +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +LITERT_DEFINE_HANDLE(LrtSamsungOptions); + +// The string identifier that discriminates samsung options. +const char* LrtSamsungOptionsGetIdentifier(); + +// Create a samsung options object. +LiteRtStatus LrtCreateSamsungOptions(LrtSamsungOptions* options); + +#ifdef __cplusplus +// Create a qualcomm options object mapped from a TOML payload. +LiteRtStatus LrtCreateSamsungOptionsFromToml(const char* toml_payload, + LrtSamsungOptions* options); +#endif // __cplusplus + +// Destroy a samsung options object. +void LrtDestroySamsungOptions(LrtSamsungOptions options); + +LiteRtStatus LrtGetOpaqueSamsungOptionsData(LrtSamsungOptions options, + const char** identifier, + void** payload, + void (**payload_deleter)(void*)); + +// COMPILATION OPTIONS //////////////////////////////////////////////////////// + +LiteRtStatus LrtSamsungOptionsSetEnableLargeModelSupport( + LrtSamsungOptions options, bool enable_large_model_support); + +LiteRtStatus LrtSamsungOptionsGetEnableLargeModelSupport( + LrtSamsungOptions options, bool* enable_large_model_support); + +LiteRtStatus LrtSamsungOptionsSetSocModel(LrtSamsungOptions options, + const char* soc_model); + +LiteRtStatus LrtSamsungOptionsGetSocModel(LrtSamsungOptions options, + const char** soc_model); +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ODML_LITERT_LITERT_C_OPTIONS_LITERT_SAMSUNG_OPTIONS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_webnn_options.h b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_webnn_options.h new file mode 100644 index 0000000000000000000000000000000000000000..893291f14a1a7fd00218a2b3b57ee04338a0b90f --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/include/litert/c/options/litert_webnn_options.h @@ -0,0 +1,102 @@ +// Copyright 2025 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_WEBNN_OPTIONS_H_ +#define THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_WEBNN_OPTIONS_H_ + +#include "litert/c/litert_common.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Maps to third_party/tflite_webnn_delegate/src/delegate_options.h. +typedef enum { + // The CPU device type. + kLiteRtWebNnDeviceTypeCpu = 0, + // The GPU device type. + kLiteRtWebNnDeviceTypeGpu = 1, + // The NPU device type. + kLiteRtWebNnDeviceTypeNpu = 2, +} LiteRtWebNnDeviceType; + +typedef enum { + // The default power preference. + kLiteRtWebNnPowerPreferenceDefault = 0, + // The high performance power preference. + kLiteRtWebNnPowerPreferenceHighPerformance = 1, + // The low power power preference. + kLiteRtWebNnPowerPreferenceLowPower = 2, +} LiteRtWebNnPowerPreference; + +typedef enum { + // The FP32 precision. + kLiteRtWebNnPrecisionFp32 = 0, + // The FP16 precision. + kLiteRtWebNnPrecisionFp16 = 1, +} LiteRtWebNnPrecision; + +typedef struct LrtWebNnOptions LrtWebNnOptions; + +// Creates a WebNN options object. +// The caller is responsible for freeing the returned options using +// `LrtDestroyWebNnOptions`. +LiteRtStatus LrtCreateWebNnOptions(LrtWebNnOptions** options); + +// Destroys a WebNN options object. +void LrtDestroyWebNnOptions(LrtWebNnOptions* options); + +// Serializes WebNN options and returns the components needed to create opaque +// options. The caller is responsible for passing these to +// `LiteRtCreateOpaqueOptions` and freeing the returned payload using +// `payload_deleter`. +LiteRtStatus LrtGetOpaqueWebNnOptionsData(const LrtWebNnOptions* options, + const char** identifier, + void** payload, + void (**payload_deleter)(void*)); + +// Deserializes the given TOML string into an opaque options object. +LiteRtStatus LrtCreateWebNnOptionsFromToml(const char* toml_string, + LrtWebNnOptions** options); + +// Sets the device type for WebNN. +LiteRtStatus LrtSetWebNnOptionsDevicePreference( + LrtWebNnOptions* options, LiteRtWebNnDeviceType device_type); + +// Gets the device type for WebNN. +LiteRtStatus LrtGetWebNnOptionsDevicePreference( + const LrtWebNnOptions* options, LiteRtWebNnDeviceType* device_type); + +// Sets the power preference for WebNN. +LiteRtStatus LrtSetWebNnOptionsPowerPreference( + LrtWebNnOptions* options, LiteRtWebNnPowerPreference power_preference); + +// Gets the power preference for WebNN. +LiteRtStatus LrtGetWebNnOptionsPowerPreference( + const LrtWebNnOptions* options, + LiteRtWebNnPowerPreference* power_preference); + +// Sets the precision for WebNN. +LiteRtStatus LrtSetWebNnOptionsPrecision(LrtWebNnOptions* options, + LiteRtWebNnPrecision precision); + +// Gets the precision for WebNN. +LiteRtStatus LrtGetWebNnOptionsPrecision(const LrtWebNnOptions* options, + LiteRtWebNnPrecision* precision); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // THIRD_PARTY_ODML_LITERT_LITERT_C_OPTIONS_LITERT_WEBNN_OPTIONS_H_ diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/libLiteRt.so b/sm8850-npu-fp16/vendor/litert/2.3.1/libLiteRt.so new file mode 100644 index 0000000000000000000000000000000000000000..31d35401746a2e7e5c130fe2c4276311fc1a33e6 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/libLiteRt.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9ad1a5072b09087bddeb3d7be22854350191b21239136b78ebee2120443c7305 +size 5475936 diff --git a/sm8850-npu-fp16/vendor/litert/2.3.1/libLiteRtDispatch_Qualcomm.so b/sm8850-npu-fp16/vendor/litert/2.3.1/libLiteRtDispatch_Qualcomm.so new file mode 100644 index 0000000000000000000000000000000000000000..fcc0062c3c57104d574bb2629f04ea4f9e12ce58 --- /dev/null +++ b/sm8850-npu-fp16/vendor/litert/2.3.1/libLiteRtDispatch_Qualcomm.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab6a581ef26d83f60d03ff4ce2436d9a75b7d0c0b276357787a865e5e9dd4b7d +size 445712