From 76dc86c986804fb26d9376d6260de72b55efd48d Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Thu, 5 Dec 2019 09:58:03 +0900 Subject: [PATCH] Add NNAS SDK 2019/12/15 preset (#9376) This commit add a SDK preset for NNAS 2019/12/15 release. Please note that this commit does not change the default preset. Signed-off-by: Jonghyun Park --- infra/packaging/preset/20191215 | 42 ++++++++++++++++++++++ infra/packaging/res/tf2nnpkg.20191215 | 68 +++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 infra/packaging/preset/20191215 create mode 100644 infra/packaging/res/tf2nnpkg.20191215 diff --git a/infra/packaging/preset/20191215 b/infra/packaging/preset/20191215 new file mode 100644 index 0000000..980d729 --- /dev/null +++ b/infra/packaging/preset/20191215 @@ -0,0 +1,42 @@ +#!/bin/bash + +function preset_configure() +{ + REQUIRED_UNITS=() + # Common Libraries + REQUIRED_UNITS+=("angkor" "bino" "cwrap" "fipe" "pepper-str" "pepper-strcast" "pp" "stdex") + REQUIRED_UNITS+=("oops" "pepper-assert") + # Hermes Logging Framework + REQUIRED_UNITS+=("hermes" "hermes-std") + # loco IR and related utilities + REQUIRED_UNITS+=("loco" "locop" "locomotiv" "logo-core" "logo") + # loco IR extension: Custom Op Support + REQUIRED_UNITS+=("locoex-customop") + # TensorFlow Libraries + REQUIRED_UNITS+=("tfinfo" "plier-tf") + # TensorFlow GraphDef I/O + REQUIRED_UNITS+=("mio-tf") + # TensorFlow Frontend (.pb/.pbtxt -> loco.caninical) + REQUIRED_UNITS+=("moco-log" "moco" "moco-tf") + # TensorFlow Lite/Circle Backend (loco.canonical -> .tflite, loco.circle -> .circle) + REQUIRED_UNITS+=("exo") + # Tools + REQUIRED_UNITS+=("tf2circle") + + # TODO Use "nncc configure" and "nncc build" + cmake \ + -DCMAKE_INSTALL_PREFIX="${NNCC_INSTALL_PREFIX}" \ + -DCMAKE_BUILD_TYPE=release \ + -DBUILD_WHITELIST=$(join_by ";" "${REQUIRED_UNITS[@]}") \ + ${EXTRA_OPTIONS[@]} \ + "${NNAS_PROJECT_PATH}/infra/nncc" +} + +function preset_install() +{ + install -t "${NNPKG_INSTALL_PREFIX}/bin" -D \ + "${NNAS_PROJECT_PATH}/tools/nnpackage_tool/model2nnpkg/model2nnpkg.sh" + + # Install tf2nnpkg + install -T -m 755 -D "${SCRIPT_PATH}/res/tf2nnpkg.20191215" "${NNAS_INSTALL_PREFIX}/bin/tf2nnpkg" +} diff --git a/infra/packaging/res/tf2nnpkg.20191215 b/infra/packaging/res/tf2nnpkg.20191215 new file mode 100644 index 0000000..d334a90 --- /dev/null +++ b/infra/packaging/res/tf2nnpkg.20191215 @@ -0,0 +1,68 @@ +#!/bin/bash + +set -e + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +command_exists() { + if [ "$#" -le 0 ]; then + return 1 + fi + command -v "$@" > /dev/null 2>&1 +} + +usage() +{ + echo "Usage: tf2nnpkg --info --graphdef -o " + exit 0 +} + +# Parse command-line arguments +# +while [ "$#" -ne 0 ]; do + CUR="$1" + + case $CUR in + '--help') + usage + ;; + '--info') + export INFO_FILE="$2" + shift 2 + ;; + '--graphdef') + export GRAPHDEF_FILE="$2" + shift 2 + ;; + '-o') + export OUTPUT_DIR="$2" + shift 2 + ;; + '--use-tf2circle') + echo "WARNING! --use-tf2circle is deprecated" + shift 1 + ;; + *) + echo "${CUR}" + shift + ;; + esac +done + +if [ -z ${GRAPHDEF_FILE} ] || [ ! -e ${GRAPHDEF_FILE} ]; then + echo "pb is not found. Please check --graphdef is correct." + exit 2 +fi + +if [ -z ${INFO_FILE} ] || [ ! -e ${INFO_FILE} ]; then + echo "info is not found. Please check --info is correct." + exit 2 +fi + +FILE_BASE=$(basename ${GRAPHDEF_FILE}) +MODEL_NAME="${FILE_BASE%.*}" +TMPDIR=$(mktemp -d) +trap "{ rm -rf $TMPDIR; }" EXIT + +"${ROOT}/bin/tf2circle" "${INFO_FILE}" "${GRAPHDEF_FILE}" "${TMPDIR}/${MODEL_NAME}.circle" +"${ROOT}/bin/model2nnpkg.sh" -o "${OUTPUT_DIR}" "${TMPDIR}/${MODEL_NAME}.circle" -- 2.7.4