File size: 2,599 Bytes
2ac5d24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
license: apache-2.0
tags:
- executorch
- xnnpack
- pte
- on-device
- zero-shot-image-classification
base_model:
- google/siglip2-base-patch16-224
---
# siglip2_base_p16_image — ExecuTorch

- **Source**: google/siglip2-base-patch16-224
- **License**: Apache-2.0
- **Input**: [[1, 3, 224, 224]] — RGB scaled to [-1, 1] (mean .5, std .5), 224x224
- **Output**: image embedding [1,768] from the attention pooler (unnormalized; L2-normalize before cosine)

## Variants

All variants take and return fp32 tensors — swap the `.pte` file, keep your app code.

| build | file | size (MB) | parity vs fp32 eager (worst corr) | Mac median (ms)* |
|-----------|------|-----------|------------------------------------|------------------|
| fp32 | `siglip2_base_p16_image_xnnpack_fp32.pte` | 371.7 | 0.999994 | 195.6 |
| fp16 | `siglip2_base_p16_image_xnnpack_fp16.pte` | 187.3 | 0.999986 | 227.8 |
| Core ML (fp16, iOS) | `siglip2_base_p16_image_coreml_all.pte` | 185.1 | 0.999806 | 4.4 |


The Core ML build is the same graph lowered to Apple's Neural Engine instead of
XNNPACK, which is CPU-only. Measured on an iPhone 17 Pro across seven models, it
runs **3.5x to 13.9x faster (median 12x)** at roughly half the file size — for
example Depth-Anything-V2-Small at 500.8 ms against 42.7 ms, and MODNet at 81.7 ms
against 5.9 ms. It computes in fp16 and is iOS-only; the XNNPACK files stay the
portable option and are what runs on Android.

\*Mac arm64, single process, median of 10 — a reference point for relative cost
only, not a device number (torch eager fp32 on the same machine: 34.4 ms).

## Verification (executorch 1.4.0, torch 2.13.0)

Parity is measured against the fp32 eager model on real image input; `corr` is
the correlation over all elements of each output tensor.

| output | shape | max_abs_diff | corr |
|--------|-------|--------------|------|
| 0 | [1, 768] | 1.195e-02 | 0.999994 |

XNNPACK delegate coverage (fp32): 68.6% (395/576 ops); ops left on the portable kernels: `aten.expand_copy.default` x48, `aten.native_layer_norm.default` x26, `aten.mul.Scalar` x24, `aten.logical_not.default` x24, `aten.eq.Scalar` x12, `aten.full_like.default` x12, `aten.any.dim` x12, `aten.where.self` x12, `aten.select_copy.int` x3, `aten.split_with_sizes_copy.default` x2, `aten.addmm.default` x2, `aten.repeat.default` x1, `aten.embedding.default` x1, `aten.unsqueeze_copy.default` x1, `aten.squeeze_copy.dims` x1

## Conversion

torch.export -> to_edge_transform_and_lower(partitioner) -> .pte
(conversion scripts: [executorch-models](https://github.com/john-rocky/executorch-models))