summaryrefslogtreecommitdiff
path: root/nnpackage/spec/10_packaging_and_manifest.md
blob: d4e6ec8bd4dc7496db79ef695007dbe9db7f8e55 (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
# 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
└── mymodel.model
```

- `mymodel.model` is a model file that has computation graph and weights.
- `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`.

#### 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" : "0",
    "patch-version" : "0",
    "models"      : [ "mymodel.model", "yourmodel.model" ],
    "model-types" : [ "tflite", "circle" ]
}
```