Merge pull request #24876 from 1e100:master
PiperOrigin-RevId: 236012087
This commit is contained in:
commit
08e48b6138
tensorflow/lite
@ -215,11 +215,14 @@ trained Tensorflow models to the
|
||||
devices. To use the converter, refer to the
|
||||
[Tensorflow-CoreML converter documentation](https://github.com/tf-coreml/tf-coreml).
|
||||
|
||||
### Raspberry Pi
|
||||
### ARM32 and ARM64 Linux
|
||||
|
||||
Compile Tensorflow Lite for a Raspberry Pi by following the
|
||||
[RPi build instructions](rpi.md) This compiles a static library file (`.a`) used
|
||||
to build your app. There are plans for Python bindings and a demo app.
|
||||
[RPi build instructions](rpi.md) Compile Tensorflow Lite for a generic aarch64
|
||||
board such as Odroid C2, Pine64, NanoPi, and others by following the
|
||||
[ARM64 Linux build instructions](linux_aarch64.md) This compiles a static
|
||||
library file (`.a`) used to build your app. There are plans for Python bindings
|
||||
and a demo app.
|
||||
|
||||
## 4. Optimize your model (optional)
|
||||
|
||||
|
62
tensorflow/lite/g3doc/linux_aarch64.md
Normal file
62
tensorflow/lite/g3doc/linux_aarch64.md
Normal file
@ -0,0 +1,62 @@
|
||||
# TensorFlow Lite for generic ARM64 boards
|
||||
|
||||
## Cross compiling
|
||||
|
||||
### Installing the toolchain
|
||||
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install crossbuild-essential-arm64
|
||||
```
|
||||
|
||||
> If you are using Docker, you may not use `sudo`.
|
||||
|
||||
### Building
|
||||
|
||||
Clone this Tensorflow repository. Run this script at the root of the repository
|
||||
to download all the dependencies:
|
||||
|
||||
> The Tensorflow repository is in `/tensorflow` if you are using
|
||||
> `tensorflow/tensorflow:nightly-devel` docker image, just try it.
|
||||
|
||||
```bash
|
||||
./tensorflow/lite/tools/make/download_dependencies.sh
|
||||
```
|
||||
|
||||
Note that you only need to do this once.
|
||||
|
||||
Compile:
|
||||
|
||||
```bash
|
||||
./tensorflow/lite/tools/make/build_aarch64_lib.sh
|
||||
```
|
||||
|
||||
This should compile a static library in:
|
||||
`tensorflow/lite/gen/gen/aarch64_armv8-a/lib/libtensorflow-lite.a`.
|
||||
|
||||
## Native compiling
|
||||
|
||||
These steps were tested on HardKernel Odroid C2, gcc version 5.4.0.
|
||||
|
||||
Log in to your board, install the toolchain.
|
||||
|
||||
```bash
|
||||
sudo apt-get install build-essential
|
||||
```
|
||||
|
||||
First, clone the TensorFlow repository. Run this at the root of the repository:
|
||||
|
||||
```bash
|
||||
./tensorflow/lite/tools/make/download_dependencies.sh
|
||||
```
|
||||
|
||||
Note that you only need to do this once.
|
||||
|
||||
Compile:
|
||||
|
||||
```bash
|
||||
./tensorflow/lite/tools/make/build_aarch64_lib.sh
|
||||
```
|
||||
|
||||
This should compile a static library in:
|
||||
`tensorflow/lite/gen/gen/aarch64_armv8-a/lib/libtensorflow-lite.a`.
|
@ -1,3 +1,7 @@
|
||||
# Make uses /bin/sh by default, which is incompatible with the bashisms seen
|
||||
# below.
|
||||
SHELL := /bin/bash
|
||||
|
||||
# Find where we're running from, so we can store generated files here.
|
||||
ifeq ($(origin MAKEFILE_DIR), undefined)
|
||||
MAKEFILE_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
|
22
tensorflow/lite/tools/make/build_aarch64_lib.sh
Executable file
22
tensorflow/lite/tools/make/build_aarch64_lib.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/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=aarch64 TARGET_ARCH=armv8-a
|
33
tensorflow/lite/tools/make/targets/aarch64_makefile.inc
Normal file
33
tensorflow/lite/tools/make/targets/aarch64_makefile.inc
Normal file
@ -0,0 +1,33 @@
|
||||
# Settings for generic aarch64 boards such as Odroid C2 or Pine64.
|
||||
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_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
|
Loading…
Reference in New Issue
Block a user