summaryrefslogtreecommitdiff
path: root/nnpackage/spec/10_packaging_and_manifest.md
blob: 4dc3de874ce449ec1d77fec1a28941e8b6f074a1 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Packaging and Manifest

## 1. Overview

`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.

The document will cover packaging and `MANIFEST` only.

For `model` and `custom_op`, see [20_model_and_operators.md](20_model_and_operators.md) and [30_custom_op.md](30_custom_op.md).

## 2. Packaging Structure

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

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

- `mymodel.model` is a model file that has computation graph and weights.
- `config.cfg` is a configuration file that has parameters to configure onert.
- `metadata` is a directory that contains all metadata including `MANIFEST`.
- `MANIFEST` is a collection of attributes about this package.
- `custom_op` is a directory that contains implementation objects.

## 3. Packaging Format

`nnpackage` is contained in `Zip Archive`, which could be either `compressed` or `stored` (no compression).

## 4. Manifest

`MANIFEST` is a collection of attributes about `nnpacakge`. `MANIFEST` should be a valid JSON.

### Attributes

#### version

`version` is composed of 3 numbers in `MAJOR`.`MINOR`.`PATCH`.

Given a version number MAJOR.MINOR.PATCH, increment the:

MAJOR version when you make incompatible/breaking changes,
MINOR version when you add functionality in a backwards-compatible manner, and
PATCH version when you make backwards-compatible bug fixes.

For detail, see [semantic versioning 2.0.0](https://semver.org/)

##### major-version

`major-version` is the major version of `nnpackage`.

##### minor-version

`minor-version` is the minor version of `nnpackage`.

##### patch-version

`patch-version` is the patch version of `nnpackage`.

#### configs

`configs` is an array of configuration file names placed in `metadata` folder. This can be empty or
attribute itself can be omitted. As of now we only support only one item.

#### models

`models` is an array of path to model files, which is relative path from top level directory of this package.
The first element from the array will be the default model to be executed.

#### model-types

`model-types` is an array of strings that describes the type of each model in `models`.

It can have the values (case-sensitive) in following table.

| name   | description            |
|--------|------------------------|
| tflite | tensorflow lite schema |
| circle | nnpackage schema       |

### Example

Here is an example of `MANIFEST`.

```
{
    "major-version" : "1",
    "minor-version" : "1",
    "patch-version" : "0",
    "configs"     : [ "model.cfg" ],
    "models"      : [ "mymodel.model", "yourmodel.model" ],
    "model-types" : [ "tflite", "circle" ]
}
```

## 5. Configuration file

Configuration file is a human readable plain text file having one `key=value` in each line.
- `#` is used as comment and will be ignored afterwards.
- all leading and trailing white spaces will be ignored in both `key` and `value`.

For example
```
BACKENDS=cpu
# leading/trailing space is ignored
 EXCUTOR=Linear # some comment
```

Refer `runtime/onert/core/include/util/Config.lst` file for more information of `key`.