Image Classification
LiteRT
LiteRT
vit
vision
snnn001 commited on
Commit
35989ed
·
1 Parent(s): 5e5bb13

Update NPU and OpenCL GPU benchmark numbers in README.md

Browse files
Files changed (1) hide show
  1. README.md +47 -35
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 three 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,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, INT8 weights and
 
46
  INT64 biases. CPU fallback can be slow, and the tested LiteRT GPU IR importer
47
- does not support its INT16 quantization.
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
- **Mixed A8W8** keeps asymmetric INT8 fully connected inputs/outputs and INT32
99
- biases, with INT16 attention, residual and LayerNorm boundaries. Both retain
100
- the same INT8 weight codes and scales; activation scales are per-tensor.
 
 
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 devices to give a rough
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 millisecond. Each
164
- value is the median of three process means, with five warmup invocations and
165
- 30 measured invocations per process. All configurations are AOT compiled and
166
- fully delegated to the NPU, with no residual CPU operations.
167
-
168
- | Model file | `SM-S937U1`(ms) | `LJ9`(ms) |
169
- | --- | ---: | ---: |
170
- | `model_fp32.tflite` | 6 | 129 |
171
- | `model_a16w8.tflite` | 4 | 71 |
172
- | `model_a8w8.tflite` | 10 | 52 |
173
-
174
- FP32 identifies the source model. Qualcomm compiles it to FP16-based NPU
175
- execution, and MediaTek enables FP32-to-FP16 relaxation. The floating-source
176
- timings therefore do not imply FP32 arithmetic throughout the NPU program.
 
 
 
 
 
 
 
 
 
 
177
 
178
  Measurements use LiteRT's compiled-model benchmark with persistent buffers
179
- and deterministic random input. They exclude model initialization, image
 
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-S937U1` ran Android 17 with Qualcomm QNN/QAIRT 2.50 in burst performance
185
- mode. The LJ9 ran Android 15 with the MediaTek Neuron runtime in sustained
186
- speed mode. Power settings were not normalized, and energy consumption was
187
- not measured. These results apply to the listed device/compiler/runtime
188
- combinations and do not characterize JIT performance.
189
 
190
  **Hardware benchmark disclosure:** Results were measured by us on retail
191
- devices purchased through normal channels. These results are not affiliated
192
- with, sponsored by, endorsed by, or verified by Samsung, TECNO, vivo, Qualcomm,
193
- MediaTek, Google, MLCommons, or Hugging Face. Results depend on device SKU,
194
- OS build, thermal state, battery mode, backend, model quantization, runtime
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