summaryrefslogtreecommitdiff
path: root/docs/nnfw/howto/HowToRunNnpackge.md
blob: 93dd74e83dafeb2ec799551ea8343f7fbb522f1a (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
63
64
65
66
67
68
69
70
71
72
73
74
75
# How To Run 'nnpackage' (for beginners)

## 0. Environment

This document is based on an experience with ...

```
- Architecture : armhf 
- OS : ubuntu 18.04
```

## 1. What is 'nnpackage'? 

'nnpackage' is the input of nnfw and the output of nncc.

'nnpackage' contains all data (such as model, MANIFEST, custom_op) that requires to run a given model.

'nnpackage' is a Zip archive in the following structure:

```
nnpackage
├── custom_op
├── metadata
│   └── MANIFEST
└── mymodel.model
```

For more information, find the document [nnpackage/spec/10_packaging_and_manifest.md](../../../nnpackage/spec/10_packaging_and_manifest.md)

## 2. How to generate nnpackage?

'nnpackage' can be generated from either '.circle' or '.tflite'.

In this example, we generate 'nnpackage' from '.tflite'.

  [1] Find 'model2nnpkg.sh'.
  ```
  nnfw/tools/nnpackage_tool/model2nnpkg/model2nnpkg.sh
  ```
  
  [2] Get any \*.tflite model file. 
  You can simply use a file in test framework directory, 'nnfw/tests/framework/cache/'.
  If you don't have /cache directory, download them with command
  ```
  cd nnfw
  MODELFILE_SERVER={MODELFILE_SERVER_LINK} ./tests/framework/run_test.sh --download=on

  For {MODELFILE_SERVER_LINK}, put appropriate server link.
  ```
  In this example, we will use 'nnfw/tests/framework/cache/add/1D/add_test1.tflite'

  [3] Simply run.
  ```
  $./model2nnpkg.sh add_test1
  ```
  Now, you got add_test1 directory. Check into the directory to find the hierchical structure inside.

## 3. How to set up an environment and run?

  [1] Build 'nnfw'.
  
  After build, you can see an execution file 'nnfw/Product/armv7l-linux.debug/out/bin/nnpackage_run'.
  For how to build, check out the document [docs/nnfw/howto/CrossBuildForArm.md](../../../docs/nnfw/howto/CrossBuildForArm.md).
  
  [2] Install package 'libhdf5-cpp-100'.
  ```
  $ sudo apt install libhdf5-cpp-100
  ```
  
  [3] Run nnpackage.
  ```
  $ ./nnpackage_run add_test1 
  ```
  Note that you need to put an whole 'add_test_1' directory,
  because 'nnpackage' means an archive, not a single file.