Quellcode durchsuchen

Build Linux flatc from source snapshot

Lutz Roeder vor 6 Jahren
Ursprung
Commit
8ea1de519a
5 geänderte Dateien mit 915 neuen und 840 gelöschten Zeilen
  1. 2 2
      Makefile
  2. 153 495
      src/armnn-schema.js
  3. 696 278
      src/tflite-schema.js
  4. 31 34
      tools/armnn
  5. 33 31
      tools/tflite

+ 2 - 2
Makefile

@@ -21,7 +21,7 @@ reset:
 
 update:
 	@[ -d node_modules ] || npm install
-	@./tools/armnn sync install schema
+	@./tools/armnn sync schema
 	@./tools/bigdl sync schema
 	@./tools/caffe sync schema
 	@./tools/coreml sync install schema
@@ -39,7 +39,7 @@ update:
 	@./tools/pytorch sync install schema metadata
 	@./tools/sklearn sync install metadata
 	@./tools/tf sync install schema metadata
-	@./tools/tflite sync install schema
+	@./tools/tflite sync schema
 	@./tools/torch sync
 
 build_python:

Datei-Diff unterdrückt, da er zu groß ist
+ 153 - 495
src/armnn-schema.js


Datei-Diff unterdrückt, da er zu groß ist
+ 696 - 278
src/tflite-schema.js


+ 31 - 34
tools/armnn

@@ -14,20 +14,6 @@ bold() {
     echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)" 
 }
 
-git_sync () {
-    mkdir -p "${third_party}"
-    if [ -d "${third_party}/${2}" ]; then
-        git -C "${third_party}/${2}" pull --quiet --prune
-    else
-        git -C "${third_party}" clone --quiet --recursive ${1}
-    fi
-    if [ -n "${3}" ]; then
-        git -C "${third_party}/${2}" checkout --quiet ${3}
-    fi
-    git -C "${third_party}/${2}" submodule sync --quiet
-    git -C "${third_party}/${2}" submodule update --quiet --init --recursive
-}
-
 clean() {
     bold "armnn clean"
     rm -rf ${third_party}/armnn
@@ -35,30 +21,42 @@ clean() {
 
 sync() {
     bold "armnn sync"
-    git_sync https://github.com/google/flatbuffers.git flatbuffers
-    git_sync https://github.com/ARM-software/armnn.git armnn master
+    mkdir -p "${third_party}"
+    if [ -d "${third_party}/armnn" ]; then
+        git -C "${third_party}/armnn" pull --quiet --prune
+    else
+        git -C "${third_party}" clone --quiet --branch master --recursive https://github.com/ARM-software/armnn.git
+    fi
+    git -C "${third_party}/armnn" submodule sync --quiet
+    git -C "${third_party}/armnn" submodule update --quiet --init --recursive
 }
 
-install() {
-    bold "armnn install"
-    case "$(uname)" in
-        "Linux")
-            [ -n "$(which cmake)" ] || sudo apt install -y cmake
+schema() {
+    bold "armnn schema"
+    case "${OSTYPE}" in
+        linux*)
+            FLATC_VERSION=$(curl -s https://api.github.com/repos/google/flatbuffers/releases/latest | grep tag_name | cut -f 2 -d : | cut -f 2 -d '"')
+            FLATC_DIR=$(dirname $(mktemp -u))/flatbuffers/${FLATC_VERSION}
+            if [ ! -f "${FLATC_DIR}/flatc" ]; then
+                mkdir -p "${FLATC_DIR}"
+                pushd "${FLATC_DIR}" > /dev/null
+                curl -sL https://github.com/google/flatbuffers/archive/${FLATC_VERSION}.tar.gz | tar zx --strip-components 1
+                cmake -G "Unix Makefiles" . &> /dev/null
+                make > /dev/null
+                popd > /dev/null
+            fi
+            FLATC=${FLATC_DIR}/flatc
             ;;
-        "Darwin")
-            brew list cmake > /dev/null 2>&1 || brew install cmake > /dev/null
+        darwin*)
+            brew list flatbuffers > /dev/null 2>&1 || brew install flatbuffers > /dev/null
+            FLATC=flatc
+            ;;
+        msys*)
+            echo "msys flatc not supported" 1>&2
+            exit 1
             ;;
     esac
-    pushd "${third_party}/flatbuffers" > /dev/null
-    cmake -G "Unix Makefiles" . > /dev/null
-    make > /dev/null
-    popd > /dev/null
-}
-
-schema() {
-    bold "armnn schema"
-
-    ${third_party}/flatbuffers/flatc --no-js-exports --js ${third_party}/armnn/src/armnnSerializer/ArmnnSchema.fbs
+    ${FLATC} --no-js-exports --js ${third_party}/armnn/src/armnnSerializer/ArmnnSchema.fbs
     mv ./ArmnnSchema_generated.js ${src}/armnn-schema.js
     cat <<EOT >> ${src}/armnn-schema.js
 if (typeof module !== 'undefined' && typeof module.exports === 'object') {
@@ -72,7 +70,6 @@ while [ "$#" != 0 ]; do
     case "${command}" in
         "clean") clean;;
         "sync") sync;;
