Imported Upstream version 1.8.0
[platform/core/ml/nnfw.git] / compiler / tf2circle-value-pbtxt-remote-test / README.md
1 # tf2circle-value-pbtxt-remote-test
2
3 `tf2circle-value-pbtxt-remote-test` does random value test for `.circle` file using remote machine, normally Odroid, which `nnfw` runs on.
4
5 ### Prerequisites
6
7 1. Tensorflow library
8     - Make sure that Tensorflow library could be found at `nncc configure` step. If there is no Tensorflow library, this test will not be created.
9     - If CMake reports TensorFlow library is not found in configure step, even when the library exists, set [`TENSORFLOW_PREFIX`](../../infra/cmake/packages/TensorFlowConfig.cmake#1) to include Tensorflow library like below.
10         ```sh
11         $ ./nncc configure -DTENSORFLOW_PREFIX=/path/to/Tensorflow/library
12         ```
13     - `TENSORFLOW_PREFIX` should contain Tensorflow library as shown below.
14         ```
15         TENSORFLOW_PREFIX
16             ├ include
17             |  ├ tensorflow
18             |  |     └ c
19             |  |       ├ c_api.h
20             |  ├ ...
21             |
22             ├ lib
23             |  ├ libtensorflow.so
24             |  ├ ...
25             ├ ...
26         ```
27 1. Runtime Library and Binary files
28     - Detailed information is located in [here](../../docs/nnfw/howto/CrossBuildForArm.md)
29     - If you build runtime, related files will be produced in `Product/out`. Do not rename or move it.
30     - (TBD) Support native build option
31 1. Remote machine information and test list
32     - You should create `test.lst` file first as shown below.
33         - Set IP address and username of remote machine using `set` command.
34         - Add Tensorflow models which you want to verify, which are in `/res/TensorflowTests/`
35         ```cmake
36         #--------------- Remote Machine Setting ---------------#
37         set(REMOTE_IP "xxx.xxx.xxx.xxx")
38         set(REMOTE_USER "remote_username")
39
40         #--------------------- Tests list ---------------------#
41         add(UNIT_Add_000)
42         add(UNIT_Add_001)
43         ...
44         ```
45     - If any Tensorflow model is added, or if `REMOTE_IP` and `REMOTE_USER` is not given, `tf2circle-value-pbtxt-remote-test` will not be created.
46 1. (Optional) ssh authentication
47     - This test uses `ssh` and `scp` commands, and those commands require a password of remote machine whenever they are called. This means that you should enter the password everytime when `ssh` and `scp` require.
48     - This test resolves the problem by using `ssh-copy-id`, which copies the public key of host machine to `authorized_keys` of remote machine. Because of that, this test will ask the password of remote machine only once, at the first time. This is the only user interaction while running this test.
49     - If you do not want to interact with system, just do `ssh-copy-id ${REMOTE_USER}@${REMOTE_IP}` in advance, before running this test. Once `ssh-copy-id` is done, there will be no user-interaction action while running the test.
50
51 ### Running
52
53 - If you finished prerequisites properly, configuring -> building -> testing steps create cmake test automatically.
54 - All the related materials will be sent to `REMOTE_WORKDIR` in remote machine. Default value of `REMOTE_WORKDIR` is `CVT_YYMMDD_hhmmss`, which means Circle Value Test done on YY/MM/DD at hh:mm:ss.
55 - `REMOTE_WORKDIR` will not be removed automatically after this test finish.
56     ```sh
57     $ ./nncc configure && ./nncc build
58
59     # Default REMOTE_WORKDIR is CVT_YYMMDD_hhmmss folder
60     $ ./nncc test -R tf2circle_value_pbtxt_remote_test
61
62     # You can set REMOTE_WORKDIR where you have write privilege
63     $ REMOTE_WORKDIR=/path/you/want/ ./nncc test -R tf2circle_value_pbtxt_remote_test
64     ```
65
66 ### Generated Files While Running
67
68 - All related files(`pb`, `circle`, `h5` ... etc.) are created in `build/compiler/tf2circle-value-pbtxt-remote-test` folder.
69     ```
70     build/compiler/tf2circle-value-pbtxt-remote-test
71         ├ Result_latest -> Result_YYMMDD_hhmmss.csv
72         ├ Result_YYMMDD_hhmmss.csv
73         ├ ...
74         |
75         ├ UNIT_Add_000
76         |     ├ metadata
77         |     |     ├ MANIFEST
78         |     |     └ tc
79         |     |        ├ expected.h5
80         |     |        └ input.h5
81         |     └ UNIT_Add_000.circle
82         |
83         ├ UNIT_Add_000.circle
84         ├ UNIT_Add_000.expected.h5
85         ├ UNIT_Add_000.info
86         ├ UNIT_Add_000.input.h5
87         ├ UNIT_Add_000.log
88         ├ UNIT_Add_000.passed
89         ├ UNIT_Add_000.pb
90         ├ UNIT_Add_000.pbtxt
91         |
92         ├ ...
93     ```
94 - Runtime products and each nnpackage are sent to `REMOTE_WORKDIR` in remote machine.
95 - (TBD) Modify script not to remove obtained h5 file.
96     ```
97     REMOTE_WORKDIR
98         |
99         ├ Product
100         |     └ out
101         |        ├ bin
102         |        ├ lib
103         |        ├ test
104         |        ├ ...
105         |
106         ├ UNIT_Add_000
107         |     ├ metadata
108         |     |     ├ MANIFEST
109         |     |     └ tc
110         |     |        ├ expected.h5
111         |     |        ├ input.h5
112         |     |        └ UNIT_Add_000.out.h5
113         |     |          (Only when comparing with expected.h5 fails)
114         |     |
115         |     └ UNIT_Add_000.circle
116         ├ ...
117     ```
118
119 ### Check Test Result
120
121 - Summary of test result will be created as csv file in host.
122     ```sh
123     # Result_latest is symbolic link to the latest csv result file
124     # Print the latest test result
125     $ cat build/compiler/tf2circle-value-pbtxt-remote-test/Result_latest
126     TEST_NAME, TF2CIRCLE, CIRCLE_VALUE_TEST
127     UNIT_Add_000, TRUE, TRUE
128     ...
129
130     # List all result csv files
131     $ ls build/compiler/tf2circle-value-pbtxt-remote-test/Result_*.csv
132     Result_20191119_212521.csv
133     ...
134     ```
135 - Detailed log file for each test cases is also created.
136     ```sh
137     $ cat build/compiler/tf2circle-value-pbtxt-remote-test/*.log
138     ```