Prcandidate1 (#2)

* Initial commit of XCORE port
This commit is contained in:
Andrew Cavanaugh 2020-05-07 16:31:22 -04:00 committed by GitHub
parent 46ab1e9f26
commit 2d529fbf9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 123 additions and 0 deletions

View File

@ -0,0 +1,47 @@
#!/bin/bash -e
# Copyright 2018 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.
# ==============================================================================
#
# Tests an XS3 binary by executing it using the XSIM simulator and parsing
# the log output.
#
# First argument is the binary location.
# Second argument is a regular expression that's required to be in the output
# logs for the test to pass.
declare -r ROOT_DIR=`pwd`
declare -r TEST_TMPDIR=/tmp/test_xcore_binary/
declare -r MICRO_LOG_PATH=${TEST_TMPDIR}/$1
declare -r MICRO_LOG_FILENAME=${MICRO_LOG_PATH}/logs.txt
declare -r XCORE_
mkdir -p ${MICRO_LOG_PATH}
# Get the location of this script file as an absolute path
SCRIPT_PATH="`dirname \"$BASH_SOURCE\"`"
SCRIPT_PATH="`( cd \"$SCRIPT_PATH\" && pwd )`"
XSIM_FLAGS=""
xsim $1 ${XSIM_FLAGS} 2>&1 | tee ${MICRO_LOG_FILENAME}
if grep -q "$2" ${MICRO_LOG_FILENAME}
then
echo "$1: PASS"
exit 0
else
echo "$1: FAIL - '$2' not found in logs."
exit 1
fi

View File

@ -137,6 +137,9 @@ download_and_extract() {
exit 1
fi
# delete anything after the '?' in a url that might confound f
url=$(echo "${url}" | sed "s/\?.*//")
if [[ "${url}" == *gz ]]; then
tar -C "${dir}" --strip-components=1 -xzf ${tempfile}
elif [[ "${url}" == *tar.xz ]]; then

View File

@ -0,0 +1,24 @@
# Settings for XMOS XS3 based processors (xcore.ai, ...)
#IMPORTANT: to set up environment variables correctly run the following from the top tensorflow directory:
# $ make -f tensorflow/lite/micro/tools/make/Makefile TARGET="xcore" clean clean_downloads test
# $ pushd tensorflow/lite/micro/tools/make/downloads/xtimecomposer/xTIMEcomposer/15.0.0/ && source SetEnv && popd
# $ make -f tensorflow/lite/micro/tools/make/Makefile TARGET="xcore" test
ifeq ($(TARGET), xcore)
XTIME_URL := "https://www.xmos.com/download/Tools-15---Linux-64%2815.0.0_rc1%29.tgz?key=132D-9DC9-E913-0229-ECE6-D5AB-F511-2B19"
XTIME_MD5 := "8f6543c8ac4af7583edf75e62df322a2"
$(eval $(call add_third_party_download,$(XTIME_URL),$(XTIME_MD5),xtimecomposer))
PLATFORM_FLAGS = -target=XU316-1024-FB265-C32 -mcmodel=large -Os -DXCORE -Wno-xcore-fptrgroup -report
CXX_TOOL := xcc
CC_TOOL := xcc
AR_TOOL := xmosar
override CXXFLAGS := -std=c++11 -g -DTF_LITE_STATIC_MEMORY -DNDEBUG
override CXXFLAGS += $(PLATFORM_FLAGS)
override CCFLAGS := -g -DTF_LITE_STATIC_MEMORY -DNDEBUG
override CCFLAGS += $(PLATFORM_FLAGS)
TARGET_ARCH := xcore
#TARGET_TOOLCHAIN_PREFIX := tensorflow/lite/micro/tools/make/downloads/xtimecomposer/bin/
TEST_SCRIPT := tensorflow/lite/micro/testing/test_xcore_binary.sh
#GCC_XCORE := $(MAKEFILE_DIR)/downloads/xtimecomposer/bin/
endif

View File

@ -0,0 +1,32 @@
# Quickstart to install tools and run unit tests:
$ make -f tensorflow/lite/micro/tools/make/Makefile TARGET="xcore" clean clean_downloads && make -f tensorflow/lite/micro/tools/make/Makefile TARGET="xcore" test_greedy_memory_planner_test || true && pushd tensorflow/lite/micro/tools/make/downloads/xtimecomposer/xTIMEcomposer/15.0.0/ && source SetEnv && popd && make -f tensorflow/lite/micro/tools/make/Makefile TARGET="xcore" test
(add -jN to the final make command to run builds / tests in N parallel threads)
# Background information:
* To start from a fresh repo (this will also remove non-xcore builds and downloads):
```
$ make -f tensorflow/lite/micro/tools/make/Makefile TARGET="xcore" clean clean_downloads
```
* To force xcore.ai tools download from a clean repo:
```
$ make -f tensorflow/lite/micro/tools/make/Makefile TARGET="xcore" test_greedy_memory_planner_test
```
(this will fail to build the test, but if it succeeds because you already have tools it will exit quickly)
* To set up environment variables correctly run the following from the top tensorflow directory:
```
$ make -f tensorflow/lite/micro/tools/make/Makefile TARGET="xcore" test
$ pushd ./tensorflow/lite/micro/tools/make/downloads/xtimecomposer/xTIMEcomposer/15.0.0/ && source SetEnv && popd
$ make -f tensorflow/lite/micro/tools/make/Makefile TARGET="xcore" test
```
* Assuming tools are already set up the following are the most commonly used commands:
```
$ make -f tensorflow/lite/micro/tools/make/Makefile TARGET="xcore" build
$ make -f tensorflow/lite/micro/tools/make/Makefile TARGET="xcore" test
$ make -f tensorflow/lite/micro/tools/make/Makefile TARGET="xcore" < name_of_example i.e. hello_world_test >
```

View File

@ -0,0 +1,17 @@
/* Copyright 2018 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.
==============================================================================*/
#include "tensorflow/lite/micro/debug_log.h"
#include <cstdio>
extern "C" void DebugLog(const char* s) { printf("%s",s); }