Commit 65e793b
Android: unified error reporting — all sync errors throw, no silent failures
Replace the mixed error-reporting pattern (int return codes, empty arrays,
silent no-ops) with a consistent exception-based contract across Module,
LlmModule, and LlmCallback:
- Module: all public methods acquire mLock and check destroyed state;
loadMethod() throws ExecutorchRuntimeException on native error;
execute()/forward() throw IllegalStateException on destroyed module;
destroy() throws if lock unavailable (concurrent execution)
- LlmModule: all generate/load/prefill methods check destroyed state
via volatile flag and throw on native errors; resetNative() deprecated
in favor of future close(); stop() intentionally unguarded for
interrupt-during-generate; prefill methods return void instead of long
- LlmCallback: onError() default logs via android.util.Log with
try/catch fallback for JVM unit test environments
- ExecutorchRuntimeException: added ALREADY_LOADED (0x04) error code,
javadoc on all 19 error codes, "ExecuTorch" casing in error messages
- JNI: renamed registrations to match Java native method names
(generateNative, loadNative, resetContextNative); removed double
exception throw from C++ load(); unknown input typeCode now throws
- Tests: updated for void returns and assertThrows; all @ignore preserved
- Benchmark: ModelRunner and LlmModelRunner adapted to try/catch pattern
Breaking change under @experimental — all APIs are still experimental.
Co-authored-by: Claude <noreply@anthropic.com>1 parent 60d57e5 commit 65e793b
File tree
10 files changed
+252
-120
lines changed- extension
- android
- executorch_android/src
- androidTest/java/org/pytorch/executorch
- main/java/org/pytorch/executorch
- extension/llm
- jni
- benchmark/android/benchmark/app/src/main/java/org/pytorch/minibench
10 files changed
+252
-120
lines changedLines changed: 1 addition & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | | - | |
59 | | - | |
| 57 | + | |
60 | 58 | | |
61 | 59 | | |
62 | 60 | | |
| |||
277 | 275 | | |
278 | 276 | | |
279 | 277 | | |
280 | | - | |
281 | 278 | | |
282 | 279 | | |
283 | 280 | | |
Lines changed: 6 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
| 69 | + | |
71 | 70 | | |
72 | 71 | | |
73 | 72 | | |
| |||
96 | 95 | | |
97 | 96 | | |
98 | 97 | | |
99 | | - | |
100 | | - | |
| 98 | + | |
101 | 99 | | |
102 | 100 | | |
103 | 101 | | |
104 | 102 | | |
105 | 103 | | |
106 | 104 | | |
107 | 105 | | |
108 | | - | |
109 | | - | |
| 106 | + | |
110 | 107 | | |
111 | 108 | | |
112 | 109 | | |
| |||
116 | 113 | | |
117 | 114 | | |
118 | 115 | | |
119 | | - | |
120 | | - | |
| 116 | + | |
121 | 117 | | |
122 | 118 | | |
123 | 119 | | |
124 | 120 | | |
125 | 121 | | |
126 | 122 | | |
127 | 123 | | |
128 | | - | |
129 | | - | |
| 124 | + | |
130 | 125 | | |
131 | 126 | | |
132 | 127 | | |
133 | | - | |
134 | | - | |
| 128 | + | |
135 | 129 | | |
136 | 130 | | |
137 | 131 | | |
| |||
175 | 169 | | |
176 | 170 | | |
177 | 171 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | 172 | | |
183 | 173 | | |
Lines changed: 53 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
15 | 20 | | |
16 | 21 | | |
| 22 | + | |
17 | 23 | | |
| 24 | + | |
| 25 | + | |
18 | 26 | | |
| 27 | + | |
| 28 | + | |
19 | 29 | | |
| 30 | + | |
| 31 | + | |
20 | 32 | | |
| 33 | + | |
| 34 | + | |
21 | 35 | | |
22 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
23 | 40 | | |
| 41 | + | |
| 42 | + | |
24 | 43 | | |
| 44 | + | |
| 45 | + | |
25 | 46 | | |
| 47 | + | |
| 48 | + | |
26 | 49 | | |
| 50 | + | |
| 51 | + | |
27 | 52 | | |
| 53 | + | |
| 54 | + | |
28 | 55 | | |
| 56 | + | |
| 57 | + | |
29 | 58 | | |
| 59 | + | |
| 60 | + | |
30 | 61 | | |
31 | 62 | | |
32 | 63 | | |
| 64 | + | |
| 65 | + | |
33 | 66 | | |
| 67 | + | |
| 68 | + | |
34 | 69 | | |
| 70 | + | |
| 71 | + | |
35 | 72 | | |
| 73 | + | |
| 74 | + | |
36 | 75 | | |
| 76 | + | |
| 77 | + | |
37 | 78 | | |
| 79 | + | |
| 80 | + | |
38 | 81 | | |
39 | 82 | | |
40 | 83 | | |
| 84 | + | |
| 85 | + | |
41 | 86 | | |
| 87 | + | |
| 88 | + | |
42 | 89 | | |
| 90 | + | |
| 91 | + | |
43 | 92 | | |
44 | 93 | | |
45 | 94 | | |
| |||
52 | 101 | | |
53 | 102 | | |
54 | 103 | | |
| 104 | + | |
55 | 105 | | |
56 | 106 | | |
57 | 107 | | |
| |||
83 | 133 | | |
84 | 134 | | |
85 | 135 | | |
86 | | - | |
| 136 | + | |
87 | 137 | | |
88 | 138 | | |
89 | 139 | | |
| |||
111 | 161 | | |
112 | 162 | | |
113 | 163 | | |
| 164 | + | |
114 | 165 | | |
115 | 166 | | |
116 | 167 | | |
117 | 168 | | |
| 169 | + | |
118 | 170 | | |
119 | 171 | | |
120 | 172 | | |
| |||
Lines changed: 57 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
130 | 129 | | |
131 | 130 | | |
132 | 131 | | |
| 132 | + | |
133 | 133 | | |
134 | | - | |
135 | 134 | | |
136 | | - | |
137 | | - | |
| 135 | + | |
138 | 136 | | |
139 | 137 | | |
140 | 138 | | |
| |||
151 | 149 | | |
152 | 150 | | |
153 | 151 | | |
154 | | - | |
155 | | - | |
156 | 152 | | |
157 | | - | |
| 153 | + | |
| 154 | + | |
158 | 155 | | |
159 | | - | |
160 | 156 | | |
161 | | - | |
162 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
163 | 162 | | |
164 | | - | |
165 | 163 | | |
166 | 164 | | |
167 | 165 | | |
| |||
184 | 182 | | |
185 | 183 | | |
186 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
187 | 197 | | |
188 | | - | |
| 198 | + | |
189 | 199 | | |
190 | 200 | | |
191 | 201 | | |
| |||
194 | 204 | | |
195 | 205 | | |
196 | 206 | | |
197 | | - | |
198 | | - | |
199 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
200 | 219 | | |
201 | | - | |
202 | 220 | | |
203 | 221 | | |
204 | 222 | | |
| |||
210 | 228 | | |
211 | 229 | | |
212 | 230 | | |
213 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
214 | 240 | | |
215 | 241 | | |
216 | 242 | | |
| |||
224 | 250 | | |
225 | 251 | | |
226 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
227 | 265 | | |
228 | | - | |
| 266 | + | |
229 | 267 | | |
230 | 268 | | |
231 | 269 | | |
| |||
241 | 279 | | |
242 | 280 | | |
243 | 281 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
| 282 | + | |
248 | 283 | | |
249 | 284 | | |
250 | 285 | | |
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
50 | 56 | | |
0 commit comments