Refactor Makefile build of TFLite

- Enable Ruy for ARM64 Makefile build
- Remove build_generic_aarch64_lib.sh which is obsolete by build_aarch64_lib.sh
- BUILD_WITH_NNAPI is disabled by default
- Use aarch64 instead of armv8-a for ARM64 TARGET_ARCH to make
  compatible with "uname -m" result
- Generate ARM64 outputs under make/gen/linux_aarch64

PiperOrigin-RevId: 294362807
Change-Id: I8b5fecce28bf3e16bc318497f498970b6dea07cc
This commit is contained in:
Terry Heo 2020-02-10 20:16:37 -08:00 committed by TensorFlower Gardener
parent be9b6c66eb
commit 69dc52a704
7 changed files with 18 additions and 77 deletions

View File

@ -46,7 +46,7 @@ Then compile:
```
This should compile a static library in:
`tensorflow/lite/tools/make/gen/aarch64_armv8-a/lib/libtensorflow-lite.a`.
`tensorflow/lite/tools/make/gen/linux_aarch64/lib/libtensorflow-lite.a`.
## Compile natively on ARM64
@ -75,4 +75,4 @@ Then compile:
```
This should compile a static library in:
`tensorflow/lite/tools/make/gen/aarch64_armv8-a/lib/libtensorflow-lite.a`.
`tensorflow/lite/tools/make/gen/linux_aarch64/lib/libtensorflow-lite.a`.

View File

@ -146,22 +146,15 @@ else
CORE_CC_EXCLUDE_SRCS += tensorflow/lite/mmap_allocation_disabled.cc
endif
BUILD_WITH_NNAPI ?= true
ifeq ($(BUILD_TYPE),micro)
BUILD_WITH_NNAPI=false
BUILD_WITH_RUY ?= false
ifeq ($(TARGET_ARCH),aarch64)
BUILD_WITH_RUY=true
endif
ifeq ($(TARGET),windows)
BUILD_WITH_NNAPI=false
endif
ifeq ($(TARGET),ios)
BUILD_WITH_NNAPI=false
endif
ifeq ($(TARGET),rpi)
BUILD_WITH_NNAPI=false
endif
ifeq ($(TARGET),generic-aarch64)
BUILD_WITH_NNAPI=false
ifeq ($(BUILD_WITH_RUY),true)
CXXFLAGS += -DTFLITE_WITH_RUY
endif
BUILD_WITH_NNAPI ?= false
ifeq ($(BUILD_WITH_NNAPI),true)
CORE_CC_ALL_SRCS += tensorflow/lite/delegates/nnapi/nnapi_delegate.cc
CORE_CC_ALL_SRCS += tensorflow/lite/delegates/nnapi/quant_lstm_sup.cc
@ -219,7 +212,8 @@ ALL_SRCS := \
$(CMD_LINE_TOOLS_SRCS)
# Where compiled objects are stored.
GENDIR := $(MAKEFILE_DIR)/gen/$(TARGET)_$(TARGET_ARCH)/
TARGET_OUT_DIR ?= $(TARGET)_$(TARGET_ARCH)
GENDIR := $(MAKEFILE_DIR)/gen/$(TARGET_OUT_DIR)/
OBJDIR := $(GENDIR)obj/
BINDIR := $(GENDIR)bin/
LIBDIR := $(GENDIR)lib/

View File

@ -1,22 +0,0 @@
#!/bin/bash -x
# Copyright 2017 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.
# ==============================================================================
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR/../../../.."
CC_PREFIX=aarch64-linux-gnu- make -j 3 -f tensorflow/lite/tools/make/Makefile TARGET=generic-aarch64 TARGET_ARCH=armv8-a

View File

@ -20,5 +20,5 @@ set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TENSORFLOW_DIR="${SCRIPT_DIR}/../../../.."
make -j 4 BUILD_WITH_NNAPI=false -C "${TENSORFLOW_DIR}" -f tensorflow/lite/tools/make/Makefile
make -j 4 -C "${TENSORFLOW_DIR}" -f tensorflow/lite/tools/make/Makefile

View File

@ -2,8 +2,9 @@
ifeq ($(TARGET),aarch64)
# The aarch64 architecture covers all 64-bit ARM chips. This arch mandates
# NEON, so FPU flags are not needed below.
TARGET_ARCH := armv8-a
TARGET_ARCH := aarch64
TARGET_TOOLCHAIN_PREFIX := aarch64-linux-gnu-
TARGET_OUT_DIR := linux_aarch64
CXXFLAGS += \
-march=armv8-a \
@ -24,7 +25,6 @@ ifeq ($(TARGET),aarch64)
-Wl,--as-needed \
-lrt
LIBS := \
-lstdc++ \
-lpthread \

View File

@ -1,33 +0,0 @@
# Settings for generic aarch64 boards such as Odroid C2 or Pine64.
ifeq ($(TARGET),generic-aarch64)
# The aarch64 architecture covers all 64-bit ARM chips. This arch mandates
# NEON, so FPU flags are not needed below.
TARGET_ARCH := armv8-a
TARGET_TOOLCHAIN_PREFIX := aarch64-linux-gnu-
CXXFLAGS += \
-march=armv8-a \
-funsafe-math-optimizations \
-ftree-vectorize \
-fPIC
CCFLAGS += \
-march=armv8-a \
-funsafe-math-optimizations \
-ftree-vectorize \
-fPIC
LDFLAGS := \
-Wl,--no-export-dynamic \
-Wl,--exclude-libs,ALL \
-Wl,--gc-sections \
-Wl,--as-needed
LIBS := \
-lstdc++ \
-lpthread \
-lm \
-ldl
endif

View File

@ -7,7 +7,7 @@ ifeq ($(TARGET),rpi)
ifeq ($(TARGET_ARCH), armv7l)
CXXFLAGS += \
-march=armv7-a \
-march=armv7-a \
-mfpu=neon-vfpv4 \
-funsafe-math-optimizations \
-ftree-vectorize \
@ -25,6 +25,8 @@ ifeq ($(TARGET),rpi)
-Wl,--exclude-libs,ALL \
-Wl,--gc-sections \
-Wl,--as-needed
BUILD_WITH_RUY := true
endif
# TODO(petewarden) In the future, we'll want to use OpenBLAS as a faster
@ -50,7 +52,7 @@ ifeq ($(TARGET),rpi)
-Wl,--gc-sections \
-Wl,--as-needed
endif
LIBS := \
-lstdc++ \
-lpthread \