From 7b4b3c9dccc2ce5a8dd0c6d7d893bcd0240a208b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=82=A8=EA=B6=81=EC=84=9D/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Wed, 4 Dec 2019 10:28:19 +0900 Subject: [PATCH] First commit for release documents of compiler (#9354) This commit includes `tutorial.md` and `getting_started.md`. `tutorial.md` contains the simple actions for compiling inception_v3 `getting_started.md` contains more detailed sections about compiler Signed-off-by: Seok NamKoong --- docs/nncc/Release_2019/getting_started.md | 59 +++++++++++++++++++++++++++++++ docs/nncc/Release_2019/tutorial.md | 49 +++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 docs/nncc/Release_2019/getting_started.md create mode 100644 docs/nncc/Release_2019/tutorial.md diff --git a/docs/nncc/Release_2019/getting_started.md b/docs/nncc/Release_2019/getting_started.md new file mode 100644 index 0000000..ee80140 --- /dev/null +++ b/docs/nncc/Release_2019/getting_started.md @@ -0,0 +1,59 @@ +# Getting Started + +## Environments + +Currently, Ubuntu 16.04 is officially supported as development environment. +Other environments may be available but not confirmed. + +## How to compile your own model + +### What should we preapare + +- Tensorflow model file (`.pb` file) + - TensorFlow model file should be frozen. [[How to freeze?]](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py) + - Only inference operations are supported. Training operations are not supported yet. + - Quantization is not yet supported. + - `device` attribute should not have `GPU` value. +- Model information file (`.info` file) + - `.info` file should include 4 things. + - Specification of input or output + - name of input/output node + - type of input/output node + - shape of input/output node + - Example format is written below. + ``` + # input/output, node_name, node_type, node_shape + + input, input:0, TF_FLOAT, [1, 299, 299, 3] + output, InceptionV3/Predictions/Reshape_1:0, TF_FLOAT, [1, 1001] + ``` + +### How to compile + +1. Generate `nnpkg` using `.pb` file and `.info` file. + ```sh + tf2nnpkg --graphdef --info -o + ``` + +1. Check if all files are generated correctly. + - Directory name of `nnpkg` is prefix of `.pb` file. + - For example, if there is `model.pb` file, directory name will be `model`. + ``` + path/to/generate + └ model + ├ model.circle + └ metadata + └ MANIFEST + ``` + +1. Check if `MANIFEST` contents are correct. + ```sh + $ cat path/to/generate/model/metadata/MANIFEST + { + "major-version" : "1", + "minor-version" : "0", + "patch-version" : "0", + "models" : [ "model.circle" ], + "model-types" : [ "circle" ] + } + ``` diff --git a/docs/nncc/Release_2019/tutorial.md b/docs/nncc/Release_2019/tutorial.md new file mode 100644 index 0000000..9d1f97e --- /dev/null +++ b/docs/nncc/Release_2019/tutorial.md @@ -0,0 +1,49 @@ +# Tutorial + +Let's compile Inception_v3 model and make a nnpackage! + +## Prepare inception_v3 files + +1. Download pre-trained `inception_v3.pb` model file. + ```sh + $ wget https://storage.googleapis.com/download.tensorflow.org/models/tflite/model_zoo/upload_20180427/inception_v3_2018_04_27.tgz + $ tar -xvf inception_v3_2018_04_27.tgz + ``` +1. Create model information file as `inception_v3.info`. + ``` + $ cat > inception_v3.info << "END" + input, input:0, TF_FLOAT, [1, 299, 299, 3] + output, InceptionV3/Predictions/Reshape_1:0, TF_FLOAT, [1, 1001] + END + ``` + +## Let's compile inception_v3 + +1. Generate `nnpkg`. In this tutorial, let's generate to current directory. + ```sh + tf2nnpkg --use-tf2circle \ + --graphdef inception_v3.pb \ + --info inception_v3.info \ + -o . + ``` + +## Check whether compilation is well done + +- Check if all files are generated correctly. + ``` + inception_v3 + ├ inception_v3.circle + └ metadata + └ MANIFEST + ``` +- Check if `MANIFEST` contents are correct. + ```sh + $ cat inception_v3/metadata/MANIFEST + { + "major-version" : "1", + "minor-version" : "0", + "patch-version" : "0", + "models" : [ "inception_v3.circle" ], + "model-types" : [ "circle" ] + } + ``` -- 2.7.4