Imported Upstream version 1.8.0
[platform/core/ml/nnfw.git] / tools / nnpackage_tool / sth2nnpkgtc / pb2nnpkgtc.md
1 # pb2nnpkgtc
2
3 `pb2nnpkgtc` is a tool to select a subgraph of pb model and convert to `nnpackage` with golden data and generated pb.
4
5 It takes `pb` as input and generates `nnpackage`.
6
7 ## prerequisite
8
9 Install tensorflow >= 1.12. It is tested with tensorflow 1.13, 1.14 and 2.0.
10
11 Install node. (Any version will do. I recommend you to use `nvm`.)
12
13 Set environmet variables from usage below.
14
15 ## usage
16
17 ```
18 $ ./pb2nnpkgtc.sh -h
19 Usage: pb2nnpkgtc.sh [options] pb inputs outputs
20 Convert pb to nnpkg-tc
21
22 Returns
23      0       success
24   non-zero   failure
25
26 Options:
27     -h   show this help
28     -o   set output directory (default=.)
29
30 Environment variables:
31    flatc           path to flatc
32                    (default=./build/externals/FLATBUFFERS/build/flatc)
33    tflite_schema   path to tflite schema (i.e. schema.fbs)
34    circle_schema   path to tflite schema (i.e. schema.fbs)
35 ```
36
37 ## example
38 ```
39 # @ host
40 $ tools/nnpackage_tool/sth2nnpkgtc/pb2nnpkgtc.sh test_model.pb img_placeholder conv2d_transpose
41
42 # then, nnpkg is generated in {basename}.{outputname}
43 # it contains all of pb, tflite, circle, and golden data.
44
45 $ tree test_model.conv2d_transpose
46 test_model.conv2d_transpose
47 ├── test_model.conv2d_transpose.circle
48 ├── test_model.conv2d_transpose.pb
49 ├── test_model.conv2d_transpose.tflite
50 └── metadata
51     ├── MANIFEST
52         └── tc
53                 ├── expected.h5
54                         └── input.h5
55
56 # @ target
57 $ OP_BACKEND_ALLOPS=cpu \
58 onert/test/onert-test nnpkg-test test_model.conv2d_transpose
59 [  Run  ] ./test_model.out   Pass
60 [Compare] ./test_model.out   Pass
61 ```