Commit cbd0fe1
committed
wasi_nn_tensorflowlite.cpp: make this compatible with wasmedge
for wasi_ephemeral_nn,
* implement u8 input
* stop dealing with quantization.
* wasi-nn doesn't have a concept of quantization or pre/post-processing.
i can't think of any ways to make the backend perform zero-point/scale
processing without risking to break other applications.
* there seems to be applications which just use u8 inputs/outputs for
a quantized model. (see [1] for an example.)
for certain kinds of inputs/outputs, it usually just works.
this commit keeps the legacy wasi_nn logic intact for now.
tested with [1] with [2] applied.
WAMR with this patch:
```
Read graph weights, size in bytes: 3561598
[wasi_nn.c:297 WARNING] load_by_name_with_config() not found
[wasi_nn_tensorflowlite.cpp:272 WARNING] Default encoding is CPU.
Loaded graph into wasi-nn with ID: Graph#0
Read input tensor, size in bytes: 150528
1.) [166](198)Aix galericulata
2.) [34](1)Gallus gallus domesticus
3.) [158](1)Coccothraustes coccothraustes
4.) [778](1)Sitta europaea
5.) [819](1)Anas platyrhynchos
```
wasmedge:
```
Read graph weights, size in bytes: 3561598
Loaded graph into wasi-nn with ID: Graph#0
Read input tensor, size in bytes: 150528
1.) [166](198)Aix galericulata
2.) [34](1)Gallus gallus domesticus
3.) [158](1)Coccothraustes coccothraustes
4.) [778](1)Sitta europaea
5.) [819](1)Anas platyrhynchos
```
and "Aix galericulata" seems like a reasonable classification
of the image to my eyes.
[1] https://github.com/second-state/WasmEdge-WASINN-examples/tree/67f174bab59d98c1b52f7367ec0928701dc998f9/tflite-birds_v1-image
[2] second-state/WasmEdge-WASINN-examples#204
Related:
#3555
#26111 parent d298a66 commit cbd0fe1
File tree
1 file changed
+44
-28
lines changed- core/iwasm/libraries/wasi-nn/src
1 file changed
+44
-28
lines changedLines changed: 44 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
279 | 280 | | |
280 | 281 | | |
281 | 282 | | |
| 283 | + | |
282 | 284 | | |
283 | | - | |
284 | | - | |
285 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
286 | 298 | | |
287 | 299 | | |
288 | 300 | | |
289 | 301 | | |
290 | 302 | | |
291 | 303 | | |
292 | | - | |
293 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
294 | 307 | | |
295 | 308 | | |
296 | 309 | | |
297 | 310 | | |
298 | 311 | | |
299 | | - | |
| 312 | + | |
300 | 313 | | |
301 | 314 | | |
302 | 315 | | |
303 | 316 | | |
304 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
305 | 330 | | |
306 | 331 | | |
307 | 332 | | |
| |||
346 | 371 | | |
347 | 372 | | |
348 | 373 | | |
| 374 | + | |
349 | 375 | | |
350 | 376 | | |
351 | 377 | | |
| |||
388 | 414 | | |
389 | 415 | | |
390 | 416 | | |
391 | | - | |
392 | | - | |
393 | 417 | | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
398 | 427 | | |
| 428 | + | |
| 429 | + | |
399 | 430 | | |
400 | 431 | | |
401 | 432 | | |
| |||
404 | 435 | | |
405 | 436 | | |
406 | 437 | | |
407 | | - | |
408 | 438 | | |
409 | 439 | | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | 440 | | |
414 | 441 | | |
415 | 442 | | |
416 | 443 | | |
417 | 444 | | |
418 | | - | |
419 | 445 | | |
420 | 446 | | |
421 | 447 | | |
| |||
429 | 455 | | |
430 | 456 | | |
431 | 457 | | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | 458 | | |
439 | 459 | | |
440 | 460 | | |
| |||
443 | 463 | | |
444 | 464 | | |
445 | 465 | | |
446 | | - | |
447 | 466 | | |
448 | 467 | | |
449 | 468 | | |
| |||
458 | 477 | | |
459 | 478 | | |
460 | 479 | | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | 480 | | |
465 | 481 | | |
466 | 482 | | |
467 | 483 | | |
468 | 484 | | |
469 | | - | |
470 | 485 | | |
| 486 | + | |
471 | 487 | | |
472 | 488 | | |
473 | 489 | | |
| |||
0 commit comments