summaryrefslogtreecommitdiff
path: root/tools/nnpackage_tool/sth2nnpkgtc/pb2nnpkgtc.md
blob: faf66fbde706cd94f289f4ef3db45177c6fbc1ce (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
# pb2nnpkgtc

`pb2nnpkgtc` is a tool to select a subgraph of pb model and convert to `nnpackage` with golden data and generated pb.

It takes `pb` as input and generates `nnpackage`.

## prerequisite

Install tensorflow >= 1.12. It is tested with tensorflow 1.13, 1.14 and 2.0.

Install node. (Any version will do. I recommend you to use `nvm`.)

Set environmet variables from usage below.

## usage

```
$ ./pb2nnpkgtc.sh -h
Usage: pb2nnpkgtc.sh [options] pb inputs outputs
Convert pb to nnpkg-tc

Returns
     0       success
  non-zero   failure

Options:
    -h   show this help
    -o   set output directory (default=.)

Environment variables:
   flatc           path to flatc
                   (default=./build/externals/FLATBUFFERS/build/flatc)
   tflite_schema   path to tflite schema (i.e. schema.fbs)
   circle_schema   path to tflite schema (i.e. schema.fbs)
```

## example
```
# @ host
$ tools/nnpackage_tool/sth2nnpkgtc/pb2nnpkgtc.sh test_model.pb img_placeholder conv2d_transpose

# then, nnpkg is generated in {basename}.{outputname}
# it contains all of pb, tflite, circle, and golden data.

$ tree test_model.conv2d_transpose
test_model.conv2d_transpose
├── test_model.conv2d_transpose.circle
├── test_model.conv2d_transpose.pb
├── test_model.conv2d_transpose.tflite
└── metadata
    ├── MANIFEST
        └── tc
                ├── expected.h5
                        └── input.h5

# @ target
$ OP_BACKEND_ALLOPS=cpu \
onert/test/onert-test nnpkg-test test_model.conv2d_transpose
[  Run  ] ./test_model.out   Pass
[Compare] ./test_model.out   Pass
```