-        "install") install;;
         "schema") schema;;
     esac
 done

+ 33 - 31
tools/tflite

@@ -15,17 +15,6 @@ bold() {
     echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)" 
 }
 
-git_sync () {
-    mkdir -p "${third_party}"
-    if [ -d "${third_party}/${1}" ]; then
-        git -C "${third_party}/${1}" pull --quiet --prune
-    else
-        git -C "${third_party}" clone --quiet --recursive ${2}
-    fi
-    git -C "${third_party}/${1}" submodule sync --quiet
-    git -C "${third_party}/${1}" submodule update --quiet --init --recursive
-}
-
 clean() {
     bold "tflite clean"
     rm -rf ${virtualenv}
@@ -34,32 +23,43 @@ clean() {
 
 sync() {
     bold "tflite sync"
-    git_sync flatbuffers https://github.com/google/flatbuffers.git
-    git_sync tensorflow https://github.com/tensorflow/tensorflow.git
+    mkdir -p "${third_party}"
+    if [ -d "${third_party}/tensorflow" ]; then
+        git -C "${third_party}/tensorflow" pull --quiet --prune
+    else
+        git -C "${third_party}" clone --quiet --recursive https://github.com/tensorflow/tensorflow.git
+    fi
+    git -C "${third_party}/tensorflow" submodule sync --quiet
+    git -C "${third_party}/tensorflow" submodule update --quiet --init --recursive
 }
 
-install() {
-    bold "tflite install"
-    case "$(uname)" in
-        "Linux")
-            [ -n "$(which cmake)" ] || sudo apt install -y cmake
+schema() {
+    bold "tflite schema"
+    case "${OSTYPE}" in
+        linux*)
+            FLATC_VERSION=$(curl -s https://api.github.com/repos/google/flatbuffers/releases/latest | grep tag_name | cut -f 2 -d : | cut -f 2 -d '"')
+            FLATC_DIR=$(dirname $(mktemp -u))/flatbuffers/${FLATC_VERSION}
+            if [ ! -f "${FLATC_DIR}/flatc" ]; then
+                mkdir -p "${FLATC_DIR}"
+                pushd "${FLATC_DIR}" > /dev/null
+                curl -sL https://github.com/google/flatbuffers/archive/${FLATC_VERSION}.tar.gz | tar zx --strip-components 1
+                cmake -G "Unix Makefiles" . &> /dev/null
+                make > /dev/null
+                popd > /dev/null
+            fi
+            FLATC=${FLATC_DIR}/flatc
             ;;
-        "Darwin")
-            brew list cmake > /dev/null 2>&1 || brew install cmake > /dev/null
+        darwin*)
+            brew list flatbuffers > /dev/null 2>&1 || brew install flatbuffers > /dev/null
+            FLATC=flatc
+            ;;
+        msys*)
+            echo "msys flatc not supported" 1>&2
+            exit 1
             ;;
     esac
-    pushd "${third_party}/flatbuffers" > /dev/null
-    cmake -G "Unix Makefiles" . > /dev/null
-    make > /dev/null
-    popd > /dev/null
-    [ -n "$(python3 -m pip list --format columns --disable-pip-version-check | grep -w virtualenv)" ] || python3 -m pip install --force-reinstall --user --quiet virtualenv
-    [ -d "${virtualenv}" ] || virtualenv --quiet -p python3 ${virtualenv}
-}
-
-schema() {
-    bold "tflite schema"
     sed 's/namespace tflite;/namespace TFLITE;/g' <${third_party}/tensorflow/tensorflow/lite/schema/schema.fbs >${tools}/tflite.schema.fbs
-    ${third_party}/flatbuffers/flatc --no-js-exports --js ${tools}/tflite.schema.fbs
+    ${FLATC} --no-js-exports --js ${tools}/tflite.schema.fbs
     rm ${tools}/tflite.schema.fbs
     mv ./tflite.schema_generated.js ${src}/tflite-schema.js
     cat <<EOT >> ${src}/tflite-schema.js
@@ -71,6 +71,8 @@ EOT
 
 visualize() {
     bold "tflite visualize"
+    [ -n "$(python3 -m pip list --format columns --disable-pip-version-check | grep -w virtualenv)" ] || python3 -m pip install --force-reinstall --user --quiet virtualenv
+    [ -d "${virtualenv}" ] || virtualenv --quiet -p python3 ${virtualenv}
     source ${virtualenv}/bin/activate
     python3 -m pip install --quiet tensorflow
     python3 ${third_party}/tensorflow/tensorflow/lite/tools/visualize.py $@

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.