blob: bb36cc67bf3b043453b657ba292ea6f630a3b567 (
plain)
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
56
57
58
59
60
61
62
|
# How to test NNFW on single model/input pair
1. Select backend through environment variables:
* acl_cl: `export OP_BACKEND_ALLOPS=acl_cl`
* acl_neon: `export OP_BACKEND_ALLOPS=acl_neon`
* cpu: `export OP_BACKEND_ALLOPS=cpu`
* different backends for different operations:
```
unset OP_BACKEND_ALLOPS
export OP_BACKEND_Conv2D=cpu
export OP_BACKEND_MaxPool2D=acl_cl
export OP_BACKEND_AvgPool2D=acl_neon
```
2. Select executor through environment variable:
* linear: `export EXECUTOR=Linear`
* dataflow: `export EXECUTOR=Dataflow`
* parallel: `export EXECUTOR=Parallel`
## Test NNFW through NNAPI
### Testing on random input
1. Generate random input, get reference result using tflite interpreter, dump input and result into file:
```
/path/to/tflite_run --tflite /path/to/model.tflite --dump /path/to/out.dat
```
2. Inference with NNFW NNAPI and compare result with reference one:
```
USE_NNAPI=1 /path/to/tflite_run --tflite /path/to/model.tflite ---compare /path/to/out.dat
```
### Testing on particular input
1. Prepare input:
`tflite_run` consumes input as sequence of floats.
For example, you could convert `.jpg` image into such format file with next python3 script:
```
from PIL import Image
import numpy as np
img = Image.open("./image.jpg")
np_img = np.array(img.getdata()).reshape(img.size[0], img.size[1], 3).astype(np.float32) / 255.
with open('./converted_image.dat', 'wb') as f:
for i in np_img.flatten('C'):
f.write(i)
```
2. Get reference result using tflite interpreter, dump input and result into file:
```
/path/to/tflite_run --tflite /path/to/model.tflite --input /path/to/input.dat --dump /path/to/out.dat
```
3. Inference with NNFW NNAPI and compare result with reference one:
```
USE_NNAPI=1 /path/to/tflite_run --tflite /path/to/model.tflite ---compare /path/to/out.dat
```
## Test NNFW through NNPackage
TODO: fill this section when NNPackage will be implemented
|