msluszniak commited on
Commit
177f558
·
verified ·
1 Parent(s): 57fbfd8

Core ML: drop fp32, fp16 is equivalent in use

Browse files

fp16 and fp32 were kept side by side pending review; they are indistinguishable in use (93.4% (s) and 93.9% (x) by a segmentation-shaped metric; confirmed visually identical on device), and fp32 is both slower and twice the size while being structurally unable to run on the ANE.

The config is republished alongside. For ssdlite320 this also corrects the declared input shape: the published config said [1,3,320,320] while the model accepts [3,320,320], so set_inputs failed against its own contract.

v0.9.0 and below are untouched.

s/coreml/config.json CHANGED
@@ -1,20 +1,18 @@
1
  {
2
  "$schema": "https://huggingface.co/software-mansion/react-native-executorch-spec/resolve/main/config.schema.json",
3
- "model": "fast_sam",
4
- "family": "sam",
5
- "size": "s",
6
  "capabilities": [
7
  "instance-segmentation"
8
  ],
9
  "backend": "coreml",
10
- "license": "apache-2.0",
11
  "variants": [
12
  {
13
  "file": "fast_sam_s_coreml_fp16.pte",
14
  "precision": "fp16",
15
  "quantized": false,
16
  "default": true,
17
- "size": "s",
18
  "methods": {
19
  "forward": {
20
  "inputs": [
@@ -31,7 +29,6 @@
31
  "outputs": [
32
  {
33
  "shape": [
34
- 1,
35
  300,
36
  4
37
  ],
@@ -39,65 +36,19 @@
39
  },
40
  {
41
  "shape": [
42
- 1,
43
- 300,
44
- 32
45
  ],
46
  "dtype": "float32"
47
  },
48
  {
49
  "shape": [
50
- 1,
51
- 32,
52
- 160,
53
- 160
54
- ],
55
- "dtype": "float32"
56
- }
57
- ]
58
- }
59
- }
60
- },
61
- {
62
- "file": "fast_sam_s_coreml_fp32.pte",
63
- "precision": "fp32",
64
- "quantized": false,
65
- "default": false,
66
- "size": "s",
67
- "methods": {
68
- "forward": {
69
- "inputs": [
70
- {
71
- "shape": [
72
- 1,
73
- 3,
74
- 640,
75
- 640
76
- ],
77
- "dtype": "float32"
78
- }
79
- ],
80
- "outputs": [
81
- {
82
- "shape": [
83
- 1,
84
- 300,
85
- 4
86
  ],
87
  "dtype": "float32"
88
  },
89
  {
90
  "shape": [
91
- 1,
92
  300,
93
- 32
94
- ],
95
- "dtype": "float32"
96
- },
97
- {
98
- "shape": [
99
- 1,
100
- 32,
101
  160,
102
  160
103
  ],
@@ -108,4 +59,4 @@
108
  }
109
  }
110
  ]
111
- }
 
1
  {
2
  "$schema": "https://huggingface.co/software-mansion/react-native-executorch-spec/resolve/main/config.schema.json",
3
+ "model": "fast_sam_s",
4
+ "family": "fastsam",
 
5
  "capabilities": [
6
  "instance-segmentation"
7
  ],
8
  "backend": "coreml",
9
+ "license": "agpl-3.0",
10
  "variants": [
11
  {
12
  "file": "fast_sam_s_coreml_fp16.pte",
13
  "precision": "fp16",
14
  "quantized": false,
15
  "default": true,
 
16
  "methods": {
17
  "forward": {
18
  "inputs": [
 
29
  "outputs": [
30
  {
31
  "shape": [
 
32
  300,
33
  4
34
  ],
 
36
  },
37
  {
38
  "shape": [
39
+ 300
 
 
40
  ],
41
  "dtype": "float32"
42
  },
43
  {
44
  "shape": [
45
+ 300
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  ],
47
  "dtype": "float32"
48
  },
49
  {
50
  "shape": [
 
51
  300,
 
 
 
 
 
 
 
 
52
  160,
53
  160
54
  ],
 
59
  }
60
  }
61
  ]
62
+ }
s/coreml/fast_sam_s_coreml_fp32.pte DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:eeb3f302e786aa2e6bed8b7fbc595dde129d8977d83050d50753bd51b3bd4153
3
- size 47792732
 
 
 
 
x/coreml/config.json CHANGED
@@ -1,20 +1,18 @@
1
  {
2
  "$schema": "https://huggingface.co/software-mansion/react-native-executorch-spec/resolve/main/config.schema.json",
3
- "model": "fast_sam",
4
- "family": "sam",
5
- "size": "x",
6
  "capabilities": [
7
  "instance-segmentation"
8
  ],
9
  "backend": "coreml",
10
- "license": "apache-2.0",
11
  "variants": [
12
  {
13
  "file": "fast_sam_x_coreml_fp16.pte",
14
  "precision": "fp16",
15
  "quantized": false,
16
  "default": true,
17
- "size": "x",
18
  "methods": {
19
  "forward": {
20
  "inputs": [
@@ -31,7 +29,6 @@
31
  "outputs": [
32
  {
33
  "shape": [
34
- 1,
35
  300,
36
  4
37
  ],
@@ -39,65 +36,19 @@
39
  },
40
  {
41
  "shape": [
42
- 1,
43
- 300,
44
- 32
45
  ],
46
  "dtype": "float32"
47
  },
48
  {
49
  "shape": [
50
- 1,
51
- 32,
52
- 160,
53
- 160
54
- ],
55
- "dtype": "float32"
56
- }
57
- ]
58
- }
59
- }
60
- },
61
- {
62
- "file": "fast_sam_x_coreml_fp32.pte",
63
- "precision": "fp32",
64
- "quantized": false,
65
- "default": false,
66
- "size": "x",
67
- "methods": {
68
- "forward": {
69
- "inputs": [
70
- {
71
- "shape": [
72
- 1,
73
- 3,
74
- 640,
75
- 640
76
- ],
77
- "dtype": "float32"
78
- }
79
- ],
80
- "outputs": [
81
- {
82
- "shape": [
83
- 1,
84
- 300,
85
- 4
86
  ],
87
  "dtype": "float32"
88
  },
89
  {
90
  "shape": [
91
- 1,
92
  300,
93
- 32
94
- ],
95
- "dtype": "float32"
96
- },
97
- {
98
- "shape": [
99
- 1,
100
- 32,
101
  160,
102
  160
103
  ],
@@ -108,4 +59,4 @@
108
  }
109
  }
110
  ]
111
- }
 
1
  {
2
  "$schema": "https://huggingface.co/software-mansion/react-native-executorch-spec/resolve/main/config.schema.json",
3
+ "model": "fast_sam_x",
4
+ "family": "fastsam",
 
5
  "capabilities": [
6
  "instance-segmentation"
7
  ],
8
  "backend": "coreml",
9
+ "license": "agpl-3.0",
10
  "variants": [
11
  {
12
  "file": "fast_sam_x_coreml_fp16.pte",
13
  "precision": "fp16",
14
  "quantized": false,
15
  "default": true,
 
16
  "methods": {
17
  "forward": {
18
  "inputs": [
 
29
  "outputs": [
30
  {
31
  "shape": [
 
32
  300,
33
  4
34
  ],
 
36
  },
37
  {
38
  "shape": [
39
+ 300
 
 
40
  ],
41
  "dtype": "float32"
42
  },
43
  {
44
  "shape": [
45
+ 300
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  ],
47
  "dtype": "float32"
48
  },
49
  {
50
  "shape": [
 
51
  300,
 
 
 
 
 
 
 
 
52
  160,
53
  160
54
  ],
 
59
  }
60
  }
61
  ]
62
+ }
x/coreml/fast_sam_x_coreml_fp32.pte DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:71e24a2f15c3de34e7af2eedb78f405aae3f314a71c6655ab924e9721d954c1e
3
- size 289720009