Instructions to use litert-community/vit-base-patch16-224 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/vit-base-patch16-224 with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Update NPU and OpenCL GPU benchmark numbers in README.md
Browse files
README.md
CHANGED
|
@@ -20,7 +20,7 @@ LiteRT/TFLite variants of
|
|
| 20 |
pinned to source revision `3f49326eb077187dfe1c2a2bb15fbd74e6ab91e3`.
|
| 21 |
|
| 22 |
The package provides FP32, A16W8 and mixed A8W8 models for image classification.
|
| 23 |
-
All
|
| 24 |
The `.tflite` files are portable source artifacts for target-specific NPU
|
| 25 |
compilation; they do not contain device-specific compiled NPU programs.
|
| 26 |
|
|
@@ -30,6 +30,7 @@ compilation; they do not contain device-specific compiled NPU programs.
|
|
| 30 |
| --- | --- |
|
| 31 |
| `model_fp32.tflite` | Floating-point reference with FP32 weights. |
|
| 32 |
| `model_a16w8.tflite` | INT16 transformer activations and INT8 fully connected weights; the primary quantized option for compatible NPUs. |
|
|
|
|
| 33 |
| `model_a8w8.tflite` | Experimental mixed precision: INT8 fully connected layers with INT16 attention, residual and LayerNorm boundaries. |
|
| 34 |
| `config.json` | Original source configuration and class mapping. |
|
| 35 |
| `preprocessor_config.json` | Source image preprocessing configuration. |
|
|
@@ -42,9 +43,10 @@ compilation; they do not contain device-specific compiled NPU programs.
|
|
| 42 |
|
| 43 |
- **FP32** provides the floating-point reference and is the example's default.
|
| 44 |
- **A16W8** offers the best observed accuracy/speed balance on the tested NPUs.
|
| 45 |
-
Its fully connected layers use INT16 inputs and outputs
|
|
|
|
| 46 |
INT64 biases. CPU fallback can be slow, and the tested LiteRT GPU IR importer
|
| 47 |
-
does not support its
|
| 48 |
- **Mixed A8W8** is retained as a reference that may suit devices limited to
|
| 49 |
32-bit integer accumulation in their fully connected kernels. It has a
|
| 50 |
substantial accuracy tradeoff and retains INT16 regions, so backend support
|
|
@@ -94,10 +96,12 @@ config = Int8StaticActivationInt8WeightConfig(
|
|
| 94 |
|
| 95 |
The final TFLite export also needs calibrated linear-output and transformer
|
| 96 |
activation ranges, collected using the same 500 images. **A16W8** uses symmetric
|
| 97 |
-
INT16 activations with zero point zero and INT64 fully connected biases
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
|
|
|
|
|
|
| 101 |
|
| 102 |
The transformer graphs keep activations quantized across attention, residual,
|
| 103 |
reshape, transpose, softmax and GELU operations. LayerNorm uses composite
|
|
@@ -154,45 +158,53 @@ repeated after this metadata cleanup.
|
|
| 154 |
|
| 155 |
## NPU performance
|
| 156 |
|
| 157 |
-
These are representative measurements from retail
|
| 158 |
sense of on-device runtime behavior, not a direct comparison between hardware
|
| 159 |
platforms. All latency numbers were collected with LiteRT's compiled-model
|
| 160 |
`benchmark_model` launched through `adb shell` on the connected device; they
|
| 161 |
are not app-level measurements from an integrated Android application.
|
| 162 |
|
| 163 |
-
Warm batch-one inference latency, rounded to the nearest
|
| 164 |
-
value is the median of three process means, with five warmup
|
| 165 |
-
30 measured invocations per process. All configurations are
|
| 166 |
-
fully delegated
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
|
| 170 |
-
|
|
| 171 |
-
| `
|
| 172 |
-
| `
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
|
| 178 |
Measurements use LiteRT's compiled-model benchmark with persistent buffers
|
| 179 |
-
and deterministic random input
|
|
|
|
| 180 |
preprocessing, file I/O and explicit host input/output buffer transfers.
|
| 181 |
-
Some variants were measured in separate sessions using the same benchmark
|
| 182 |
-
and dispatch runtime for each device.
|
| 183 |
|
| 184 |
-
The `SM-
|
| 185 |
-
mode
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
combinations and do not characterize JIT
|
| 189 |
|
| 190 |
**Hardware benchmark disclosure:** Results were measured by us on retail
|
| 191 |
-
devices
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
version, and benchmark settings.
|
| 196 |
|
| 197 |
## Input and output
|
| 198 |
|
|
|
|
| 20 |
pinned to source revision `3f49326eb077187dfe1c2a2bb15fbd74e6ab91e3`.
|
| 21 |
|
| 22 |
The package provides FP32, A16W8 and mixed A8W8 models for image classification.
|
| 23 |
+
All have FP32 input and output and require external image preprocessing.
|
| 24 |
The `.tflite` files are portable source artifacts for target-specific NPU
|
| 25 |
compilation; they do not contain device-specific compiled NPU programs.
|
| 26 |
|
|
|
|
| 30 |
| --- | --- |
|
| 31 |
| `model_fp32.tflite` | Floating-point reference with FP32 weights. |
|
| 32 |
| `model_a16w8.tflite` | INT16 transformer activations and INT8 fully connected weights; the primary quantized option for compatible NPUs. |
|
| 33 |
+
| `model_a16w8_qualcomm.tflite` | Dedicated Qualcomm NPU compilation input for A16W8 using UINT16 transformer activations and LayerNorm interfaces. |
|
| 34 |
| `model_a8w8.tflite` | Experimental mixed precision: INT8 fully connected layers with INT16 attention, residual and LayerNorm boundaries. |
|
| 35 |
| `config.json` | Original source configuration and class mapping. |
|
| 36 |
| `preprocessor_config.json` | Source image preprocessing configuration. |
|
|
|
|
| 43 |
|
| 44 |
- **FP32** provides the floating-point reference and is the example's default.
|
| 45 |
- **A16W8** offers the best observed accuracy/speed balance on the tested NPUs.
|
| 46 |
+
Its fully connected layers use INT16 inputs and outputs (or UINT16 in
|
| 47 |
+
`model_a16w8_qualcomm.tflite` for Qualcomm HTP compilation), INT8 weights and
|
| 48 |
INT64 biases. CPU fallback can be slow, and the tested LiteRT GPU IR importer
|
| 49 |
+
does not support its 16-bit integer quantization.
|
| 50 |
- **Mixed A8W8** is retained as a reference that may suit devices limited to
|
| 51 |
32-bit integer accumulation in their fully connected kernels. It has a
|
| 52 |
substantial accuracy tradeoff and retains INT16 regions, so backend support
|
|
|
|
| 96 |
|
| 97 |
The final TFLite export also needs calibrated linear-output and transformer
|
| 98 |
activation ranges, collected using the same 500 images. **A16W8** uses symmetric
|
| 99 |
+
INT16 activations with zero point zero and INT64 fully connected biases (and
|
| 100 |
+
`model_a16w8_qualcomm.tflite` provides the corresponding UINT16 export for
|
| 101 |
+
Qualcomm NPU compilation). **Mixed A8W8** keeps asymmetric INT8 fully connected
|
| 102 |
+
inputs/outputs and INT32 biases, with INT16 attention, residual and LayerNorm
|
| 103 |
+
boundaries. Both retain the same INT8 weight codes and scales; activation scales
|
| 104 |
+
are per-tensor.
|
| 105 |
|
| 106 |
The transformer graphs keep activations quantized across attention, residual,
|
| 107 |
reshape, transpose, softmax and GELU operations. LayerNorm uses composite
|
|
|
|
| 158 |
|
| 159 |
## NPU performance
|
| 160 |
|
| 161 |
+
These are representative measurements from a retail device to give a rough
|
| 162 |
sense of on-device runtime behavior, not a direct comparison between hardware
|
| 163 |
platforms. All latency numbers were collected with LiteRT's compiled-model
|
| 164 |
`benchmark_model` launched through `adb shell` on the connected device; they
|
| 165 |
are not app-level measurements from an integrated Android application.
|
| 166 |
|
| 167 |
+
Warm batch-one inference latency, rounded to the nearest tenth of a
|
| 168 |
+
millisecond. Each value is the median of three process means, with five warmup
|
| 169 |
+
invocations and 30 measured invocations per process. All configurations are
|
| 170 |
+
fully delegated in a single partition with no residual CPU operations (AOT
|
| 171 |
+
compiled for NPU, and pre-warmed OpenCL program cache for GPU).
|
| 172 |
+
|
| 173 |
+
| Model file | Backend / precision | `SM-S937U` (ms) |
|
| 174 |
+
| --- | --- | ---: |
|
| 175 |
+
| `model_fp32.tflite` | LiteRT GPU (MLDrift OpenCL, FP32) | 23.7 |
|
| 176 |
+
| `model_fp32.tflite` | LiteRT GPU (MLDrift OpenCL, FP16) | 12.8 |
|
| 177 |
+
| `model_fp32.tflite` | Qualcomm NPU (HTP, FP16) | 3.4 |
|
| 178 |
+
| `model_a16w8_qualcomm.tflite` | Qualcomm NPU (HTP, A16W8) | 2.5 |
|
| 179 |
+
|
| 180 |
+
On `SM-S937U`, Qualcomm NPU execution is **3.8× faster** than MLDrift OpenCL
|
| 181 |
+
GPU at matching FP16 precision (`3.4 ms` vs `12.8 ms`), and **5.0× faster**
|
| 182 |
+
with `A16W8` quantization (`2.5 ms` vs `12.8 ms`; **9.3× faster** than FP32
|
| 183 |
+
OpenCL GPU at `23.7 ms`).
|
| 184 |
+
|
| 185 |
+
FP32 identifies the source model, which Qualcomm compiles to FP16-based NPU
|
| 186 |
+
execution. The floating-source NPU timing therefore does not imply FP32
|
| 187 |
+
arithmetic throughout the NPU program. `model_a16w8_qualcomm.tflite` is the
|
| 188 |
+
dedicated UINT16 compilation input corresponding to `model_a16w8.tflite`. Mixed
|
| 189 |
+
A8W8 is omitted because a Qualcomm-specific UINT16 A8W8 compilation input is
|
| 190 |
+
not published in this package.
|
| 191 |
|
| 192 |
Measurements use LiteRT's compiled-model benchmark with persistent buffers
|
| 193 |
+
and deterministic random input (`clFinish()` synchronized per iteration on
|
| 194 |
+
OpenCL GPU). They exclude model initialization, shader/graph compilation, image
|
| 195 |
preprocessing, file I/O and explicit host input/output buffer transfers.
|
|
|
|
|
|
|
| 196 |
|
| 197 |
+
The `SM-S937U` ran Android 16 with Qualcomm QNN/QAIRT 2.52 in burst performance
|
| 198 |
+
mode (`O3` optimization) for NPU and LiteRT's MLDrift OpenCL backend on Adreno
|
| 199 |
+
for GPU. Power settings were not normalized, and energy consumption was not
|
| 200 |
+
measured. These results apply to the listed device/compiler/runtime
|
| 201 |
+
combinations and do not characterize JIT initialization latency.
|
| 202 |
|
| 203 |
**Hardware benchmark disclosure:** Results were measured by us on retail
|
| 204 |
+
devices. These results are not affiliated with, sponsored by, endorsed by, or
|
| 205 |
+
verified by Samsung, TECNO, Qualcomm, MediaTek, Google, MLCommons, or Hugging
|
| 206 |
+
Face. Results depend on device SKU, OS build, thermal state, battery mode,
|
| 207 |
+
backend, model quantization, runtime version, and benchmark settings.
|
|
|
|
| 208 |
|
| 209 |
## Input and output
|
| 210 |
|