-
Notifications
You must be signed in to change notification settings - Fork 172
[TF Lite] composing local build environment
This document is created for composing build environment about Tensorflow-lite at local PC rather than mobile device. The source codes are stored at here with MNIST tflite model. If there are missing models, please contact @helloahn .
we need ingredients likes below.
- Tensorflow-Lite model file(
.tflite
) - lists - Tensorflow Library(
.a
or.so
) - download rpm -
gcc
&g++
up to version 6
try below command at terminal.
rpm2cpio {file_name}.rpm | cpio -div
and then, you can get the result likes below.
├── include
│ ├── flatbuffers
│ │ ├── base.h
│ │ ├── code_generators.h
│ │ ├── flatbuffers.h
│ │ ├── flatc.h
│ │ ├── flexbuffers.h
│ │ ├── grpc.h
│ │ ├── hash.h
│ │ ├── idl.h
│ │ ├── minireflect.h
│ │ ├── reflection_generated.h
│ │ ├── reflection.h
│ │ ├── registry.h
│ │ ├── stl_emulation.h
│ │ └── util.h
│ └── tensorflow
│ └── contrib
│ └── lite
│ ├── allocation.h
│ ├── arena_planner.h
│ ├── builtin_op_data.h
│ ├── builtin_ops.h
│ ├── context.h
│ ├── error_reporter.h
│ ├── graph_info.h
│ ├── interpreter.h
│ ├── kernels
│ │ ├── activation_functor.h
│ │ ├── gemm_support.h
│ │ ├── kernel_util.h
│ │ ├── op_macros.h
│ │ ├── padding.h
│ │ ├── register.h
│ │ └── test_util.h
│ ├── memory_planner.h
│ ├── model.h
│ ├── nnapi_delegate.h
│ ├── optional_debug_tools.h
│ ├── schema
│ │ └── schema_generated.h
│ ├── simple_memory_arena.h
│ ├── string.h
│ ├── string_util.h
│ ├── tools
│ │ ├── gen_op_registration.h
│ │ ├── mutable_op_resolver.h
│ │ └── verifier.h
│ └── version.h
└── lib64
├── libtensorflow-lite.a
└── pkgconfig
└── tensorflow-lite.pc
To 'make' project with Tensorflow-lite, we have to set C++ version up to 11. In my case, I used version 14.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
To include headers(tensorflow, flatbuffers)
We have to set include path at CMakeLists.txt
likes below.
include_directories(
${PATH_TO_HEADERS_DIR}
)
To link with libraries, the required libraries should be defined at the CMakeLists.txt
file.
I defined below three libraries with target_link_libraries
.
target_link_libraries( output
${PROJECT_SOURCE_DIR}/lib64/libtensorflow-lite.a
pthread
dl
)
pthread
and dl
are also linked because Tensorflow-lite requires those libraries.