Commit 2b96224
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 2b96224
File tree
10 files changed
+234
-118
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
+234
-118
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: 36 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 | + | |
19 | 28 | | |
| 29 | + | |
20 | 30 | | |
| 31 | + | |
21 | 32 | | |
| 33 | + | |
| 34 | + | |
22 | 35 | | |
23 | 36 | | |
| 37 | + | |
| 38 | + | |
24 | 39 | | |
| 40 | + | |
25 | 41 | | |
| 42 | + | |
26 | 43 | | |
| 44 | + | |
27 | 45 | | |
| 46 | + | |
28 | 47 | | |
| 48 | + | |
29 | 49 | | |
| 50 | + | |
30 | 51 | | |
31 | 52 | | |
32 | 53 | | |
| 54 | + | |
| 55 | + | |
33 | 56 | | |
| 57 | + | |
34 | 58 | | |
| 59 | + | |
35 | 60 | | |
| 61 | + | |
36 | 62 | | |
| 63 | + | |
37 | 64 | | |
| 65 | + | |
38 | 66 | | |
39 | 67 | | |
40 | 68 | | |
| 69 | + | |
| 70 | + | |
41 | 71 | | |
| 72 | + | |
42 | 73 | | |
| 74 | + | |
43 | 75 | | |
44 | 76 | | |
45 | 77 | | |
| |||
52 | 84 | | |
53 | 85 | | |
54 | 86 | | |
| 87 | + | |
55 | 88 | | |
56 | 89 | | |
57 | 90 | | |
| |||
83 | 116 | | |
84 | 117 | | |
85 | 118 | | |
86 | | - | |
| 119 | + | |
87 | 120 | | |
88 | 121 | | |
89 | 122 | | |
| |||
111 | 144 | | |
112 | 145 | | |
113 | 146 | | |
| 147 | + | |
114 | 148 | | |
115 | 149 | | |
116 | 150 | | |
117 | 151 | | |
| 152 | + | |
118 | 153 | | |
119 | 154 | | |
120 | 155 | | |
| |||
Lines changed: 57 additions & 21 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 | | |
| |||
152 | 150 | | |
153 | 151 | | |
154 | 152 | | |
155 | | - | |
156 | 153 | | |
157 | | - | |
| 154 | + | |
| 155 | + | |
158 | 156 | | |
159 | | - | |
160 | 157 | | |
161 | | - | |
162 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
163 | 163 | | |
164 | | - | |
165 | 164 | | |
166 | 165 | | |
167 | 166 | | |
| |||
184 | 183 | | |
185 | 184 | | |
186 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
187 | 198 | | |
188 | | - | |
| 199 | + | |
189 | 200 | | |
190 | 201 | | |
191 | 202 | | |
| |||
194 | 205 | | |
195 | 206 | | |
196 | 207 | | |
197 | | - | |
198 | | - | |
199 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
200 | 220 | | |
201 | | - | |
202 | 221 | | |
203 | 222 | | |
204 | 223 | | |
| |||
210 | 229 | | |
211 | 230 | | |
212 | 231 | | |
213 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
214 | 241 | | |
215 | 242 | | |
216 | 243 | | |
| |||
224 | 251 | | |
225 | 252 | | |
226 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
227 | 266 | | |
228 | | - | |
| 267 | + | |
229 | 268 | | |
230 | 269 | | |
231 | 270 | | |
| |||
241 | 280 | | |
242 | 281 | | |
243 | 282 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
| 283 | + | |
248 | 284 | | |
249 | 285 | | |
250 | 286 | | |
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