Update cmake support of TFLite minimal example
Created a CMakeLists.txt under the lite/examples/minimal Usage) $ git clone https://github.com/tensorflow/tensorflow.git tensorflow_src $ mkdir minimal_build $ cd miniaml_build $ cmake ../tensorflow_src/tensorflow/lite/examples/minimal $ cmake --build . -j PiperOrigin-RevId: 339977906 Change-Id: I85cada5430407e72354d0a31a17584c48407db2f
This commit is contained in:
parent
a876f91d24
commit
289ba7f54b
tensorflow/lite
@ -450,12 +450,3 @@ target_link_libraries(benchmark_model
|
|||||||
${TFLITE_BENCHMARK_LIBS}
|
${TFLITE_BENCHMARK_LIBS}
|
||||||
)
|
)
|
||||||
|
|
||||||
# TFLite minimal example
|
|
||||||
add_executable(minimal
|
|
||||||
EXCLUDE_FROM_ALL
|
|
||||||
${TFLITE_SOURCE_DIR}/examples/minimal/minimal.cc
|
|
||||||
)
|
|
||||||
target_link_libraries(minimal
|
|
||||||
tensorflow-lite
|
|
||||||
${CMAKE_DL_LIBS}
|
|
||||||
)
|
|
||||||
|
44
tensorflow/lite/examples/minimal/CMakeLists.txt
Normal file
44
tensorflow/lite/examples/minimal/CMakeLists.txt
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
# https://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.
|
||||||
|
|
||||||
|
|
||||||
|
# Builds the minimal Tensorflow Lite example.
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
project(minimal C CXX)
|
||||||
|
|
||||||
|
set(TENSORFLOW_SOURCE_DIR "" CACHE PATH
|
||||||
|
"Directory that contains the TensorFlow project"
|
||||||
|
)
|
||||||
|
if(NOT TENSORFLOW_SOURCE_DIR)
|
||||||
|
get_filename_component(TENSORFLOW_SOURCE_DIR
|
||||||
|
"${CMAKE_CURRENT_LIST_DIR}/../../../../"
|
||||||
|
ABSOLUTE
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory(
|
||||||
|
"${TENSORFLOW_SOURCE_DIR}/tensorflow/lite"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/tensorflow-lite"
|
||||||
|
EXCLUDE_FROM_ALL
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(minimal
|
||||||
|
minimal.cc
|
||||||
|
)
|
||||||
|
target_link_libraries(minimal
|
||||||
|
tensorflow-lite
|
||||||
|
${CMAKE_DL_LIBS}
|
||||||
|
)
|
37
tensorflow/lite/examples/minimal/README.md
Normal file
37
tensorflow/lite/examples/minimal/README.md
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# TensorFlow Lite C++ minimal example
|
||||||
|
|
||||||
|
This example shows how you can build a simple TensorFlow Lite application.
|
||||||
|
|
||||||
|
#### Step 1. Install CMake tool
|
||||||
|
|
||||||
|
It requires CMake 3.16 or higher. On Ubuntu, you can simply run the following
|
||||||
|
command.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo apt-get install cmake
|
||||||
|
```
|
||||||
|
|
||||||
|
Or you can follow
|
||||||
|
[the official cmake installation guide](https://cmake.org/install/)
|
||||||
|
|
||||||
|
#### Step 2. Clone TensorFlow repository
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone https://github.com/tensorflow/tensorflow.git tensorflow_src
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Step 3. Create CMake build directory and run CMake tool
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mkdir minimal_build
|
||||||
|
cd minimal_build
|
||||||
|
cmake ../tensorflow_src/tensorflow/lite/examples/minimal
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Step 4. Build TensorFlow Lite
|
||||||
|
|
||||||
|
In the minimal_build directory,
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake --build . -j
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user