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:
parent
be9b6c66eb
commit
69dc52a704
@ -46,7 +46,7 @@ Then compile:
|
|||||||
```
|
```
|
||||||
|
|
||||||
This should compile a static library in:
|
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
|
## Compile natively on ARM64
|
||||||
|
|
||||||
@ -75,4 +75,4 @@ Then compile:
|
|||||||
```
|
```
|
||||||
|
|
||||||
This should compile a static library in:
|
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`.
|
||||||
|
@ -146,22 +146,15 @@ else
|
|||||||
CORE_CC_EXCLUDE_SRCS += tensorflow/lite/mmap_allocation_disabled.cc
|
CORE_CC_EXCLUDE_SRCS += tensorflow/lite/mmap_allocation_disabled.cc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BUILD_WITH_NNAPI ?= true
|
BUILD_WITH_RUY ?= false
|
||||||
ifeq ($(BUILD_TYPE),micro)
|
ifeq ($(TARGET_ARCH),aarch64)
|
||||||
BUILD_WITH_NNAPI=false
|
BUILD_WITH_RUY=true
|
||||||
endif
|
endif
|
||||||
ifeq ($(TARGET),windows)
|
ifeq ($(BUILD_WITH_RUY),true)
|
||||||
BUILD_WITH_NNAPI=false
|
CXXFLAGS += -DTFLITE_WITH_RUY
|
||||||
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
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
BUILD_WITH_NNAPI ?= false
|
||||||
ifeq ($(BUILD_WITH_NNAPI),true)
|
ifeq ($(BUILD_WITH_NNAPI),true)
|
||||||
CORE_CC_ALL_SRCS += tensorflow/lite/delegates/nnapi/nnapi_delegate.cc
|
CORE_CC_ALL_SRCS += tensorflow/lite/delegates/nnapi/nnapi_delegate.cc
|
||||||
CORE_CC_ALL_SRCS += tensorflow/lite/delegates/nnapi/quant_lstm_sup.cc
|
CORE_CC_ALL_SRCS += tensorflow/lite/delegates/nnapi/quant_lstm_sup.cc
|
||||||
@ -219,7 +212,8 @@ ALL_SRCS := \
|
|||||||
$(CMD_LINE_TOOLS_SRCS)
|
$(CMD_LINE_TOOLS_SRCS)
|
||||||
|
|
||||||
# Where compiled objects are stored.
|
# 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/
|
OBJDIR := $(GENDIR)obj/
|
||||||
BINDIR := $(GENDIR)bin/
|
BINDIR := $(GENDIR)bin/
|
||||||
LIBDIR := $(GENDIR)lib/
|
LIBDIR := $(GENDIR)lib/
|
||||||
|
@ -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
|
|
@ -20,5 +20,5 @@ set -e
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
TENSORFLOW_DIR="${SCRIPT_DIR}/../../../.."
|
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
|
||||||
|
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
ifeq ($(TARGET),aarch64)
|
ifeq ($(TARGET),aarch64)
|
||||||
# The aarch64 architecture covers all 64-bit ARM chips. This arch mandates
|
# The aarch64 architecture covers all 64-bit ARM chips. This arch mandates
|
||||||
# NEON, so FPU flags are not needed below.
|
# NEON, so FPU flags are not needed below.
|
||||||
TARGET_ARCH := armv8-a
|
TARGET_ARCH := aarch64
|
||||||
TARGET_TOOLCHAIN_PREFIX := aarch64-linux-gnu-
|
TARGET_TOOLCHAIN_PREFIX := aarch64-linux-gnu-
|
||||||
|
TARGET_OUT_DIR := linux_aarch64
|
||||||
|
|
||||||
CXXFLAGS += \
|
CXXFLAGS += \
|
||||||
-march=armv8-a \
|
-march=armv8-a \
|
||||||
@ -24,7 +25,6 @@ ifeq ($(TARGET),aarch64)
|
|||||||
-Wl,--as-needed \
|
-Wl,--as-needed \
|
||||||
-lrt
|
-lrt
|
||||||
|
|
||||||
|
|
||||||
LIBS := \
|
LIBS := \
|
||||||
-lstdc++ \
|
-lstdc++ \
|
||||||
-lpthread \
|
-lpthread \
|
||||||
|
@ -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
|
|
@ -7,7 +7,7 @@ ifeq ($(TARGET),rpi)
|
|||||||
|
|
||||||
ifeq ($(TARGET_ARCH), armv7l)
|
ifeq ($(TARGET_ARCH), armv7l)
|
||||||
CXXFLAGS += \
|
CXXFLAGS += \
|
||||||
-march=armv7-a \
|
-march=armv7-a \
|
||||||
-mfpu=neon-vfpv4 \
|
-mfpu=neon-vfpv4 \
|
||||||
-funsafe-math-optimizations \
|
-funsafe-math-optimizations \
|
||||||
-ftree-vectorize \
|
-ftree-vectorize \
|
||||||
@ -25,6 +25,8 @@ ifeq ($(TARGET),rpi)
|
|||||||
-Wl,--exclude-libs,ALL \
|
-Wl,--exclude-libs,ALL \
|
||||||
-Wl,--gc-sections \
|
-Wl,--gc-sections \
|
||||||
-Wl,--as-needed
|
-Wl,--as-needed
|
||||||
|
|
||||||
|
BUILD_WITH_RUY := true
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# TODO(petewarden) In the future, we'll want to use OpenBLAS as a faster
|
# 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,--gc-sections \
|
||||||
-Wl,--as-needed
|
-Wl,--as-needed
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LIBS := \
|
LIBS := \
|
||||||
-lstdc++ \
|
-lstdc++ \
|
||||||
-lpthread \
|
-lpthread \
|
||||||
|
Loading…
Reference in New Issue
Block a user