Skip to content

Commit

Permalink
misc: Update patch.
Browse files Browse the repository at this point in the history
  • Loading branch information
iabdalkader committed Jul 14, 2024
1 parent 7e9e17f commit e9d55ca
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 84 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/tflm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,10 @@ jobs:
repository: tensorflow/tflite-micro
ref: 0cc2e49fd96eca29761b323a16f41683fe112fc6

- name: '⏳ Checkout Ethos-U'
run: |
git clone --branch 24.05 --depth 1 \
https://review.mlplatform.org/ml/ethos-u/ethos-u-core-driver \
tflite-micro/tensorflow/lite/micro/tools/make/downloads/ethos_u_core_driver/
- name: '🩹 Apply patches'
run: |
cd tflite-micro/tensorflow/lite/micro/tools/make/downloads/ethos_u_core_driver/
git log -1
git apply --verbose ${GITHUB_WORKSPACE}/patches/ethosu_driver.patch
cd tflite-micro
git apply --verbose ${GITHUB_WORKSPACE}/patches/tflite_micro.patch
- name: '♻ Caching dependencies'
uses: actions/[email protected]
Expand Down
74 changes: 0 additions & 74 deletions patches/ethosu_driver.patch

This file was deleted.

108 changes: 108 additions & 0 deletions patches/tflite_micro.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
diff --git a/tensorflow/lite/micro/tools/make/ethos_u_core_driver_download.sh b/tensorflow/lite/micro/tools/make/ethos_u_core_driver_download.sh
new file mode 100755
index 00000000..c4859466
--- /dev/null
+++ b/tensorflow/lite/micro/tools/make/ethos_u_core_driver_download.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+# Copyright 2024 The TensorFlow Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==============================================================================
+#
+# Called with following arguments:
+# 1 - Path to the downloads folder which is typically
+# tensorflow/lite/micro/tools/make/downloads
+#
+# This script is called from the Makefile and uses the following convention to
+# enable determination of sucess/failure:
+#
+# - If the script is successful, the only output on stdout should be SUCCESS.
+# The makefile checks for this particular string.
+#
+# - Any string on stdout that is not SUCCESS will be shown in the makefile as
+# the cause for the script to have failed.
+#
+# - Any other informational prints should be on stderr.
+
+set -e
+
+TENSORFLOW_ROOT=${2}
+source ${TENSORFLOW_ROOT}tensorflow/lite/micro/tools/make/bash_helpers.sh
+
+DOWNLOADS_DIR=${1}
+if [ ! -d ${DOWNLOADS_DIR} ]; then
+ echo "The top-level downloads directory: ${DOWNLOADS_DIR} does not exist."
+ exit 1
+fi
+
+DOWNLOADED_ETHOS_U_CORE_DRIVER_PATH=${DOWNLOADS_DIR}/ethos_u_core_driver
+
+if [ -d ${DOWNLOADED_ETHOS_U_CORE_DRIVER_PATH} ]; then
+ echo >&2 "${DOWNLOADED_ETHOS_U_CORE_DRIVER_PATH} already exists, skipping the download."
+else
+ UNAME_S=`uname -s`
+ if [ ${UNAME_S} != Linux ]; then
+ echo "OS type ${UNAME_S} not supported."
+ exit 1
+ fi
+
+ git clone -c advice.detachedHead=false --depth 1 --branch 24.05 \
+ "https://review.mlplatform.org/ml/ethos-u/ethos-u-core-driver" \
+ ${DOWNLOADED_ETHOS_U_CORE_DRIVER_PATH} >&2
+ pushd ${DOWNLOADED_ETHOS_U_CORE_DRIVER_PATH} > /dev/null
+ rm -rf .git
+ create_git_repo ./
+ popd > /dev/null
+
+fi
+
+echo "SUCCESS"
diff --git a/tensorflow/lite/micro/tools/make/ext_libs/ethos_u.inc b/tensorflow/lite/micro/tools/make/ext_libs/ethos_u.inc
index c61aaff3..fba2bbde 100644
--- a/tensorflow/lite/micro/tools/make/ext_libs/ethos_u.inc
+++ b/tensorflow/lite/micro/tools/make/ext_libs/ethos_u.inc
@@ -30,7 +30,10 @@ endif
ETHOSU_DEFAULT_DOWNLOAD_DRIVER_PATH := $(MAKEFILE_DIR)/downloads/ethos_u_core_driver
ETHOSU_DRIVER_PATH := $(ETHOSU_DEFAULT_DOWNLOAD_DRIVER_PATH)
ifeq ($(ETHOSU_DRIVER_PATH), $(ETHOSU_DEFAULT_DOWNLOAD_DRIVER_PATH))
- $(call $(or $(shell $(DOWNLOAD_SCRIPT) $(ETHOSU_URL) $(ETHOSU_MD5) $(ETHOSU_DRIVER_PATH) >&2 && echo SUCCESS), $(error $(DOWNLOAD_SCRIPT) failed)))
+DOWNLOAD_RESULT := $(shell $(MAKEFILE_DIR)/ethos_u_core_driver_download.sh $(DOWNLOADS_DIR) $(TENSORFLOW_ROOT))
+ ifneq ($(DOWNLOAD_RESULT), SUCCESS)
+ $(error $(DOWNLOAD_SCRIPT) failed)
+ endif
endif

