d4e6ec8bd4dc7496db79ef695007dbe9db7f8e55
[platform/core/ml/nnfw.git] / nnpackage / spec / 10_packaging_and_manifest.md
1 # Packaging and Manifest
2
3 ## 1. Overview
4
5 `nnpackage` is the input of nnfw, and the output of nncc.
6
7 `nnpackage` contains all data (such as model, `MANIFEST`, custom_op) that requires to run a given model.
8
9 The document will cover packaging and `MANIFEST` only.
10
11 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).
12
13 ## 2. Packaging Structure
14
15 `nnpackage` is a Zip archive in the following structure:
16
17 ```
18 nnpackage
19 ├── custom_op
20 ├── metadata
21 │   └── MANIFEST
22 └── mymodel.model
23 ```
24
25 - `mymodel.model` is a model file that has computation graph and weights.
26 - `metadata` is a directory that contains all metadata including `MANIFEST`.
27 - `MANIFEST` is a collection of attributes about this package.
28 - `custom_op` is a directory that contains implementation objects.
29
30 ## 3. Packaging Format
31
32 `nnpackage` is contained in `Zip Archive`, which could be either `compressed` or `stored` (no compression).
33
34 ## 4. Manifest
35
36 `MANIFEST` is a collection of attributes about `nnpacakge`. `MANIFEST` should be a valid JSON.
37
38 ### Attributes
39
40 #### version
41
42 `version` is composed of 3 numbers in `MAJOR`.`MINOR`.`PATCH`.
43
44 Given a version number MAJOR.MINOR.PATCH, increment the:
45
46 MAJOR version when you make incompatible/breaking changes,
47 MINOR version when you add functionality in a backwards-compatible manner, and
48 PATCH version when you make backwards-compatible bug fixes.
49
50 For detail, see [semantic versioning 2.0.0](https://semver.org/)
51
52 ##### major-version
53
54 `major-version` is the major version of `nnpackage`.
55
56 ##### minor-version
57
58 `minor-version` is the minor version of `nnpackage`.
59
60 ##### patch-version
61
62 `patch-version` is the patch version of `nnpackage`.
63
64 #### models
65
66 `models` is an array of path to model files, which is relative path from top level directory of this package.
67 The first element from the array will be the default model to be executed.
68
69 #### model-types
70
71 `model-types` is an array of strings that describes the type of each model in `models`.
72
73 It can have the values (case-sensitive) in following table.
74
75 | name   | description            |
76 |--------|------------------------|
77 | tflite | tensorflow lite schema |
78 | circle | nnpackage schema       |
79
80 ### Example
81
82 Here is an example of `MANIFEST`.
83
84 ```
85 {
86     "major-version" : "1",
87     "minor-version" : "0",
88     "patch-version" : "0",
89     "models"      : [ "mymodel.model", "yourmodel.model" ],
90     "model-types" : [ "tflite", "circle" ]
91 }
92 ```