diff options
author | Chunseok Lee <chunseok.lee@samsung.com> | 2020-08-14 15:19:19 +0900 |
---|---|---|
committer | Chunseok Lee <chunseok.lee@samsung.com> | 2020-08-14 15:19:19 +0900 |
commit | 042b262b3633b6c0f577aed6cb4b980ad0c1dcf3 (patch) | |
tree | e79fb9ffe65b21bdc5863306db2757ab187a3306 /tools | |
parent | 05e0ec30a632339a8533082476f27bda31ccde16 (diff) | |
download | nnfw-042b262b3633b6c0f577aed6cb4b980ad0c1dcf3.tar.gz nnfw-042b262b3633b6c0f577aed6cb4b980ad0c1dcf3.tar.bz2 nnfw-042b262b3633b6c0f577aed6cb4b980ad0c1dcf3.zip |
Imported Upstream version 1.8.0upstream/1.8.0submit/tizen/20200814.062151
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/nnpackage_tool/nncc-tc-to-nnpkg-tc/nncc-tc-to-nnpkg-tc.sh | 5 | ||||
-rw-r--r-- | tools/nnpackage_tool/sth2nnpkgtc/pb2nnpkgtc.md | 2 | ||||
-rw-r--r-- | tools/nnpackage_tool/sth2nnpkgtc/tflite2nnpkgtc.md | 2 | ||||
-rwxr-xr-x | tools/tflitefile_tool/select_operator.py | 21 | ||||
-rw-r--r-- | tools/tflkit/README.md | 12 | ||||
-rw-r--r-- | tools/update_version/update-version | 11 |
6 files changed, 20 insertions, 33 deletions
diff --git a/tools/nnpackage_tool/nncc-tc-to-nnpkg-tc/nncc-tc-to-nnpkg-tc.sh b/tools/nnpackage_tool/nncc-tc-to-nnpkg-tc/nncc-tc-to-nnpkg-tc.sh index cf3e54406..bbc5b3e6c 100755 --- a/tools/nnpackage_tool/nncc-tc-to-nnpkg-tc/nncc-tc-to-nnpkg-tc.sh +++ b/tools/nnpackage_tool/nncc-tc-to-nnpkg-tc/nncc-tc-to-nnpkg-tc.sh @@ -62,6 +62,7 @@ tflite " model_type="" +tf_intf_version="" for ext in $supported_model_types; do [ -e "$indir/$tcname"."$ext" ] && model_type=$ext @@ -73,7 +74,9 @@ if [[ "$model_type" == "" ]]; then fi if [[ "$model_type" == "pb" ]]; then - $tf2nnpkg --info "$indir/$tcname".info --graphdef "$indir/$tcname"."$model_type" -o "$outdir" + [ -f "$indir/$tcname"."v2" ] && tf_intf_version="--v2" + $tf2nnpkg --info "$indir/$tcname".info --graphdef "$indir/$tcname"."$model_type" \ + "$tf_intf_version" -o "$outdir" else $model2nnpkg -o "$outdir" "$indir/$tcname"."$model_type" fi diff --git a/tools/nnpackage_tool/sth2nnpkgtc/pb2nnpkgtc.md b/tools/nnpackage_tool/sth2nnpkgtc/pb2nnpkgtc.md index df90d0aa1..faf66fbde 100644 --- a/tools/nnpackage_tool/sth2nnpkgtc/pb2nnpkgtc.md +++ b/tools/nnpackage_tool/sth2nnpkgtc/pb2nnpkgtc.md @@ -55,7 +55,7 @@ test_model.conv2d_transpose # @ target $ OP_BACKEND_ALLOPS=cpu \ -tests/scripts/nnpkg_test.sh test_model.conv2d_transpose +onert/test/onert-test nnpkg-test test_model.conv2d_transpose [ Run ] ./test_model.out Pass [Compare] ./test_model.out Pass ``` diff --git a/tools/nnpackage_tool/sth2nnpkgtc/tflite2nnpkgtc.md b/tools/nnpackage_tool/sth2nnpkgtc/tflite2nnpkgtc.md index dab6ba4d7..9f28ebacb 100644 --- a/tools/nnpackage_tool/sth2nnpkgtc/tflite2nnpkgtc.md +++ b/tools/nnpackage_tool/sth2nnpkgtc/tflite2nnpkgtc.md @@ -42,5 +42,5 @@ nnpkg-tcs/cast # @ target # run nnpkg with nnpackage_run and compare with h5diff -$ tests/scripts/nnpkg_test.sh -i nnpkg-tcs cast +$ onert/test/onert-test nnpkg-test -i nnpkg-tcs cast ``` diff --git a/tools/tflitefile_tool/select_operator.py b/tools/tflitefile_tool/select_operator.py index 1ad44a389..333ca32f6 100755 --- a/tools/tflitefile_tool/select_operator.py +++ b/tools/tflitefile_tool/select_operator.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved # @@ -1180,23 +1180,6 @@ def GenerateModel(args, new_builder, sample_model, operator_list, new_input_tens return tflite.Model.ModelEnd(new_builder) -def Finish(new_builder, new_model): - # Cusrom implementation: identifier - # Python API don't support identifier input yet - # Reference: Finish(self, rootTable)) in builder.py, Finish(uoffset_t root, const char *file_identifier, bool size_prefix) in flatbuffers.h - new_builder.Prep(new_builder.minalign, - flatbuffers.number_types.UOffsetTFlags.bytewidth) - - new_builder.PrependByte(0x33) - new_builder.PrependByte(0x4c) - new_builder.PrependByte(0x46) - new_builder.PrependByte(0x54) - - new_builder.PrependUOffsetTRelative(new_model) - new_builder.finished = True - return new_builder.Head() - - def main(args): input_model_file = args.input_model oplist_file = args.opcode_list @@ -1343,7 +1326,7 @@ def main(args): new_input_tensors, new_output_tensors, used_tensors_dic, used_buffers_dic, used_opcodes_dic, used_subgraphs_dic) - Finish(new_builder, new_model) + new_builder.Finish(new_model, file_identifier=b'TFL3') new_buf = new_builder.Output() output_model_file.write(new_buf) diff --git a/tools/tflkit/README.md b/tools/tflkit/README.md index a0c40c6fa..9e1883436 100644 --- a/tools/tflkit/README.md +++ b/tools/tflkit/README.md @@ -1,4 +1,4 @@ -# tflkit +# tflkit ## Purpose @@ -114,11 +114,11 @@ Number of all operators : 126 (total instrs: 11,484,469 ### TensorFlow -TensorFlow provides some kinds of converting guideline. In Python, the [TFLiteConverter](https://www.tensorflow.org/api_docs/python/tf/contrib/lite/TFLiteConverter) class will help you to convert a TensorFlow GraphDef or SavedModel into `output_format` using TOCO. The `output_format` can be `TFLITE` or `GRAPHVIZ_DOT` format. The default `output_format` is `TFLITE`. And there is a Python command line interface for running TOCO, and its name is [tflite_convert](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/python/tflite_convert.py). This converts a TensorFlow GraphDef or SavedModel into `TFLITE` or `GRAPHVIZ_DOT` format like [TFLiteConverter](https://www.tensorflow.org/api_docs/python/tf/contrib/lite/TFLiteConverter). These two way also supports to convert a TensorFlow Keras model into `output_format`. Both functions are implemented using a tool called TOCO. +TensorFlow provides some kinds of converting guideline. In Python, the [TFLiteConverter](https://www.tensorflow.org/api_docs/python/tf/lite/TFLiteConverter) class will help you to convert a TensorFlow GraphDef or SavedModel into `output_format` using TOCO. The `output_format` can be `TFLITE` or `GRAPHVIZ_DOT` format. The default `output_format` is `TFLITE`. And there is a Python command line interface for running TOCO, and its name is [tflite_convert](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/python/tflite_convert.py). This converts a TensorFlow GraphDef or SavedModel into `TFLITE` or `GRAPHVIZ_DOT` format like [TFLiteConverter](https://www.tensorflow.org/api_docs/python/tf/lite/TFLiteConverter). These two way also supports to convert a TensorFlow Keras model into `output_format`. Both functions are implemented using a tool called TOCO. ### with tflkit -The tflkit uses the [tflite_convert](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/python/tflite_convert.py) python command line interface to convert a TensorFlow model into TfLite model. It only supports to convert a TensorFlow GraphDef file into `TFLITE` format file. This tool supports the creation of individual `TFLITE` files for different input shapes. When converting to multiple `TFLITE` files, it needs to put a string called `NAME` in `TFLITE_PATH`. The string `NAME` will be replaced by what is listed in teh `NAME` environment. This tool requires an information file as a parameter. There is an [example file](info/convert.template) for a convert information. The `--tensorflow_path` and `--tensorflow_version` can change the TensorFlow location. By default, it uses `externals/tensorflow` directory. +The tflkit uses the [tflite_convert](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/python/tflite_convert.py) python command line interface to convert a TensorFlow model into TfLite model. It only supports to convert a TensorFlow GraphDef file into `TFLITE` format file. This tool supports the creation of individual `TFLITE` files for different input shapes. When converting to multiple `TFLITE` files, it needs to put a string called `NAME` in `TFLITE_PATH`. The string `NAME` will be replaced by what is listed in the `NAME` environment. This tool requires an information file as a parameter. There is an [example file](convert.template) for a convert information. The `--tensorflow_path` and `--tensorflow_version` can change the TensorFlow location. By default, it uses `externals/tensorflow` directory. Convert information: * GRAPHDEF_PATH : Full filepath of file containing frozen TensorFlow GraphDef. @@ -176,7 +176,7 @@ The input and output file of this tool is a TensorFlow GraphDef file. ### with tflkit -The [optimize_for_inference.sh](optimize_for_inference.sh) file invokes the TensorFlow [optimize tool](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/optimize_for_inference.py). This tool requires a optimize information file as a parameter. Here is an [example file](info/optimize.template) for this tool. The information file needs `INPUT` and `OUTPUT` array names. The [summarize_pb.sh](summarize_pb.sh) file will help you to define the `INPUT` and `OUTPUT` array names. The `--tensorflow_path` can change the TensorFlow location. By default, it uses `externals/tensorflow` directory. +The [optimize_for_inference.sh](optimize_for_inference.sh) file invokes the TensorFlow [optimize tool](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/optimize_for_inference.py). This tool requires a optimize information file as a parameter. Here is an [example file](optimize.template) for this tool. The information file needs `INPUT` and `OUTPUT` array names. The [summarize_pb.sh](summarize_pb.sh) file will help you to define the `INPUT` and `OUTPUT` array names. The `--tensorflow_path` can change the TensorFlow location. By default, it uses `externals/tensorflow` directory. Optimize information: * GRAPHDEF_PATH : Full filepath of file containing frozen TensorFlow GraphDef. @@ -207,7 +207,7 @@ The trained TensorFlow model can be trasformed by some variants to deploy it in ### with tflkit -The [transform_graph.sh](transform_graph.sh) file supports to transform a TensorFlow GraphDef using various transform options. This tool requires a transform information file as a parameter and the transform options are described in the information file. There is an [example file](info/transform.template) for this tool. The information file needs `INPUT` and `OUTPUT` array names. The [summarize_pb.sh](summarize_pb.sh) file will help you to define the `INPUT` and `OUTPUT` array names. The `--tensorflow_path` can change the TensorFlow location. By default, it uses `externals/tensorflow` directory. +The [transform_graph.sh](transform_graph.sh) file supports to transform a TensorFlow GraphDef using various transform options. This tool requires a transform information file as a parameter and the transform options are described in the information file. There is an [example file](transform.template) for this tool. The information file needs `INPUT` and `OUTPUT` array names. The [summarize_pb.sh](summarize_pb.sh) file will help you to define the `INPUT` and `OUTPUT` array names. The `--tensorflow_path` can change the TensorFlow location. By default, it uses `externals/tensorflow` directory. Transform information: * GRAPHDEF_PATH : Full filepath of file containing frozen TensorFlow GraphDef. @@ -270,7 +270,7 @@ The [freeze_graph](https://github.com/tensorflow/tensorflow/blob/master/tensorfl ### with tflkit -The tflkit provides the simple way to create a frozen graph using [freeze_graph](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py) tool. This tool requires an information file as a parameter. There is an [example file](info/freeze.info) for a freeze tool. Either `SAVED_MODEL` or `META_GRAPH` must be declared. And `META_GRAPH` is always used with `CKPT_PATH`. The `--tensorflow_path` can change the TensorFlow location. By default, it uses `externals/tensorflow` directory. +The tflkit provides the simple way to create a frozen graph using [freeze_graph](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py) tool. This tool requires an information file as a parameter. There is an [example file](freeze.template) for a freeze tool. Either `SAVED_MODEL` or `META_GRAPH` must be declared. And `META_GRAPH` is always used with `CKPT_PATH`. The `--tensorflow_path` can change the TensorFlow location. By default, it uses `externals/tensorflow` directory. Freeze information: * SAVED_MODEL : Full directory path with TensorFlow `SavedModel` file and variables. diff --git a/tools/update_version/update-version b/tools/update_version/update-version index 41693278b..1b77c10cd 100644 --- a/tools/update_version/update-version +++ b/tools/update_version/update-version @@ -40,11 +40,12 @@ fi version=$1 -sed -i "s/^release = .*/release = \'$version\'/" ${nnfw_root}/docs/conf.py -sed -i "s/^Version: .*/Version: $version/" ${nnfw_root}/packaging/nnfw.spec +perl -pi -e "s/^release = .*/release = \'$version\'/" ${nnfw_root}/docs/conf.py -IFS=. read M m p <<< $version +perl -pi -e "s/^Version: .*/Version: $version/" ${nnfw_root}/packaging/nnfw.spec + +IFS=. read M m p <<< "$version" hex=$(printf '0x%08x' $(( (($M << 24)) | (($m << 8)) | $p ))) -sed -i "s/^#define NNFW_VERSION.*/#define NNFW_VERSION $hex/" ${nnfw_root}/runtime/onert/api/include/nnfw_version.h +perl -pi -e "s/^#define NNFW_VERSION.*/#define NNFW_VERSION $hex/" ${nnfw_root}/runtime/onert/api/include/nnfw_version.h -sed -i "s/versionName .*$/versionName \"$version\"/" ${nnfw_root}/runtime/contrib/android/api/build.gradle +perl -pi -e "s/versionName .*$/versionName \"$version\"/" ${nnfw_root}/runtime/contrib/android/api/build.gradle |