THIRD_PARTY_CC_HDRS += $(shell find $(ETHOSU_DRIVER_PATH)/include -name "*.h")
@@ -67,8 +70,8 @@ else ifeq ($(ETHOSU_ARCH), u65)
else
$(error "ETHOSU_ARCH=$(ETHOSU_ARCH) is not supported")
endif
-CCFLAGS += ${ETHOSU_FLAGS}
-CXXFLAGS += ${ETHOSU_FLAGS}
+CCFLAGS += ${ETHOSU_FLAGS} ${ETHOSU_EXTRA_CFLAGS}
+CXXFLAGS += ${ETHOSU_FLAGS} ${ETHOSU_EXTRA_CXXFLAGS}

# Convert downloaded person detect int8 model.
$(GENERATED_SRCS_DIR)tensorflow/lite/micro/models/person_detect_model_data_vela.cc:
diff --git a/tensorflow/lite/micro/tools/make/third_party_downloads.inc b/tensorflow/lite/micro/tools/make/third_party_downloads.inc
index 6bee8ce8..902206d4 100644
--- a/tensorflow/lite/micro/tools/make/third_party_downloads.inc
+++ b/tensorflow/lite/micro/tools/make/third_party_downloads.inc
@@ -40,5 +40,3 @@ EMBARC_MLI_PRE_COMPILED_URL := "https://github.com/foss-for-synopsys-dwc-arc-pro
EMBARC_MLI_PRE_COMPILED_MD5 := "173990c2dde4efef6a2c95b92d1f0244"

# Skip md5sum-check since ethos-u-core-driver download link is non-deterministic, see https://github.com/google/gitiles/issues/84
-ETHOSU_URL := "https://review.mlplatform.org/plugins/gitiles/ml/ethos-u/ethos-u-core-driver/+archive/24455eedb9e8939f8a28ca0101a6f2d171e1b2f9.tar.gz"
-ETHOSU_MD5 := "SKIP_MD5_CHECK"
\ No newline at end of file
5 changes: 4 additions & 1 deletion tools/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ ci_build_target() {
TARGET_ARGS="${5}"
TARGET_BUILD=${6}

ETHOSU_CONFIG="-DNPU_QCONFIG=0 -DNPU_REGIONCFG_0=0 -DAXI_LIMIT0_MAX_BEATS_BYTES=1 -DAXI_LIMIT0_MEM_TYPE=2 -DAXI_LIMIT1_MAX_BEATS_BYTES=1 -DAXI_LIMIT1_MEM_TYPE=2 -DAXI_LIMIT2_MAX_BEATS_BYTES=1 -DAXI_LIMIT2_MEM_TYPE=2 -DAXI_LIMIT3_MAX_BEATS_BYTES=1 -DAXI_LIMIT3_MEM_TYPE=2"

pushd ${TFLM_REPO_PATH}
make -j$(nproc) -f tensorflow/lite/micro/tools/make/Makefile \
TARGET=cortex_m_generic TARGET_ARCH=${TARGET_ARCH} CO_PROCESSOR=${TARGET_COPROC} ${TARGET_ARGS} \
TARGET=cortex_m_generic TARGET_ARCH=${TARGET_ARCH} \
CO_PROCESSOR=${TARGET_COPROC} ${TARGET_ARGS} ETHOSU_EXTRA_CFLAGS=${ETHOSU_CONFIG} \
OPTIMIZED_KERNEL_DIR=${TARGET_KERNEL} CORE_OPTIMIZATION_LEVEL=-O2 \
KERNEL_OPTIMIZATION_LEVEL=-O2 THIRD_PARTY_KERNEL_OPTIMIZATION_LEVEL=-O2 \
TARGET_TOOLCHAIN_ROOT=${TOOLCHAIN_PATH}/bin/ TARGET_TOOLCHAIN_PREFIX=arm-none-eabi- \
Expand Down

0 comments on commit e9d55ca

Please sign in to comment.