Add hexagon target to build and run Qualcomm hexagon binaries.

PiperOrigin-RevId: 290851597
Change-Id: I07e3a61d0151f118ed16357c288da17c8eb2e0f1
This commit is contained in:
Nat Jeffries 2020-01-21 16:43:42 -08:00 committed by TensorFlower Gardener
parent f79dd518f2
commit d2db6a515e
2 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,39 @@
#!/bin/bash -e
# Copyright 2020 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 a Qualcomm Hexagon binary by 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_hexagon_binary/
declare -r MICRO_LOG_PATH=${TEST_TMPDIR}/$1
declare -r MICRO_LOG_FILENAME=${MICRO_LOG_PATH}/logs.txt
mkdir -p ${MICRO_LOG_PATH}
hexagon-elfcopy $1 $1.elf
hexagon-sim $1.elf 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

@ -0,0 +1,67 @@
# Settings for Hexagon toolchain.
ifeq ($(TARGET), hexagon)
TARGET_ARCH := hexagon
PLATFORM_ARGS = \
-DHEXAGON_ASM \
-DMALLOC_IN_STDLIB \
-DMICRO_NN_ENABLED=1 \
-DMICRO_TFLITE_ENABLED=0 \
-DNDEBUG \
-DPTHREAD_STUBS \
-DTF_LITE_STATIC_MEMORY \
-DUSE_PREALLOCATED_BUFFER \
-D_HAS_C9X \
-MMD \
-O3 -DNDEBUG -DHEXAGON \
-Wall \
-Wextra \
-Wno-missing-field-initializers \
-Wno-sign-compare \
-Wno-unused-parameter \
-Wno-write-strings \
-Wvla \
-fdata-sections -ffunction-sections \
-fdata-sections \
-ffunction-sections \
-fmessage-length=0 \
-fno-builtin \
-fno-builtin \
-fno-builtin \
-fno-delete-null-pointer-checks \
-fno-exceptions \
-fno-register-global-dtors-with-atexit \
-fno-rtti \
-fno-short-enums \
-fno-threadsafe-statics \
-fno-unwind-tables \
-fno-use-cxa-atexit \
-fomit-frame-pointer \
-fpermissive \
-funsigned-char \
-mcpu=v66 \
-mv66
TARGET_TOOLCHAIN_PREFIX := hexagon-
CXX_TOOL := clang++
CC_TOOL := clang
CXXFLAGS = $(PLATFORM_ARGS) -std=c++11
CCFLAGS = $(PLATFORM_ARGS) -std=c11
LDFLAGS += \
-Wl,--gc-sections -lhexagon
INCLUDES += \
-I$(HEXAGON_SDK_PREFIX)/libs/common/qurt/computev66/include/posix \
-I$(HEXAGON_SDK_PREFIX)/libs/common/qurt/computev66/include/qurt
TEST_SCRIPT := tensorflow/lite/micro/testing/test_hexagon_binary.sh
# These are microcontroller-specific rules for converting the ELF output
# of the linker into a binary image that can be loaded directly.
OBJCOPY := $(TARGET_TOOLCHAIN_PREFIX)objcopy
$(BINDIR)/%.bin: $(BINDIR)/%
@mkdir -p $(dir $@)
$(OBJCOPY) $< $@ -O binary
endif