Initial support of CMake for TensorFlow Lite
README.md is also added. These commands show a way to use it. $ git clone https://github.com/tensorflow/tensorflow.git tensorflow_src $ mkdir tflite_build && cd tflite_build $ cmake ../tensorflow_src/tensorflow/lite $ cmake --build . -j PiperOrigin-RevId: 327736060 Change-Id: I35acf01b0b33156db5537c146c35de7dc534bb7e
This commit is contained in:
parent
d523827b79
commit
ec59a624ac
341
tensorflow/lite/CMakeLists.txt
Normal file
341
tensorflow/lite/CMakeLists.txt
Normal file
@ -0,0 +1,341 @@
|
||||
#
|
||||
# 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 Tensorflow Lite runtime.
|
||||
#
|
||||
# WARNING: This is an experimental that is subject to change.
|
||||
# This has only been tested on Windows, Linux and macOS.
|
||||
#
|
||||
# The following are not currently supported:
|
||||
# - GPU acceleration
|
||||
# - Android
|
||||
# - iOS
|
||||
# - Micro backend
|
||||
# - Tests
|
||||
# - Many features in experimental
|
||||
# - Host Tools (i.e conversion / analysis tools etc.)
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
# Double colon in target name means ALIAS or IMPORTED target.
|
||||
cmake_policy(SET CMP0028 NEW)
|
||||
# Enable MACOSX_RPATH (@rpath) for built dynamic libraries.
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
project(tensorflow-lite C CXX)
|
||||
set(TENSORFLOW_SOURCE_DIR "" CACHE PATH
|
||||
"Directory that contains the TensorFlow project"
|
||||
)
|
||||
if(NOT TENSORFLOW_SOURCE_DIR)
|
||||
set(TENSORFLOW_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
|
||||
endif()
|
||||
set(TF_SOURCE_DIR "${TENSORFLOW_SOURCE_DIR}/tensorflow")
|
||||
set(TFLITE_SOURCE_DIR "${CMAKE_SOURCE_DIR}")
|
||||
set(CMAKE_MODULE_PATH "${TFLITE_SOURCE_DIR}/tools/cmake/modules" ${CMAKE_MODULE_PATH})
|
||||
set(CMAKE_PREFIX_PATH "${TFLITE_SOURCE_DIR}/tools/cmake/modules" ${CMAKE_PREFIX_PATH})
|
||||
|
||||
option(TFLITE_ENABLE_RUY "Enable experimental RUY integration" OFF)
|
||||
option(TFLITE_ENABLE_RESOURCE "Enable experimental support for resources" ON)
|
||||
option(TFLITE_ENABLE_NNAPI "Enable NNAPI (Android only)." ON)
|
||||
option(TFLITE_ENABLE_MMAP "Enable MMAP (unsupported on Windows)" ON)
|
||||
option(TFLITE_ENABLE_GPU "Enable GPU (not supported)" OFF)
|
||||
# This must be enabled when converting from TF models with SELECT_TF_OPS
|
||||
# enabled.
|
||||
# https://www.tensorflow.org/lite/guide/ops_select#converting_the_model
|
||||
# This is currently not supported.
|
||||
option(TFLITE_ENABLE_FLEX "Enable SELECT_TF_OPS" OFF) # TODO: Add support
|
||||
option(TFLITE_ENABLE_XNNPACK "Enable XNNPACK backend" OFF) # TODO: Add XNNPACK
|
||||
option(TFLITE_ENABLE_PROFILING "Enable profiling" OFF)
|
||||
set(CMAKE_CXX_STANDARD 14) # Some components require C++14.
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(_TFLITE_ENABLE_NNAPI "${TFLITE_ENABLE_NNAPI}")
|
||||
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
|
||||
set(_TFLITE_ENABLE_NNAPI OFF)
|
||||
endif()
|
||||
set(_TFLITE_ENABLE_MMAP "${TFLITE_ENABLE_MMAP}")
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
# See https://github.com/tensorflow/tensorflow/blob/\
|
||||
# 2b96f3662bd776e277f86997659e61046b56c315/tensorflow/lite/tools/make/\
|
||||
# Makefile#L157
|
||||
set(_TFLITE_ENABLE_MMAP OFF)
|
||||
endif()
|
||||
# Simplifies inclusion of non-test sources and headers from a directory.
|
||||
# SOURCE_DIR: Directory to search for files.
|
||||
# SOURCES_VAR: Variable to append with all matching *.cc and *.h files.
|
||||
# [FILTER expression0 .. expressionN]:
|
||||
# Additional regular expressions to filter the set of matching
|
||||
# files. By default, all files ending in "(_test|test_util)\\.(cc|h)" are
|
||||
# removed.
|
||||
# [RECURSE]: Whether to recursively search SOURCE_DIR.
|
||||
macro(populate_source_vars SOURCE_DIR SOURCES_VAR)
|
||||
cmake_parse_arguments(ARGS "RECURSE" "" "FILTER" ${ARGN})
|
||||
if(ARGS_RECURSE)
|
||||
set(GLOB_OP GLOB_RECURSE)
|
||||
else()
|
||||
set(GLOB_OP GLOB)
|
||||
endif()
|
||||
set(DEFAULT_FILE_FILTER ".*(_test|test_util)\\.(c|cc|h)$")
|
||||
file(${GLOB_OP} FOUND_SOURCES "${SOURCE_DIR}/*.*")
|
||||
list(FILTER FOUND_SOURCES INCLUDE REGEX ".*\\.(c|cc|h)$")
|
||||
list(FILTER FOUND_SOURCES EXCLUDE REGEX "${DEFAULT_FILE_FILTER}")
|
||||
foreach(FILE_FILTER ${ARGS_FILTER})
|
||||
list(FILTER FOUND_SOURCES EXCLUDE REGEX "${FILE_FILTER}")
|
||||
endforeach()
|
||||
list(APPEND ${SOURCES_VAR} ${FOUND_SOURCES})
|
||||
endmacro()
|
||||
# Simplifies inclusion of non-test sources and headers from a directory
|
||||
# relative to TFLITE_SOURCE_DIR. See populate_source_vars() for the
|
||||
# description of arguments including and following SOURCES_VAR.
|
||||
macro(populate_tflite_source_vars RELATIVE_DIR SOURCES_VAR)
|
||||
populate_source_vars(
|
||||
"${TFLITE_SOURCE_DIR}/${RELATIVE_DIR}" ${SOURCES_VAR} ${ARGN}
|
||||
)
|
||||
endmacro()
|
||||
# Simplifies inclusion of non-test sources and headers from a directory
|
||||
# relative to TF_SOURCE_DIR. See populate_source_vars() for the description of
|
||||
# arguments including and following SOURCES_VAR.
|
||||
macro(populate_tf_source_vars RELATIVE_DIR SOURCES_VAR)
|
||||
populate_source_vars(
|
||||
"${TF_SOURCE_DIR}/${RELATIVE_DIR}" ${SOURCES_VAR} ${ARGN}
|
||||
)
|
||||
endmacro()
|
||||
# Find TensorFlow Lite dependencies.
|
||||
find_package(absl REQUIRED CONFIG)
|
||||
find_package(eigen REQUIRED)
|
||||
find_package(farmhash REQUIRED)
|
||||
find_package(fft2d REQUIRED)
|
||||
find_package(flatbuffers REQUIRED)
|
||||
find_package(gemmlowp REQUIRED)
|
||||
find_package(neon2sse REQUIRED)
|
||||
find_package(ruy REQUIRED)
|
||||
# Generate TensorFlow Lite FlatBuffer code.
|
||||
# This is not currently neccessary since the generated code is checked into
|
||||
# the repository but it would likely be preferable to do this in future.
|
||||
# NOTE: This will not work for cross compilation (e.g for iOS, Android etc.)
|
||||
# as flatc needs to be compiled with the host toolchain and this currently
|
||||
# builds with the target toolchain. Instead this should recursively call
|
||||
# cmake with the default host toolchain to build flatc.
|
||||
set(TFLITE_FLATBUFFERS_SCHEMAS "${TFLITE_SOURCE_DIR}/schema/schema.fbs")
|
||||
set(TFLITE_FLATBUFFERS_GEN_DIR
|
||||
"${CMAKE_BINARY_DIR}/flatbuffers_generated/"
|
||||
)
|
||||
set(TFLITE_FLATBUFFERS_HDRS "")
|
||||
foreach(INPUT_SCHEMA ${TFLITE_FLATBUFFERS_SCHEMAS})
|
||||
file(RELATIVE_PATH FILENAME "${TENSORFLOW_SOURCE_DIR}" "${INPUT_SCHEMA}")
|
||||
get_filename_component(OUTPUT_DIR
|
||||
"${TFLITE_FLATBUFFERS_GEN_DIR}/${FILENAME}" DIRECTORY
|
||||
)
|
||||
get_filename_component(OUTPUT_BASENAME
|
||||
"${FILENAME}" NAME_WE
|
||||
)
|
||||
set(OUTPUT_FILENAME "${OUTPUT_DIR}/${OUTPUT_BASENAME}_generated.h")
|
||||
list(APPEND TFLITE_FLATBUFFERS_HDRS "${OUTPUT_FILENAME}")
|
||||
add_custom_command(
|
||||
OUTPUT "${OUTPUT_FILENAME}"
|
||||
COMMAND flatc
|
||||
--cpp
|
||||
--gen-mutable
|
||||
--gen-object-api
|
||||
--reflect-names
|
||||
-I "${TENSORFLOW_SOURCE_DIR}"
|
||||
-o "${OUTPUT_DIR}"
|
||||
"${INPUT_SCHEMA}"
|
||||
DEPENDS
|
||||
"${INPUT_SCHEMA}")
|
||||
endforeach()
|
||||
set(TF_TARGET_PRIVATE_OPTIONS "")
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
|
||||
# TensorFlow uses a heap of deprecated proto fields so surpress these
|
||||
# warnings until they're fixed.
|
||||
list(APPEND TF_TARGET_PRIVATE_OPTIONS "-Wno-deprecated-declarations")
|
||||
endif()
|
||||
# Additional compiler flags used when compiling TF Lite.
|
||||
set(TFLITE_TARGET_PUBLIC_OPTIONS "")
|
||||
set(TFLITE_TARGET_PRIVATE_OPTIONS "")
|
||||
# Additional library dependencies based upon enabled features.
|
||||
set(TFLITE_TARGET_DEPENDENCIES "")
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
|
||||
# TFLite uses deprecated methods in neon2sse which generates a huge number of
|
||||
# warnings so surpress these until they're fixed.
|
||||
list(APPEND TFLITE_TARGET_PRIVATE_OPTIONS "-Wno-deprecated-declarations")
|
||||
endif()
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
# Use NOMINMAX to disable the min / max macros in windows.h as they break
|
||||
# use of std::min std::max.
|
||||
# Use NOGDI to ERROR macro which breaks TensorFlow logging.
|
||||
list(APPEND TFLITE_TARGET_PRIVATE_OPTIONS "-DNOMINMAX" "-DNOGDI")
|
||||
endif()
|
||||
# Build a list of source files to compile into the TF Lite library.
|
||||
populate_tflite_source_vars("." TFLITE_SRCS)
|
||||
if(_TFLITE_ENABLE_MMAP)
|
||||
list(FILTER TFLITE_SRCS EXCLUDE REGEX ".*mmap_allocation_disabled\\.cc$")
|
||||
else()
|
||||
list(FILTER TFLITE_SRCS EXCLUDE REGEX ".*mmap_allocation\\.cc$")
|
||||
endif()
|
||||
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
|
||||
list(FILTER TFLITE_SRCS EXCLUDE REGEX ".*minimal_logging_android\\.cc$")
|
||||
endif()
|
||||
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "iOS")
|
||||
list(FILTER TFLITE_SRCS EXCLUDE REGEX ".*minimal_logging_ios\\.cc$")
|
||||
endif()
|
||||
populate_tflite_source_vars("core" TFLITE_CORE_SRCS)
|
||||
populate_tflite_source_vars("core/api" TFLITE_CORE_API_SRCS)
|
||||
populate_tflite_source_vars("c" TFLITE_C_SRCS)
|
||||
populate_tflite_source_vars("delegates" TFLITE_DELEGATES_SRCS)
|
||||
if(TFLITE_ENABLE_FLEX)
|
||||
message(FATAL_ERROR "TF Lite Flex delegate is currently not supported.")
|
||||
populate_tflite_source_vars("delegates/flex" TFLITE_DELEGATES_FLEX_SRCS)
|
||||
list(APPEND TFLITE_TARGET_DEPENDENCIES
|
||||
absl::inlined_vector
|
||||
absl::optional
|
||||
absl::type_traits
|
||||
)
|
||||
endif()
|
||||
if(TFLITE_ENABLE_GPU)
|
||||
# Implementation is under delegates/gpu.
|
||||
message(FATAL_ERROR
|
||||
"GPU acceleration is not currently supported in CMake builds"
|
||||
)
|
||||
endif()
|
||||
if(_TFLITE_ENABLE_NNAPI)
|
||||
populate_tflite_source_vars("delegates/nnapi"
|
||||
TFLITE_DELEGATES_NNAPI_SRCS
|
||||
FILTER "(_test_list|_disabled)\\.(cc|h)$"
|
||||
)
|
||||
populate_tflite_source_vars(
|
||||
"nnapi" TFLITE_NNAPI_SRCS FILTER "(_disabled)\\.(cc|h)$"
|
||||
)
|
||||
else()
|
||||
set(TFLITE_DELEGATES_NNAPI_SRCS
|
||||
"${TFLITE_SOURCE_DIR}/delegates/nnapi/nnapi_delegate_disabled.cc"
|
||||
)
|
||||
set(TFLITE_NNAPI_SRCS
|
||||
"${TFLITE_SOURCE_DIR}/nnapi/nnapi_implementation_disabled.cc"
|
||||
)
|
||||
endif()
|
||||
if(TFLITE_ENABLE_XNNPACK)
|
||||
populate_tflite_source_vars("delegates/xnnpack"
|
||||
TFLITE_DELEGATES_XNNPACK_SRCS
|
||||
)
|
||||
endif()
|
||||
if (TFLITE_ENABLE_RESOURCE)
|
||||
populate_tflite_source_vars("experimental/resource"
|
||||
TFLITE_EXPERIMENTAL_RESOURCE_SRCS
|
||||
)
|
||||
endif()
|
||||
populate_tflite_source_vars("experimental/ruy"
|
||||
TFLITE_EXPERIMENTAL_RUY_SRCS
|
||||
FILTER
|
||||
".*(test(_fast|_slow|_special_specs))\\.(cc|h)$"
|
||||
".*(benchmark|tune_tool|example)\\.(cc|h)$"
|
||||
)
|
||||
populate_tflite_source_vars("experimental/ruy/profiler"
|
||||
TFLITE_EXPERIMENTAL_RUY_PROFILER_SRCS
|
||||
FILTER ".*(test|test_instrumented_library)\\.(cc|h)$"
|
||||
)
|
||||
if(TFLITE_ENABLE_RUY)
|
||||
list(APPEND TFLITE_TARGET_PUBLIC_OPTIONS "-DTFLITE_WITH_RUY")
|
||||
endif()
|
||||
populate_tflite_source_vars("kernels"
|
||||
TFLITE_KERNEL_SRCS
|
||||
FILTER ".*(_test_util_internal|test_main)\\.(cc|h)"
|
||||
)
|
||||
populate_tflite_source_vars("kernels/internal" TFLITE_KERNEL_INTERNAL_SRCS)
|
||||
populate_tflite_source_vars("kernels/internal/optimized"
|
||||
TFLITE_KERNEL_INTERNAL_OPT_SRCS
|
||||
)
|
||||
populate_tflite_source_vars("kernels/internal/optimized/integer_ops"
|
||||
TFLITE_KERNEL_INTERNAL_OPT_INTEGER_OPS_SRCS
|
||||
)
|
||||
populate_tflite_source_vars("kernels/internal/optimized/sparse_ops"
|
||||
TFLITE_KERNEL_INTERNAL_OPT_SPARSE_OPS_SRCS
|
||||
)
|
||||
populate_tflite_source_vars("kernels/internal/reference"
|
||||
TFLITE_KERNEL_INTERNAL_REF_SRCS
|
||||
)
|
||||
populate_tflite_source_vars("kernels/internal/reference/integer_ops"
|
||||
TFLITE_KERNEL_INTERNAL_REF_INTEGER_OPS_SRCS
|
||||
)
|
||||
populate_tflite_source_vars("kernels/internal/reference/sparse_ops"
|
||||
TFLITE_KERNEL_INTERNAL_REF_SPARSE_OPS_SRCS
|
||||
)
|
||||
if(TFLITE_ENABLE_PROFILING)
|
||||
populate_tflite_source_vars("profiling" TFLITE_KERNEL_PROFILING_SRCS)
|
||||
endif()
|
||||
populate_tflite_source_vars("tools/optimize" TFLITE_TOOLS_OPTIMIZE_SRCS)
|
||||
populate_tflite_source_vars("tools/optimize/calibration"
|
||||
TFLITE_TOOLS_OPTIMIZE_CALIBRATION_SRCS
|
||||
)
|
||||
populate_tflite_source_vars("tools/optimize/calibration/builtin_logging_ops"
|
||||
TFLITE_TOOLS_OPTIMIZE_CALIBRATION_OPS_SRCS
|
||||
)
|
||||
populate_tflite_source_vars("tools/optimize/sparsity"
|
||||
TFLITE_TOOLS_OPTIMIZE_SPARSITY_SRCS
|
||||
)
|
||||
add_library(tensorflowlite
|
||||
${TFLITE_CORE_API_SRCS}
|
||||
${TFLITE_CORE_SRCS}
|
||||
${TFLITE_C_SRCS}
|
||||
${TFLITE_DELEGATES_FLEX_SRCS}
|
||||
${TFLITE_DELEGATES_NNAPI_SRCS}
|
||||
${TFLITE_DELEGATES_SRCS}
|
||||
${TFLITE_DELEGATES_XNNPACK_SRCS}
|
||||
${TFLITE_EXPERIMENTAL_RESOURCE_SRCS}
|
||||
${TFLITE_EXPERIMENTAL_RUY_PROFILER_SRCS}
|
||||
${TFLITE_EXPERIMENTAL_RUY_SRCS}
|
||||
${TFLITE_FLATBUFFERS_HDRS}
|
||||
${TFLITE_KERNEL_INTERNAL_OPT_INTEGER_OPS_SRCS}
|
||||
${TFLITE_KERNEL_INTERNAL_OPT_SPARSE_OPS_SRCS}
|
||||
${TFLITE_KERNEL_INTERNAL_OPT_SRCS}
|
||||
${TFLITE_KERNEL_INTERNAL_REF_INTEGER_OPS_SRCS}
|
||||
${TFLITE_KERNEL_INTERNAL_REF_SPARSE_OPS_SRCS}
|
||||
${TFLITE_KERNEL_INTERNAL_REF_SRCS}
|
||||
${TFLITE_KERNEL_INTERNAL_SRCS}
|
||||
${TFLITE_KERNEL_PROFILING_SRCS}
|
||||
${TFLITE_KERNEL_SRCS}
|
||||
${TFLITE_NNAPI_SRCS}
|
||||
${TFLITE_SRCS}
|
||||
${TFLITE_TOOLS_OPTIMIZE_CALIBRATION_OPS_SRCS}
|
||||
${TFLITE_TOOLS_OPTIMIZE_CALIBRATION_SRCS}
|
||||
${TFLITE_TOOLS_OPTIMIZE_SPARSITY_SRCS}
|
||||
${TFLITE_TOOLS_OPTIMIZE_SRCS}
|
||||
)
|
||||
target_link_libraries(tensorflowlite
|
||||
PUBLIC
|
||||
Eigen3::Eigen
|
||||
NEON_2_SSE
|
||||
absl::flags
|
||||
absl::hash
|
||||
absl::status
|
||||
absl::strings
|
||||
absl::synchronization
|
||||
absl::variant
|
||||
farmhash
|
||||
fft2d_fftsg2d
|
||||
flatbuffers
|
||||
gemmlowp
|
||||
ruy
|
||||
${TFLITE_TARGET_DEPENDENCIES}
|
||||
)
|
||||
target_include_directories(tensorflowlite
|
||||
PUBLIC
|
||||
"${TENSORFLOW_SOURCE_DIR}"
|
||||
PRIVATE
|
||||
"${TFLITE_FLATBUFFERS_GEN_DIR}"
|
||||
)
|
||||
target_compile_options(tensorflowlite
|
||||
PUBLIC ${TFLITE_TARGET_PUBLIC_OPTIONS}
|
||||
PRIVATE ${TFLITE_TARGET_PRIVATE_OPTIONS}
|
||||
)
|
||||
add_library(tensorflow::tensorflowlite ALIAS tensorflowlite)
|
50
tensorflow/lite/tools/cmake/README.md
Normal file
50
tensorflow/lite/tools/cmake/README.md
Normal file
@ -0,0 +1,50 @@
|
||||
# Build TensorFlow Lite with CMake
|
||||
|
||||
This page describes how to build the TensorFlow Lite static library with CMake
|
||||
tool.
|
||||
|
||||
The following instructions have been tested on Ubuntu 16.04.3 64-bit PC (AMD64)
|
||||
and TensorFlow devel docker image
|
||||
[tensorflow/tensorflow:devel](https://hub.docker.com/r/tensorflow/tensorflow/tags/).
|
||||
|
||||
**Note:** This is an experimental that is subject to change.
|
||||
|
||||
**Note:** The following are not currently supported: Android, iOS, Tests and
|
||||
Host Tools (i.e benchmark / analysis tools etc.)
|
||||
|
||||
#### Step 1. Install CMake tool
|
||||
|
||||
It requires CMake 3.16 or higher. On Ubunutu, you can simply run the following
|
||||
command.
|
||||
|
||||
```sh
|
||||
sudo apt-get install cmake
|
||||
```
|
||||
|
||||
Or you can follow [the offcial cmake installation guide](https://cmake.org/install/)
|
||||
|
||||
#### Step 2. Clone TensorFlow repository
|
||||
|
||||
```sh
|
||||
git clone https://github.com/tensorflow/tensorflow.git tensorflow_src
|
||||
```
|
||||
|
||||
**Note:** If you're using the TensorFlow Docker image, the repo is already
|
||||
provided in `/tensorflow_src/`.
|
||||
|
||||
#### Step 3. Create CMake build directory and run CMake tool
|
||||
|
||||
```sh
|
||||
mkdir tflite_build
|
||||
cd tflite_build
|
||||
cmake ../tensorflow_src/tensorflow/lite
|
||||
```
|
||||
|
||||
#### Step 4. Build TensorFlow Lite
|
||||
|
||||
```sh
|
||||
cmake --build . -j
|
||||
```
|
||||
|
||||
**Note:** This should compile a static library `libtensorflow-lite.a` in the
|
||||
current directory.
|
24
tensorflow/lite/tools/cmake/modules/Findeigen.cmake
Normal file
24
tensorflow/lite/tools/cmake/modules/Findeigen.cmake
Normal file
@ -0,0 +1,24 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
# tensorflow-lite uses find_package for this package, so override the system
|
||||
# installation and build from source instead.
|
||||
include(eigen)
|
||||
if(eigen_POPULATED)
|
||||
set(EIGEN_FOUND TRUE)
|
||||
get_target_property(EIGEN_INCLUDE_DIRS eigen INTERFACE_DIRECTORIES)
|
||||
set(EIGEN_LIBRARIES Eigen3::Eigen)
|
||||
endif()
|
||||
|
25
tensorflow/lite/tools/cmake/modules/Findfarmhash.cmake
Normal file
25
tensorflow/lite/tools/cmake/modules/Findfarmhash.cmake
Normal file
@ -0,0 +1,25 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
# tensorflow-lite uses find_package for this package, so override the system
|
||||
# installation and build from source instead.
|
||||
include(farmhash)
|
||||
if(farmhash_POPULATED)
|
||||
set(FARMHASH_FOUND TRUE)
|
||||
get_target_property(FARMHASH_INCLUDE_DIRS farmhash INTERFACE_DIRECTORIES)
|
||||
add_library(farmhash::farmhash ALIAS farmhash)
|
||||
set(FARMHASH_LIBRARIES farmhash::farmhash)
|
||||
endif()
|
||||
|
37
tensorflow/lite/tools/cmake/modules/Findfft2d.cmake
Normal file
37
tensorflow/lite/tools/cmake/modules/Findfft2d.cmake
Normal file
@ -0,0 +1,37 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
# tensorflow-lite uses find_package for this package, so override the system
|
||||
# installation and build from source instead.
|
||||
include(fft2d)
|
||||
if(fft2d_POPULATED)
|
||||
set(FFT2D_FOUND TRUE CACHE BOOL "Found FF2D")
|
||||
get_target_property(FFT2D_INCLUDE_DIRS fft2d INCLUDE_DIRECTORIES)
|
||||
set(FFT2D_INCLUDE_DIRS ${FFT2D_INCLUDE_DIRS} CACHE STRING
|
||||
"FFT2D include dirs"
|
||||
)
|
||||
set(FFT2D_LIBRARIES
|
||||
fft2d_alloc
|
||||
fft2d_fft4f2d
|
||||
fft2d_fftsg
|
||||
fft2d_fftsg2d
|
||||
fft2d_fftsg3d
|
||||
fft2d_shrtdct
|
||||
CACHE
|
||||
STRING
|
||||
"FFT2D libraries"
|
||||
)
|
||||
endif()
|
||||
|
27
tensorflow/lite/tools/cmake/modules/Findflatbuffers.cmake
Normal file
27
tensorflow/lite/tools/cmake/modules/Findflatbuffers.cmake
Normal file
@ -0,0 +1,27 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
# tensorflow-lite uses find_package for this package, so override the system
|
||||
# installation and build from source instead.
|
||||
include(flatbuffers)
|
||||
if(flatbuffers_POPULATED)
|
||||
set(FLATBUFFERS_FOUND TRUE)
|
||||
get_target_property(FLATBUFFERS_INCLUDE_DIRS flatbuffers INCLUDE_DIRECTORIES)
|
||||
set(FLATBUFFERS_LIBRARIES flatbuffers)
|
||||
set(FLATBUFFERS_PROJECT_DIR "${flatbuffers_SOURCE_DIR}" CACHE STRING
|
||||
"Flatbuffers project dir"
|
||||
)
|
||||
endif()
|
||||
|
29
tensorflow/lite/tools/cmake/modules/Findgemmlowp.cmake
Normal file
29
tensorflow/lite/tools/cmake/modules/Findgemmlowp.cmake
Normal file
@ -0,0 +1,29 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
# tensorflow-lite uses find_package for this package, so override the system
|
||||
# installation and build from source instead.
|
||||
include(gemmlowp)
|
||||
if(gemmlowp_POPULATED)
|
||||
set(GEMMLOWP_FOUND TRUE)
|
||||
get_target_property(GEMMLOWP_INCLUDE_DIRS gemmlowp INTERFACE_DIRECTORIES)
|
||||
set(GEMMLOWP_LIBRARIES
|
||||
gemmlowp
|
||||
gemmlowp_fixedpoint
|
||||
gemmlowp_profiler
|
||||
gemmlowp_eight_bit_int_gemm
|
||||
)
|
||||
endif()
|
||||
|
23
tensorflow/lite/tools/cmake/modules/Findneon2sse.cmake
Normal file
23
tensorflow/lite/tools/cmake/modules/Findneon2sse.cmake
Normal file
@ -0,0 +1,23 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
# tensorflow-lite uses find_package for this package, so override the system
|
||||
# installation and build from source instead.
|
||||
include(neon2sse)
|
||||
if(neon2sse_POPULATED)
|
||||
set(NEON2SSE_FOUND TRUE)
|
||||
get_target_property(NEON2SSE_INCLUDE_DIRS NEON_2_SSE INTERFACE_DIRECTORIES)
|
||||
set(NEON2SSE_LIBRARIES NEON_2_SSE)
|
||||
endif()
|
16
tensorflow/lite/tools/cmake/modules/Findruy.cmake
Normal file
16
tensorflow/lite/tools/cmake/modules/Findruy.cmake
Normal file
@ -0,0 +1,16 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
include(ruy)
|
@ -0,0 +1,583 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Pairs of regex --> replacement strings that map Git repositories to archive
|
||||
# URLs. GIT_COMMIT is replaced with the hash of the commit.
|
||||
set(OVERRIDABLE_FETCH_CONTENT_GITHUB_MATCH
|
||||
"^https?://github.com/([^/]+)/([^/.]+)(\\.git)?\$"
|
||||
)
|
||||
set(OVERRIDABLE_FETCH_CONTENT_GITHUB_REPLACE
|
||||
"https://github.com/\\1/\\2/archive/GIT_COMMIT.zip"
|
||||
)
|
||||
set(OVERRIDABLE_FETCH_CONTENT_GITLAB_MATCH
|
||||
"^https?://gitlab.com/([^/]+)/([^/.]+)(\\.git)?"
|
||||
)
|
||||
set(OVERRIDABLE_FETCH_CONTENT_GITLAB_REPLACE
|
||||
"https://gitlab.com/\\1/\\2/-/archive/GIT_COMMIT/\\2-GIT_COMMIT.tar.gz"
|
||||
)
|
||||
set(OVERRIDABLE_FETCH_CONTENT_GOOGLESOURCE_MATCH
|
||||
"^(https?://[^.]+\\.googlesource\\.com/.*)"
|
||||
)
|
||||
set(OVERRIDABLE_FETCH_CONTENT_GOOGLESOURCE_REPLACE
|
||||
"\\1/+archive/GIT_COMMIT.tar.gz"
|
||||
)
|
||||
# List of prefixes for regex match and replacement variables that map Git
|
||||
# repositories to archive URLs.
|
||||
list(APPEND OVERRIDABLE_FETCH_CONTENT_GIT_TRANSFORMS
|
||||
OVERRIDABLE_FETCH_CONTENT_GITHUB
|
||||
OVERRIDABLE_FETCH_CONTENT_GITLAB
|
||||
OVERRIDABLE_FETCH_CONTENT_GOOGLESOURCE
|
||||
)
|
||||
|
||||
# Pairs of regex --> replacement strings that map Git repositories to raw file
|
||||
# URLs.
|
||||
set(OVERRIDABLE_FETCH_CONTENT_GITHUB_FILE_MATCH
|
||||
"${OVERRIDABLE_FETCH_CONTENT_GITHUB_MATCH}"
|
||||
)
|
||||
set(OVERRIDABLE_FETCH_CONTENT_GITHUB_FILE_REPLACE
|
||||
"https://raw.githubusercontent.com/\\1/\\2/GIT_COMMIT/FILE_PATH"
|
||||
)
|
||||
set(OVERRIDABLE_FETCH_CONTENT_GITLAB_FILE_MATCH
|
||||
"${OVERRIDABLE_FETCH_CONTENT_GITLAB_MATCH}"
|
||||
)
|
||||
set(OVERRIDABLE_FETCH_CONTENT_GITLAB_FILE_REPLACE
|
||||
"https://gitlab.com/\\1/\\2/-/raw/GIT_COMMIT/FILE_PATH"
|
||||
)
|
||||
set(OVERRIDABLE_FETCH_CONTENT_GOOGLESOURCE_FILE_MATCH
|
||||
"${OVERRIDABLE_FETCH_CONTENT_GOOGLESOURCE_MATCH}"
|
||||
)
|
||||
# This isn't the raw file, gitiles doesn't support raw file download without
|
||||
# decoding the file from base64.
|
||||
set(OVERRIDABLE_FETCH_CONTENT_GOOGLESOURCE_FILE_REPLACE
|
||||
"\\1/+/GIT_COMMIT/FILE_PATH"
|
||||
)
|
||||
|
||||
# List of prefixes for regex match and replacement variables that map Git
|
||||
# repositories to archive URLs.
|
||||
list(APPEND OVERRIDABLE_FETCH_CONTENT_GIT_FILE_TRANSFORMS
|
||||
OVERRIDABLE_FETCH_CONTENT_GITHUB_FILE
|
||||
OVERRIDABLE_FETCH_CONTENT_GITLAB_FILE
|
||||
OVERRIDABLE_FETCH_CONTENT_GOOGLESOURCE_FILE
|
||||
)
|
||||
|
||||
# Try applying replacements to string.
|
||||
#
|
||||
# TRANSFORMS: List which contains prefixes for _MATCH / _REPLACE replacements
|
||||
# to try. For example, given the list "FOO" this will try to apply a regex
|
||||
# replacement with the value of FOO_MATCH and FOO_REPLACE.
|
||||
# TO_REPLACE: String to apply replacements to.
|
||||
# OUTPUT_VAR: Name of the variable to store the URL if successful. If
|
||||
# conversion fails this variable will be empty.
|
||||
function(_ApplyReplacements TRANSFORMS TO_REPLACE OUTPUT_VAR)
|
||||
foreach(PREFIX ${TRANSFORMS})
|
||||
message(VERBOSE "Try converting ${GIT_REPOSITORY} with ${${PREFIX}_MATCH}")
|
||||
set(MATCH "${${PREFIX}_MATCH}")
|
||||
set(REPLACE "${${PREFIX}_REPLACE}")
|
||||
if(MATCH AND REPLACE)
|
||||
string(REGEX REPLACE
|
||||
"${MATCH}"
|
||||
"${REPLACE}"
|
||||
REPLACED
|
||||
"${TO_REPLACE}"
|
||||
)
|
||||
if(NOT "${REPLACED}" STREQUAL "${TO_REPLACE}")
|
||||
set(${OUTPUT_VAR} "${REPLACED}" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
|
||||
# Try to convert a Git repository to an archive URL.
|
||||
#
|
||||
# GIT_REPOSITORY: Repository URL to convert.
|
||||
# GIT_COMMIT: Commit hash or tag to convert.
|
||||
# REPORT_WARNING: Whether to report a warning if conversion fails.
|
||||
# OUTPUT_VAR: Name of the variable to store the URL if successful. If
|
||||
# conversion fails this variable will be empty.
|
||||
function(_GitRepoArchiveUrl GIT_REPOSITORY GIT_COMMIT REPORT_WARNING OUTPUT_VAR)
|
||||
list(REMOVE_DUPLICATES OVERRIDABLE_FETCH_CONTENT_GIT_TRANSFORMS)
|
||||
_ApplyReplacements(
|
||||
"${OVERRIDABLE_FETCH_CONTENT_GIT_TRANSFORMS}"
|
||||
"${GIT_REPOSITORY}"
|
||||
REPLACED
|
||||
)
|
||||
if(REPLACED)
|
||||
string(REPLACE "GIT_COMMIT" "${GIT_COMMIT}" WITH_COMMIT "${REPLACED}")
|
||||
message(VERBOSE "${GIT_REPOSITORY} / ${GIT_COMMIT} --> ${WITH_COMMIT}")
|
||||
set(${OUTPUT_VAR} "${WITH_COMMIT}" PARENT_SCOPE)
|
||||
elseif(REPORT_WARNING)
|
||||
message(WARNING
|
||||
"Unable to map ${GIT_REPOSITORY} / ${GIT_COMMIT} to an archive URL"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
# Try to convert a Git repository, commit and relative path to a link to the
|
||||
# file.
|
||||
#
|
||||
# GIT_REPOSITORY: Repository URL to convert.
|
||||
# GIT_COMMIT: Commit hash or tag to convert.
|
||||
# FILE_PATH: Path to the file.
|
||||
# OUTPUT_VAR: Name of the variable to store the URL if successful. If
|
||||
# conversion fails this variable will be empty.
|
||||
function(_GitRepoFileUrl GIT_REPOSITORY GIT_COMMIT FILE_PATH OUTPUT_VAR)
|
||||
list(REMOVE_DUPLICATES OVERRIDABLE_FETCH_CONTENT_GIT_FILE_TRANSFORMS)
|
||||
_ApplyReplacements(
|
||||
"${OVERRIDABLE_FETCH_CONTENT_GIT_FILE_TRANSFORMS}"
|
||||
"${GIT_REPOSITORY}"
|
||||
REPLACED
|
||||
)
|
||||
if(REPLACED)
|
||||
string(REPLACE "GIT_COMMIT" "${GIT_COMMIT}" WITH_COMMIT "${REPLACED}")
|
||||
string(REPLACE "FILE_PATH" "${FILE_PATH}" WITH_FILE "${WITH_COMMIT}")
|
||||
message(VERBOSE
|
||||
"${GIT_REPOSITORY} / ${GIT_COMMIT} / ${FILE_PATH} --> ${WITH_FILE}"
|
||||
)
|
||||
set(${OUTPUT_VAR} "${WITH_FILE}" PARENT_SCOPE)
|
||||
else()
|
||||
message(WARNING
|
||||
"Unable to map ${GIT_REPOSITORY} / ${GIT_COMMIT} / ${FILE_PATH} to a URL"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
# Try to determine the license URL from a path within the content and
|
||||
# cache LICENSE_FILE and LICENSE_URL properties.
|
||||
#
|
||||
# CONTENT_NAME: Name of the content that hosts the license.
|
||||
# LICENSE_FILE: Relative path in the archive.
|
||||
# OUTPUT_VAR: Name of variable to store / retrieve the license URL.
|
||||
function(_LicenseFileToUrl CONTENT_NAME LICENSE_FILE OUTPUT_VAR)
|
||||
foreach(PROPERTY GIT_REPOSITORY GIT_COMMIT LICENSE_URL)
|
||||
_OverridableFetchContent_GetProperty(
|
||||
"${CONTENT_NAME}"
|
||||
"${PROPERTY}"
|
||||
"${PROPERTY}"
|
||||
)
|
||||
endforeach()
|
||||
_OverridableFetchContent_SetProperty(
|
||||
"${CONTENT_NAME}"
|
||||
LICENSE_FILE
|
||||
"License for ${CONTENT_NAME}"
|
||||
"${LICENSE_FILE}"
|
||||
)
|
||||
if(NOT LICENSE_URL)
|
||||
if(GIT_REPOSITORY AND GIT_COMMIT)
|
||||
# Try to synthesize the license URL from the repo path.
|
||||
_GitRepoFileUrl(
|
||||
"${GIT_REPOSITORY}"
|
||||
"${GIT_COMMIT}"
|
||||
"${LICENSE_FILE}"
|
||||
LICENSE_URL
|
||||
)
|
||||
if(LICENSE_URL)
|
||||
_OverridableFetchContent_SetProperty(
|
||||
"${CONTENT_NAME}"
|
||||
LICENSE_URL
|
||||
"License URL for ${CONTENT_NAME}"
|
||||
"${LICENSE_URL}"
|
||||
)
|
||||
set(${OUTPUT_VAR} "${LICENSE_URL}" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
# Replacement for FetchContent_Declare() that allows the user to override the
|
||||
# download URL for Git and URL sources and also favor fetching via URL vs.
|
||||
# a Git repo using variables external to this method.
|
||||
#
|
||||
# See FetchContent_Declare() and ExternalProject_Add() for the arguments
|
||||
# supported by this method.
|
||||
#
|
||||
# In addition to FetchContent_Declare() and ExternalProject_Add() arguments,
|
||||
# this method supports LICENSE_FILE that enables the caller to specify the
|
||||
# relative path of the license in the downloaded archive which disables the
|
||||
# search for a license in OverridableFetchContent_Populate().
|
||||
# LICENSE_URL can be specified to override the URL of the LICENSE_FILE if
|
||||
# a direct link to the URL can't be formed from the download path.
|
||||
#
|
||||
# It's possible to override, GIT_REPOSITORY, GIT_TAG, URL and URL_HASH for
|
||||
# a target by setting
|
||||
# OVERRIDABLE_FETCH_CONTENT_<contentName>_<variable> where <contentName> is the
|
||||
# CONTENT_NAME argument content provided to this method and <variable> is the
|
||||
# argument of this method to override. For example, given CONTENT_NAME = foo
|
||||
# the GIT_REPOSITORY can be overridden by setting foo_GIT_REPOSITORY to the
|
||||
# value to use instead.
|
||||
#
|
||||
# To convert a GIT_REPOSITORY / GIT_TAG reference to a URL,
|
||||
# set OVERRIDABLE_FETCH_CONTENT_GIT_REPOSITORY_AND_TAG_TO_URL_<contentName>
|
||||
# to ON for one repository or
|
||||
# OVERRIDABLE_FETCH_CONTENT_GIT_REPOSITORY_AND_TAG_TO_URL to ON for all
|
||||
# repositories. This will, where possible, convert a GIT_REPOSITORY / GIT_TAG
|
||||
# reference to a URL to download instead which is much faster to copy than
|
||||
# cloning a git repo.
|
||||
#
|
||||
# If OVERRIDABLE_FETCH_CONTENT_USE_GIT is ON, when a GIT_REPOSITORY and a
|
||||
# download URL are specified this method will clone the GIT_REPOSITORY. When
|
||||
# OVERRIDABLE_FETCH_CONTENT_USE_GIT is OFF or not set and both GIT_REPOSITORY
|
||||
# and download URL are specified the download URL is used instead.
|
||||
#
|
||||
# To override the archive URL before it's passed to FetchContent_Declare()
|
||||
# set OVERRIDABLE_FETCH_CONTENT_<contentName>_MATCH to a regular expression
|
||||
# to match the archive URL and OVERRIDABLE_FETCH_CONTENT_<contentName>_REPLACE
|
||||
# with the string to replace the archive URL.
|
||||
#
|
||||
# All content names passed to this method are added to the global property
|
||||
# OVERRIDABLE_FETCH_CONTENT_LIST.
|
||||
function(OverridableFetchContent_Declare CONTENT_NAME)
|
||||
set(OVERRIDABLE_ARGS
|
||||
GIT_REPOSITORY
|
||||
GIT_TAG
|
||||
URL
|
||||
URL_HASH
|
||||
URL_MD5
|
||||
)
|
||||
set(ALL_VALUE_ARGS LICENSE_FILE LICENSE_URL ${OVERRIDABLE_ARGS})
|
||||
cmake_parse_arguments(ARGS
|
||||
""
|
||||
"${ALL_VALUE_ARGS}"
|
||||
""
|
||||
${ARGN}
|
||||
)
|
||||
# Optionally override parsed arguments with values from variables in the form
|
||||
# ${CONTENT_NAME}_${OVERRIDABLE_ARG}.
|
||||
foreach(OVERRIDABLE_ARG in ${OVERRIDABLE_ARGS})
|
||||
set(OVERRIDE_VALUE
|
||||
${OVERRIDABLE_FETCH_CONTENT_${CONTENT_NAME}_${OVERRIDABLE_ARG}}
|
||||
)
|
||||
if(NOT "${OVERRIDE_VALUE}" STREQUAL "")
|
||||
set(ARGS_${OVERRIDABLE_ARG} "${OVERRIDE_VALUE}")
|
||||
message(VERBOSE "Overriding ${OVERRIDABLE_ARG} of content "
|
||||
"${CONTENT_NAME} with '${OVERRIDE_VALUE}'"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# If specified, save the source URL so it's possible to synthesize a link to
|
||||
# the license when the content is populated.
|
||||
if(ARGS_GIT_REPOSITORY AND ARGS_GIT_TAG)
|
||||
_OverridableFetchContent_SetProperty(
|
||||
"${CONTENT_NAME}"
|
||||
GIT_REPOSITORY
|
||||
"Git repo for ${CONTENT_NAME}"
|
||||
"${ARGS_GIT_REPOSITORY}"
|
||||
)
|
||||
_OverridableFetchContent_SetProperty(
|
||||
"${CONTENT_NAME}"
|
||||
GIT_COMMIT
|
||||
"Git commit for ${CONTENT_NAME}"
|
||||
"${ARGS_GIT_TAG}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Set the license file and URL properties.
|
||||
if(ARGS_LICENSE_URL)
|
||||
_OverridableFetchContent_SetProperty(
|
||||
"${CONTENT_NAME}"
|
||||
LICENSE_URL
|
||||
"License URL for ${CONTENT_NAME}"
|
||||
"${ARGS_LICENSE_URL}"
|
||||
)
|
||||
endif()
|
||||
if(ARGS_LICENSE_FILE)
|
||||
_LicenseFileToUrl(
|
||||
"${CONTENT_NAME}"
|
||||
"${ARGS_LICENSE_FILE}"
|
||||
ARGS_LICENSE_URL
|
||||
)
|
||||
endif()
|
||||
|
||||
# Try mapping to an archive URL.
|
||||
set(ARCHIVE_URL "")
|
||||
if(ARGS_GIT_REPOSITORY AND ARGS_GIT_TAG)
|
||||
_GitRepoArchiveUrl(
|
||||
"${ARGS_GIT_REPOSITORY}"
|
||||
"${ARGS_GIT_TAG}"
|
||||
OFF
|
||||
ARCHIVE_URL
|
||||
)
|
||||
# If conversion from git repository to archive URL is enabled.
|
||||
if(OVERRIDABLE_FETCH_CONTENT_GIT_REPOSITORY_AND_TAG_TO_URL_${CONTENT_NAME}
|
||||
OR OVERRIDABLE_FETCH_CONTENT_GIT_REPOSITORY_AND_TAG_TO_URL)
|
||||
# Try converting to an archive URL.
|
||||
if(NOT ARGS_URL)
|
||||
_GitRepoArchiveUrl(
|
||||
"${ARGS_GIT_REPOSITORY}"
|
||||
"${ARGS_GIT_TAG}"
|
||||
ON
|
||||
ARGS_URL
|
||||
)
|
||||
set(ARCHIVE_URL "${ARGS_URL}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# If a download URL and git repository with tag are specified either use
|
||||
# the git repo or the download URL.
|
||||
if(ARGS_URL AND ARGS_GIT_REPOSITORY)
|
||||
if(OVERRIDABLE_FETCH_CONTENT_USE_GIT)
|
||||
unset(ARGS_URL)
|
||||
unset(ARGS_URL_HASH)
|
||||
unset(ARGS_URL_MD5)
|
||||
else()
|
||||
unset(ARGS_GIT_REPOSITORY)
|
||||
unset(ARGS_GIT_TAG)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Optionally map the archive URL to a mirror.
|
||||
if(ARGS_URL)
|
||||
_ApplyReplacements(
|
||||
"OVERRIDABLE_FETCH_CONTENT_${CONTENT_NAME}"
|
||||
"${ARGS_URL}"
|
||||
REPLACED
|
||||
)
|
||||
if(REPLACED)
|
||||
set(ARGS_URL "${REPLACED}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Save the archive URL.
|
||||
if(ARGS_URL)
|
||||
set(ARCHIVE_URL "${ARGS_URL}")
|
||||
endif()
|
||||
if(ARCHIVE_URL)
|
||||
_OverridableFetchContent_SetProperty(
|
||||
"${CONTENT_NAME}"
|
||||
ARCHIVE_URL
|
||||
"Archive URL for ${CONTENT_NAME}"
|
||||
"${ARCHIVE_URL}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Build the list of arguments to pass to FetchContent_Declare() starting with
|
||||
# the overridable arguments.
|
||||
set(OUTPUT_ARGS "")
|
||||
foreach(OVERRIDABLE_ARG ${OVERRIDABLE_ARGS})
|
||||
set(OVERRIDABLE_ARG_VALUE "${ARGS_${OVERRIDABLE_ARG}}")
|
||||
if(OVERRIDABLE_ARG_VALUE)
|
||||
list(APPEND OUTPUT_ARGS ${OVERRIDABLE_ARG} "${OVERRIDABLE_ARG_VALUE}")
|
||||
endif()
|
||||
endforeach()
|
||||
list(APPEND OUTPUT_ARGS ${ARGS_UNPARSED_ARGUMENTS})
|
||||
|
||||
# Add all defined packages to a global property.
|
||||
get_property(OVERRIDABLE_FETCH_CONTENT_LIST GLOBAL PROPERTY
|
||||
OVERRIDABLE_FETCH_CONTENT_LIST
|
||||
)
|
||||
set(DOCUMENTATION "List of all fetched content")
|
||||
define_property(GLOBAL PROPERTY OVERRIDABLE_FETCH_CONTENT_LIST
|
||||
BRIEF_DOCS "${DOCUMENTATION}"
|
||||
FULL_DOCS "${DOCUMENTATION}"
|
||||
)
|
||||
list(APPEND OVERRIDABLE_FETCH_CONTENT_LIST "${CONTENT_NAME}")
|
||||
set_property(GLOBAL PROPERTY OVERRIDABLE_FETCH_CONTENT_LIST
|
||||
"${OVERRIDABLE_FETCH_CONTENT_LIST}"
|
||||
)
|
||||
|
||||
message(VERBOSE "FetchContent_Declare(${CONTENT_NAME} ${OUTPUT_ARGS}")
|
||||
FetchContent_Declare("${CONTENT_NAME}" ${OUTPUT_ARGS})
|
||||
endfunction()
|
||||
|
||||
|
||||
# Get a property name for this module.
|
||||
# CONTENT_NAME: Name of the content associated with the FetchContent function.
|
||||
# PROPERTY_NAME: Name of the property.
|
||||
# OUTPUT_VAR: Variable to store the name in.
|
||||
function(_OverridableFetchContent_GetPropertyName CONTENT_NAME PROPERTY_NAME
|
||||
OUTPUT_VAR)
|
||||
# The implementation of FetchContent_GetProperties() uses the lower case
|
||||
# content name to prefix property names so follow the same pattern here.
|
||||
string(TOLOWER "${CONTENT_NAME}" CONTENT_NAME_LOWER)
|
||||
set(${OUTPUT_VAR}
|
||||
"_OverridableFetchContent_${CONTENT_NAME_LOWER}_${PROPERTY_NAME}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endfunction()
|
||||
|
||||
|
||||
# Set a global property for this module.
|
||||
# CONTENT_NAME: Name of the content associated with the FetchContent function.
|
||||
# PROPERTY_NAME: Name of the property to set.
|
||||
# DOCUMENTATION: Documentation string for the property.
|
||||
# PROPERTY_VALUE: Value to set the property to.
|
||||
function(_OverridableFetchContent_SetProperty CONTENT_NAME PROPERTY_NAME
|
||||
DOCUMENTATION PROPERTY_VALUE)
|
||||
_OverridableFetchContent_GetPropertyName(
|
||||
"${CONTENT_NAME}"
|
||||
"${PROPERTY_NAME}"
|
||||
GLOBAL_PROPERTY_NAME
|
||||
)
|
||||
define_property(GLOBAL PROPERTY "${GLOBAL_PROPERTY_NAME}"
|
||||
BRIEF_DOCS "${DOCUMENTATION}"
|
||||
FULL_DOCS "${DOCUMENTATION}"
|
||||
)
|
||||
set_property(GLOBAL PROPERTY "${GLOBAL_PROPERTY_NAME}" "${PROPERTY_VALUE}")
|
||||
endfunction()
|
||||
|
||||
|
||||
# Get a global property for this module.
|
||||
# CONTENT_NAME: Name of the content associated with the FetchContent function.
|
||||
# PROPERTY_NAME: Name of the property to get.
|
||||
# OUTPUT_VAR: Variable to store the value in.
|
||||
function(_OverridableFetchContent_GetProperty CONTENT_NAME PROPERTY_NAME
|
||||
OUTPUT_VAR)
|
||||
_OverridableFetchContent_GetPropertyName(
|
||||
"${CONTENT_NAME}"
|
||||
"${PROPERTY_NAME}"
|
||||
GLOBAL_PROPERTY_NAME
|
||||
)
|
||||
get_property(VALUE GLOBAL PROPERTY "${GLOBAL_PROPERTY_NAME}")
|
||||
if(VALUE)
|
||||
set(${OUTPUT_VAR} "${VALUE}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
# Export a list of variables to the parent scope of the caller function.
|
||||
macro(_OverridableFetchContent_ExportToParentScope)
|
||||
# Export requested variables to the parent scope.
|
||||
foreach(VARIABLE_NAME ${ARGN})
|
||||
if(${VARIABLE_NAME})
|
||||
message(DEBUG "Export ${VARIABLE_NAME} ${${VARIABLE_NAME}}")
|
||||
set(${VARIABLE_NAME} "${${VARIABLE_NAME}}" PARENT_SCOPE)
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
# Wrapper around FetchContent_GetProperties().
|
||||
#
|
||||
# Sets the same variables as FetchContent_GetProperties() in addition to:
|
||||
# * <contentName>_LICENSE_FILE: License file relative to
|
||||
# <contentName>_SOURCE_DIR if found.
|
||||
# * <contentName>_LICENSE_URL: License URL if the file is found.
|
||||
# * <contentName_ARCHIVE_URL: URL to the source package.
|
||||
function(OverridableFetchContent_GetProperties CONTENT_NAME)
|
||||
set(EXPORT_VARIABLE_ARGS SOURCE_DIR BINARY_DIR POPULATED)
|
||||
cmake_parse_arguments(ARGS
|
||||
""
|
||||
"${EXPORT_VARIABLE_ARGS}"
|
||||
""
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
# The implementation of FetchContent_Populate() uses the lower case
|
||||
# content name to prefix returned variable names.
|
||||
string(TOLOWER "${CONTENT_NAME}" CONTENT_NAME_LOWER)
|
||||
# Get the names of the variables to export to the parent scope.
|
||||
set(EXPORT_VARIABLES "")
|
||||
set(OUTPUT_ARGS "")
|
||||
foreach(ARG_NAME ${EXPORT_VARIABLE_ARGS})
|
||||
set(ARG_VARIABLE_NAME "ARGS_${ARG_NAME}")
|
||||
set(ARG_VARIABLE_VALUE "${${ARG_VARIABLE_NAME}}")
|
||||
list(APPEND EXPORT_VARIABLES "${CONTENT_NAME_LOWER}_${ARG_NAME}")
|
||||
if(ARG_VARIABLE_VALUE)
|
||||
list(APPEND EXPORT_VARIABLES "${ARG_VARIABLE_VALUE}")
|
||||
list(APPEND OUTPUT_ARGS "${ARG_NAME}" "${ARG_VARIABLE_VALUE}")
|
||||
endif()
|
||||
endforeach()
|
||||
list(APPEND OUTPUT_ARGS ${ARGS_UNPARSED_ARGUMENTS})
|
||||
|
||||
foreach(EXPORT_PROPERTY LICENSE_FILE LICENSE_URL ARCHIVE_URL)
|
||||
_OverridableFetchContent_GetProperty("${CONTENT_NAME}"
|
||||
"${EXPORT_PROPERTY}"
|
||||
"${EXPORT_PROPERTY}"
|
||||
)
|
||||
set(PROPERTY_VALUE "${${EXPORT_PROPERTY}}")
|
||||
if(PROPERTY_VALUE)
|
||||
set(${CONTENT_NAME}_${EXPORT_PROPERTY} "${PROPERTY_VALUE}" PARENT_SCOPE)
|
||||
endif()
|
||||
endforeach()
|
||||
FetchContent_GetProperties("${CONTENT_NAME}" ${OUTPUT_ARGS})
|
||||
_OverridableFetchContent_ExportToParentScope(${EXPORT_VARIABLES})
|
||||
endfunction()
|
||||
|
||||
|
||||
# Replacement for FetchContent_Populate() that searches a newly cloned
|
||||
# repository for a top level license file and provides it to the caller
|
||||
# via the <contentName>_LICENSE_FILE and <contentName>_LICENSE_URL variables
|
||||
# where <contentName> is the value passed as the CONTENT_NAME argument of this
|
||||
# method.
|
||||
#
|
||||
# To ensure a fetched repo has a license file and URL
|
||||
# OVERRIDABLE_FETCH_CONTENT_LICENSE_CHECK_<contentName> to ON for one
|
||||
# repository or OVERRIDABLE_FETCH_CONTENT_LICENSE_CHECK to ON for all
|
||||
# repositories.
|
||||
function(OverridableFetchContent_Populate CONTENT_NAME)
|
||||
# The implementation of FetchContent_Populate() uses the lower case
|
||||
# content name to prefix returned variable names.
|
||||
string(TOLOWER "${CONTENT_NAME}" CONTENT_NAME_LOWER)
|
||||
|
||||
FetchContent_Populate("${CONTENT_NAME}")
|
||||
OverridableFetchContent_GetProperties("${CONTENT_NAME}")
|
||||
|
||||
# If a license file isn't cached try finding it in the repo.
|
||||
set(LICENSE_FILE "${${CONTENT_NAME_LOWER}_LICENSE_FILE}")
|
||||
set(LICENSE_URL "${${CONTENT_NAME_LOWER}_LICENSE_URL}")
|
||||
if(${CONTENT_NAME}_POPULATED AND NOT LICENSE_FILE)
|
||||
set(SOURCE_DIR "${${CONTENT_NAME_LOWER}_SOURCE_DIR}")
|
||||
find_file(_${CONTENT_NAME_LOWER}_LICENSE_FILE
|
||||
NAMES LICENSE LICENSE.md LICENSE.txt NOTICE COPYING
|
||||
PATHS "${SOURCE_DIR}"
|
||||
DOC "${CONTENT_NAME} license file"
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
set(LICENSE_FILE "${_${CONTENT_NAME_LOWER}_LICENSE_FILE}")
|
||||
if(LICENSE_FILE)
|
||||
file(RELATIVE_PATH LICENSE_FILE "${SOURCE_DIR}" "${LICENSE_FILE}")
|
||||
file(TO_CMAKE_PATH "${LICENSE_FILE}" LICENSE_FILE)
|
||||
endif()
|
||||
endif()
|
||||
# If a LICENSE_FILE was found populate the URL.
|
||||
if(LICENSE_FILE AND NOT LICENSE_URL)
|
||||
_LicenseFileToUrl(
|
||||
"${CONTENT_NAME}"
|
||||
"${LICENSE_FILE}"
|
||||
LICENSE_URL
|
||||
)
|
||||
endif()
|
||||
|
||||
# If enabled, check for source licenses.
|
||||
if(OVERRIDABLE_FETCH_CONTENT_LICENSE_CHECK OR
|
||||
OVERRIDABLE_FETCH_CONTENT_LICENSE_CHECK_${CONTENT_NAME})
|
||||
message(DEBUG "LICENSE_FILE: ${LICENSE_FILE}, LICENSE_URL: ${LICENSE_URL}")
|
||||
if(NOT LICENSE_FILE)
|
||||
message(FATAL_ERROR
|
||||
"Required license file not found for ${CONTENT_NAME}"
|
||||
)
|
||||
endif()
|
||||
if(NOT LICENSE_URL)
|
||||
message(FATAL_ERROR
|
||||
"Required license URL not found for ${CONTENT_NAME}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Export return values to the parent scope.
|
||||
set(EXPORT_VARIABLES "")
|
||||
foreach(VARIABLE_POSTFIX SOURCE_DIR BINARY_DIR POPULATED)
|
||||
list(APPEND EXPORT_VARIABLES "${CONTENT_NAME_LOWER}_${VARIABLE_POSTFIX}")
|
||||
endforeach()
|
||||
_OverridableFetchContent_ExportToParentScope(${EXPORT_VARIABLES})
|
||||
endfunction()
|
44
tensorflow/lite/tools/cmake/modules/abseil-cpp.cmake
Normal file
44
tensorflow/lite/tools/cmake/modules/abseil-cpp.cmake
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.
|
||||
|
||||
# Use absl_base as a proxy for the project being included.
|
||||
if(TARGET absl_base OR abseil-cpp_POPULATED)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include(OverridableFetchContent)
|
||||
|
||||
OverridableFetchContent_Declare(
|
||||
abseil-cpp
|
||||
GIT_REPOSITORY https://github.com/abseil/abseil-cpp
|
||||
GIT_TAG 20200225.2 # TODO: What version does GRPC and TFLite need?
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
PREFIX "${CMAKE_BINARY_DIR}"
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/abseil-cpp"
|
||||
)
|
||||
OverridableFetchContent_GetProperties(abseil-cpp)
|
||||
if(NOT abseil-cpp_POPULATED)
|
||||
OverridableFetchContent_Populate(abseil-cpp)
|
||||
endif()
|
||||
|
||||
set(ABSL_USE_GOOGLETEST_HEAD OFF CACHE BOOL "Disable googletest")
|
||||
set(ABSL_RUN_TESTS OFF CACHE BOOL "Disable build of ABSL tests")
|
||||
add_subdirectory(
|
||||
"${abseil-cpp_SOURCE_DIR}"
|
||||
"${abseil-cpp_BINARY_DIR}"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
|
187
tensorflow/lite/tools/cmake/modules/absl-config.cmake
Normal file
187
tensorflow/lite/tools/cmake/modules/absl-config.cmake
Normal file
@ -0,0 +1,187 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
# grpc uses find_package in CONFIG mode for this package, so override the
|
||||
# system installation and build from source instead.
|
||||
include(abseil-cpp)
|
||||
if(abseil-cpp_POPULATED)
|
||||
set(_ABSL_LIBRARY_NAMES
|
||||
algorithm
|
||||
algorithm_container
|
||||
any
|
||||
atomic_hook
|
||||
atomic_hook_test_helper
|
||||
awesome
|
||||
bad_any_cast
|
||||
bad_any_cast_impl
|
||||
bad_optional_access
|
||||
bad_variant_access
|
||||
base
|
||||
base_internal
|
||||
bind_front
|
||||
bits
|
||||
btree
|
||||
btree_test_common
|
||||
city
|
||||
civil_time
|
||||
compare
|
||||
compressed_tuple
|
||||
config
|
||||
conformance_testing
|
||||
container
|
||||
container_common
|
||||
container_memory
|
||||
cord
|
||||
cord_test_helpers
|
||||
core_headers
|
||||
counting_allocator
|
||||
debugging
|
||||
debugging_internal
|
||||
demangle_internal
|
||||
dynamic_annotations
|
||||
endian
|
||||
errno_saver
|
||||
examine_stack
|
||||
exception_safety_testing
|
||||
exception_testing
|
||||
exponential_biased
|
||||
failure_signal_handler
|
||||
fantastic_lib
|
||||
fast_type_id
|
||||
fixed_array
|
||||
flags
|
||||
flags_commandlineflag
|
||||
flags_commandlineflag_internal
|
||||
flags_config
|
||||
flags_internal
|
||||
flags_marshalling
|
||||
flags_parse
|
||||
flags_path_util
|
||||
flags_private_handle_accessor
|
||||
flags_program_name
|
||||
flags_reflection
|
||||
flags_usage
|
||||
flags_usage_internal
|
||||
flat_hash_map
|
||||
flat_hash_set
|
||||
function_ref
|
||||
graphcycles_internal
|
||||
hash
|
||||
hash_function_defaults
|
||||
hash_generator_testing
|
||||
hash_policy_testing
|
||||
hash_policy_traits
|
||||
hash_testing
|
||||
hashtable_debug
|
||||
hashtable_debug_hooks
|
||||
hashtablez_sampler
|
||||
have_sse
|
||||
hdrs
|
||||
inlined_vector
|
||||
inlined_vector_internal
|
||||
int128
|
||||
kernel_timeout_internal
|
||||
layout
|
||||
leak_check
|
||||
leak_check_api_disabled_for_testing
|
||||
leak_check_api_enabled_for_testing
|
||||
leak_check_disable
|
||||
log_severity
|
||||
main_lib
|
||||
malloc_internal
|
||||
memory
|
||||
meta
|
||||
node_hash_map
|
||||
node_hash_policy
|
||||
node_hash_set
|
||||
numeric
|
||||
optional
|
||||
per_thread_sem_test_common
|
||||
periodic_sampler
|
||||
pow10_helper
|
||||
pretty_function
|
||||
random_bit_gen_ref
|
||||
random_distributions
|
||||
random_internal_distribution_caller
|
||||
random_internal_distribution_test_util
|
||||
random_internal_explicit_seed_seq
|
||||
random_internal_fast_uniform_bits
|
||||
random_internal_fastmath
|
||||
random_internal_generate_real
|
||||
random_internal_iostream_state_saver
|
||||
random_internal_mock_helpers
|
||||
random_internal_mock_overload_set
|
||||
random_internal_nonsecure_base
|
||||
random_internal_pcg_engine
|
||||
random_internal_platform
|
||||
random_internal_pool_urbg
|
||||
random_internal_randen
|
||||
random_internal_randen_engine
|
||||
random_internal_randen_hwaes
|
||||
random_internal_randen_hwaes_impl
|
||||
random_internal_randen_slow
|
||||
random_internal_salted_seed_seq
|
||||
random_internal_seed_material
|
||||
random_internal_sequence_urbg
|
||||
random_internal_traits
|
||||
random_internal_uniform_helper
|
||||
random_internal_wide_multiply
|
||||
random_mocking_bit_gen
|
||||
random_random
|
||||
random_seed_gen_exception
|
||||
random_seed_sequences
|
||||
raw_hash_map
|
||||
raw_hash_set
|
||||
raw_logging_internal
|
||||
scoped_set_env
|
||||
span
|
||||
spinlock_test_common
|
||||
spinlock_wait
|
||||
spy_hash_state
|
||||
stack_consumption
|
||||
stacktrace
|
||||
status
|
||||
str_format
|
||||
str_format_internal
|
||||
strerror
|
||||
strings
|
||||
strings_internal
|
||||
symbolize
|
||||
synchronization
|
||||
test_instance_tracker
|
||||
thread_pool
|
||||
throw_delegate
|
||||
time
|
||||
time_internal_test_util
|
||||
time_zone
|
||||
tracked
|
||||
type_traits
|
||||
unordered_map_constructor_test
|
||||
unordered_map_lookup_test
|
||||
unordered_map_members_test
|
||||
unordered_map_modifiers_test
|
||||
unordered_set_constructor_test
|
||||
unordered_set_lookup_test
|
||||
unordered_set_members_test
|
||||
unordered_set_modifiers_test
|
||||
utility
|
||||
variant
|
||||
)
|
||||
set(_ABSL_LIBRARIES ${_ABSL_LIBRARY_NAMES})
|
||||
foreach(_LIBRARY ${_ABSL_LIBRARY_NAMES})
|
||||
list(APPEND _ABSL_LIBRARIES "absl::${LIBRARY}")
|
||||
endforeach()
|
||||
set(ABSL_LIBRARIES ${ABSL_LIBRARIES} CACHE STRING "absl libs")
|
||||
endif()
|
95
tensorflow/lite/tools/cmake/modules/eigen.cmake
Normal file
95
tensorflow/lite/tools/cmake/modules/eigen.cmake
Normal file
@ -0,0 +1,95 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
if(TARGET eigen OR eigen_POPULATED)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include(OverridableFetchContent)
|
||||
|
||||
OverridableFetchContent_Declare(
|
||||
eigen
|
||||
GIT_REPOSITORY https://gitlab.com/libeigen/eigen
|
||||
# TODO: Verify this is the version required by TFLite
|
||||
GIT_TAG b9362fb8f76fbba805b56afbc0f5de0a279631b5
|
||||
# It's not currently (cmake 3.17) possible to shallow clone with a GIT TAG
|
||||
# as cmake attempts to git checkout the commit hash after the clone
|
||||
# which doesn't work as it's a shallow clone hence a different commit hash.
|
||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/17770
|
||||
# GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
PREFIX "${CMAKE_BINARY_DIR}"
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/eigen"
|
||||
LICENSE_FILE "COPYING.MPL2"
|
||||
)
|
||||
OverridableFetchContent_GetProperties(eigen)
|
||||
if(NOT eigen_POPULATED)
|
||||
OverridableFetchContent_Populate(eigen)
|
||||
endif()
|
||||
|
||||
# Patch Eigen to disable Fortran compiler check for BLAS and LAPACK tests.
|
||||
if(NOT EIGEN_DISABLED_FORTRAN_COMPILER_CHECK)
|
||||
file(WRITE "${eigen_SOURCE_DIR}/cmake/language_support.cmake" "
|
||||
function(workaround_9220 language language_works)
|
||||
set(\${language_works} OFF PARENT_SCOPE)
|
||||
endfunction()"
|
||||
)
|
||||
endif()
|
||||
# Patch Eigen to disable benchmark suite.
|
||||
if(NOT EIGEN_BUILD_BTL)
|
||||
file(WRITE "${eigen_SOURCE_DIR}/bench/spbench/CMakeLists.txt" "")
|
||||
endif()
|
||||
|
||||
set(EIGEN_DISABLED_FORTRAN_COMPILER_CHECK ON CACHE BOOL "Disabled Fortran")
|
||||
|
||||
set(EIGEN_LEAVE_TEST_IN_ALL_TARGET OFF CACHE BOOL
|
||||
"Remove tests from all target."
|
||||
)
|
||||
set(BUILD_TESTING OFF CACHE BOOL "Disable tests.")
|
||||
set(EIGEN_TEST_CXX11 OFF CACHE BOOL "Disable tests of C++11 features.")
|
||||
set(EIGEN_BUILD_BTL OFF CACHE BOOL "Disable benchmark suite.")
|
||||
set(EIGEN_BUILD_PKGCONFIG OFF CACHE BOOL "Disable pkg-config.")
|
||||
set(EIGEN_SPLIT_LARGE_TESTS OFF CACHE BOOL "Disable test splitting.")
|
||||
set(EIGEN_DEFAULT_TO_ROW_MAJOR OFF CACHE BOOL
|
||||
"Disable row-major matrix storage"
|
||||
)
|
||||
set(EIGEN_TEST_NOQT ON CACHE BOOL "Disable Qt support in tests.")
|
||||
set(EIGEN_TEST_SSE2 OFF CACHE BOOL "Disable SSE2 test.")
|
||||
set(EIGEN_TEST_SSE3 OFF CACHE BOOL "Disable SSE3 test.")
|
||||
set(EIGEN_TEST_SSSE3 OFF CACHE BOOL "Disable SSSE3 test.")
|
||||
set(EIGEN_TEST_SSE4_1 OFF CACHE BOOL "Disable SSE4.1 test.")
|
||||
set(EIGEN_TEST_SSE4_2 OFF CACHE BOOL "Disable SSE4.2 test.")
|
||||
set(EIGEN_TEST_AVX OFF CACHE BOOL "Disable AVX test.")
|
||||
set(EIGEN_TEST_FMA OFF CACHE BOOL "Disable FMA test.")
|
||||
set(EIGEN_TEST_AVX512 OFF CACHE BOOL "Disable AVX512 test.")
|
||||
set(EIGEN_TEST_F16C OFF CACHE BOOL "Disable F16C test.")
|
||||
set(EIGEN_TEST_ALTIVEC OFF CACHE BOOL "Disable AltiVec test.")
|
||||
set(EIGEN_TEST_VSX OFF CACHE BOOL "Disable VSX test.")
|
||||
set(EIGEN_TEST_MSA OFF CACHE BOOL "Disable MSA test.")
|
||||
set(EIGEN_TEST_NEON OFF CACHE BOOL "Disable NEON test.")
|
||||
set(EIGEN_TEST_NEON64 OFF CACHE BOOL "Disable NEON64 test.")
|
||||
set(EIGEN_TEST_Z13 OFF CACHE BOOL "Disable Z13 test.")
|
||||
set(EIGEN_TEST_Z14 OFF CACHE BOOL "Disable Z14 test.")
|
||||
set(EIGEN_TEST_OPENMP OFF CACHE BOOL "Disable OpenMP test.")
|
||||
set(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION OFF CACHE BOOL "Disable vectorization")
|
||||
set(EIGEN_TEST_X87 OFF CACHE BOOL "Disable X87 instructions test")
|
||||
set(EIGEN_TEST_32BIT OFF CACHE BOOL "Disable 32-bit instructions test")
|
||||
set(EIGEN_TEST_NO_EXPLICIT_ALIGNMENT OFF CACHE BOOL "Disable alignment test")
|
||||
set(EIGEN_TEST_NO_EXCEPTIONS OFF CACHE BOOL "Disable alignment test")
|
||||
set(EIGEN_TEST_SYCL OFF CACHE BOOL "Disable Sycl test")
|
||||
set(EIGEN_SYCL_TRISYCL OFF CACHE BOOL "Disable triSYCL test")
|
||||
# Make sure only MPL2.0 or more permissively licensed code is included.
|
||||
add_compile_definitions(EIGEN_MPL2_ONLY)
|
||||
add_subdirectory("${eigen_SOURCE_DIR}" "${eigen_BINARY_DIR}" EXCLUDE_FROM_ALL)
|
48
tensorflow/lite/tools/cmake/modules/farmhash.cmake
Normal file
48
tensorflow/lite/tools/cmake/modules/farmhash.cmake
Normal file
@ -0,0 +1,48 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
if(TARGET farmhash OR farmhash_POPULATED)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include(OverridableFetchContent)
|
||||
|
||||
OverridableFetchContent_Declare(
|
||||
farmhash
|
||||
GIT_REPOSITORY https://github.com/google/farmhash
|
||||
# TODO: Reference the source of this.
|
||||
GIT_TAG 816a4ae622e964763ca0862d9dbd19324a1eaf45
|
||||
# It's not currently possible to shallow clone with a GIT TAG
|
||||
# as cmake attempts to git checkout the commit hash after the clone
|
||||
# which doesn't work as it's a shallow clone hence a different commit hash.
|
||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/17770
|
||||
# GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/farmhash"
|
||||
)
|
||||
OverridableFetchContent_GetProperties(farmhash)
|
||||
if(NOT farmhash_POPULATED)
|
||||
OverridableFetchContent_Populate(farmhash)
|
||||
endif()
|
||||
|
||||
set(FARMHASH_SOURCE_DIR "${farmhash_SOURCE_DIR}" CACHE PATH
|
||||
"Source directory for the CMake project."
|
||||
)
|
||||
|
||||
add_subdirectory(
|
||||
"${CMAKE_CURRENT_LIST_DIR}/farmhash"
|
||||
"${farmhash_BINARY_DIR}"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
39
tensorflow/lite/tools/cmake/modules/farmhash/CMakeLists.txt
Normal file
39
tensorflow/lite/tools/cmake/modules/farmhash/CMakeLists.txt
Normal file
@ -0,0 +1,39 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
project(farmhash CXX)
|
||||
|
||||
set(FARMHASH_SOURCE_DIR "" CACHE PATH
|
||||
"Directory that contains the farmhash project"
|
||||
)
|
||||
if(NOT FARMHASH_SOURCE_DIR)
|
||||
message(FATAL_ERROR "Must specify source directory")
|
||||
endif()
|
||||
|
||||
# Transcribed from farmhash/src/Makefile.am
|
||||
include(CheckCXXSourceCompiles)
|
||||
check_cxx_source_compiles(
|
||||
"int main(int argc, char* argv[]) { return (int)__builtin_expect(0, 0); }"
|
||||
FARMHASH_HAS_BUILTIN_EXPECT
|
||||
)
|
||||
|
||||
add_library(farmhash
|
||||
"${FARMHASH_SOURCE_DIR}/src/farmhash.cc"
|
||||
"${FARMHASH_SOURCE_DIR}/src/farmhash.h"
|
||||
)
|
||||
target_include_directories(farmhash PUBLIC "${FARMHASH_SOURCE_DIR}/src")
|
||||
if(NOT FARMHASH_HAS_BUILTIN_EXPECT)
|
||||
target_compile_definitions(farmhash PUBLIC -DFARMHASH_NO_BUILTIN_EXPECT)
|
||||
endif()
|
41
tensorflow/lite/tools/cmake/modules/fft2d.cmake
Normal file
41
tensorflow/lite/tools/cmake/modules/fft2d.cmake
Normal file
@ -0,0 +1,41 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
if(TARGET fft2d OR fft2d_POPULATED)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include(OverridableFetchContent)
|
||||
|
||||
OverridableFetchContent_Declare(
|
||||
fft2d
|
||||
URL https://storage.googleapis.com/mirror.tensorflow.org/www.kurims.kyoto-u.ac.jp/~ooura/fft2d.tgz
|
||||
# TODO: Reference where this comes from.
|
||||
URL_HASH SHA256=ada7e99087c4ed477bfdf11413f2ba8db8a840ba9bbf8ac94f4f3972e2a7cec9
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/fft2d"
|
||||
LICENSE_FILE "readme2d.txt"
|
||||
LICENSE_URL "http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html"
|
||||
)
|
||||
OverridableFetchContent_GetProperties(fft2d)
|
||||
if(NOT fft2d_POPULATED)
|
||||
OverridableFetchContent_Populate(fft2d)
|
||||
endif()
|
||||
|
||||
set(FFT2D_SOURCE_DIR "${fft2d_SOURCE_DIR}" CACHE PATH "fft2d source")
|
||||
add_subdirectory(
|
||||
"${CMAKE_CURRENT_LIST_DIR}/fft2d"
|
||||
"${fft2d_BINARY_DIR}"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
54
tensorflow/lite/tools/cmake/modules/fft2d/CMakeLists.txt
Normal file
54
tensorflow/lite/tools/cmake/modules/fft2d/CMakeLists.txt
Normal file
@ -0,0 +1,54 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
project(fft2d C)
|
||||
|
||||
set(FFT2D_SOURCE_DIR "" CACHE PATH
|
||||
"Directory that contains the fft2d project"
|
||||
)
|
||||
if(NOT FFT2D_SOURCE_DIR)
|
||||
message(FATAL_ERROR "Must specify source directory")
|
||||
endif()
|
||||
|
||||
# fft2d doesn't have a CMake project so define it here transcribed from
|
||||
# sample2d/Makefile.
|
||||
|
||||
# A developer should link this library if they haven't provided their own
|
||||
# implementation of these allocation methods.
|
||||
add_library(fft2d_alloc
|
||||
"${FFT2D_SOURCE_DIR}/alloc.c"
|
||||
"${FFT2D_SOURCE_DIR}/alloc.h"
|
||||
)
|
||||
target_include_directories(fft2d_alloc PUBLIC "${FFT2D_SOURCE_DIR}")
|
||||
|
||||
# Requires implementation of fft2d_alloc.
|
||||
add_library(fft2d_fft4f2d "${FFT2D_SOURCE_DIR}/fft4f2d.c")
|
||||
target_include_directories(fft2d_fft4f2d PRIVATE "${FFT2D_SOURCE_DIR}")
|
||||
|
||||
add_library(fft2d_fftsg "${FFT2D_SOURCE_DIR}/fftsg.c")
|
||||
|
||||
# Requires implementation of fft2d_alloc.
|
||||
add_library(fft2d_fftsg2d "${FFT2D_SOURCE_DIR}/fftsg2d.c")
|
||||
target_link_libraries(fft2d_fftsg2d fft2d_fftsg)
|
||||
target_include_directories(fft2d_fftsg2d PRIVATE "${FFT2D_SOURCE_DIR}")
|
||||
|
||||
# Requires implementation of fft2d_alloc.
|
||||
add_library(fft2d_fftsg3d "${FFT2D_SOURCE_DIR}/fftsg3d.c")
|
||||
target_link_libraries(fft2d_fftsg3d fft2d_fftsg)
|
||||
target_include_directories(fft2d_fftsg3d PRIVATE "${FFT2D_SOURCE_DIR}")
|
||||
|
||||
add_library(fft2d_shrtdct "${FFT2D_SOURCE_DIR}/shrtdct.c")
|
||||
|
||||
add_library(fft2d ALIAS fft2d_fftsg2d)
|
43
tensorflow/lite/tools/cmake/modules/flatbuffers.cmake
Normal file
43
tensorflow/lite/tools/cmake/modules/flatbuffers.cmake
Normal file
@ -0,0 +1,43 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
if(TARGET flatbuffers OR flatbuffers_POPULATED)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
OverridableFetchContent_Declare(
|
||||
flatbuffers
|
||||
GIT_REPOSITORY https://github.com/google/flatbuffers
|
||||
GIT_TAG v1.12.0 # TODO: What version does TFLite need?
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/flatbuffers"
|
||||
)
|
||||
OverridableFetchContent_GetProperties(flatbuffers)
|
||||
if(NOT flatbuffers_POPULATED)
|
||||
OverridableFetchContent_Populate(flatbuffers)
|
||||
endif()
|
||||
|
||||
# Required for Windows, since it has macros called min & max which
|
||||
# clashes with std::min
|
||||
add_definitions(-DNOMINMAX=1)
|
||||
add_subdirectory(
|
||||
"${flatbuffers_SOURCE_DIR}"
|
||||
"${flatbuffers_BINARY_DIR}"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
remove_definitions(-DNOMINMAX)
|
45
tensorflow/lite/tools/cmake/modules/gemmlowp.cmake
Normal file
45
tensorflow/lite/tools/cmake/modules/gemmlowp.cmake
Normal file
@ -0,0 +1,45 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
if(TARGET gemmlowp OR gemmlowp_POPULATED)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include(OverridableFetchContent)
|
||||
|
||||
OverridableFetchContent_Declare(
|
||||
gemmlowp
|
||||
GIT_REPOSITORY https://github.com/google/gemmlowp
|
||||
GIT_TAG fda83bdc38b118cc6b56753bd540caa49e570745
|
||||
# It's not currently (cmake 3.17) possible to shallow clone with a GIT TAG
|
||||
# as cmake attempts to git checkout the commit hash after the clone
|
||||
# which doesn't work as it's a shallow clone hence a different commit hash.
|
||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/17770
|
||||
# GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/gemmlowp"
|
||||
)
|
||||
|
||||
OverridableFetchContent_GetProperties(gemmlowp)
|
||||
if(NOT gemmlowp_POPULATED)
|
||||
OverridableFetchContent_Populate(gemmlowp)
|
||||
endif()
|
||||
|
||||
set(GEMMLOWP_SOURCE_DIR "${gemmlowp_SOURCE_DIR}" CACHE PATH "Source directory")
|
||||
add_subdirectory(
|
||||
"${CMAKE_CURRENT_LIST_DIR}/gemmlowp"
|
||||
"${gemmlowp_BINARY_DIR}"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
87
tensorflow/lite/tools/cmake/modules/gemmlowp/CMakeLists.txt
Normal file
87
tensorflow/lite/tools/cmake/modules/gemmlowp/CMakeLists.txt
Normal file
@ -0,0 +1,87 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
project(gemmlowp CXX)
|
||||
|
||||
option(GEMMLOWP_ADD_HEADERS_TO_TARGETS OFF
|
||||
"Whether to add sources to gemmlowp's interface library targets.
|
||||
This will cause all users of these libraries to also include these headers"
|
||||
)
|
||||
|
||||
set(GEMMLOWP_SOURCE_DIR "" CACHE PATH
|
||||
"Directory that contains the gemmlowp project"
|
||||
)
|
||||
if(NOT GEMMLOWP_SOURCE_DIR)
|
||||
message(FATAL_ERROR "Must specify source directory")
|
||||
endif()
|
||||
|
||||
# gemmlowp doesn't have a CMake project so this is transcribed from
|
||||
# gemmlowp/BUILD.
|
||||
|
||||
file(GLOB GEMMLOWP_EIGHTBITINT_HEADERS
|
||||
"${GEMMLOWP_SOURCE_DIR}/eight_bit_int_gemm/*.h"
|
||||
)
|
||||
file(GLOB GEMMLOWP_EIGHTBITINT_SOURCES
|
||||
"${GEMMLOWP_SOURCE_DIR}/eight_bit_int_gemm/*.cc"
|
||||
)
|
||||
file(GLOB GEMMLOWP_FIXEDPOINT_HEADERS "${GEMMLOWP_SOURCE_DIR}/fixedpoint/*.h")
|
||||
file(GLOB GEMMLOWP_INTERNAL_HEADERS "${GEMMLOWP_SOURCE_DIR}/internal/*.h")
|
||||
file(GLOB GEMMLOWP_META_HEADERS "${GEMMLOWP_SOURCE_DIR}/meta/*.h")
|
||||
file(GLOB GEMMLOWP_PROFILING_HEADERS "${GEMMLOWP_SOURCE_DIR}/profiling/*.h")
|
||||
file(GLOB GEMMLOWP_PUBLIC_HEADERS "${GEMMLOWP_SOURCE_DIR}/public/*.h")
|
||||
|
||||
set(GEMMLOWP_PRIVATE_HEADERS "")
|
||||
list(APPEND GEMMLOWP_PRIVATE_HEADERS ${GEMMLOWP_FIXEDPOINT_HEADERS})
|
||||
list(APPEND GEMMLOWP_PRIVATE_HEADERS ${GEMMLOWP_INTERNAL_HEADERS})
|
||||
|
||||
add_library(gemmlowp_private INTERFACE)
|
||||
if(GEMMLOWP_ADD_HEADERS_TO_TARGETS)
|
||||
target_sources(gemmlowp_private INTERFACE ${GEMMLOWP_PRIVATE_HEADERS})
|
||||
endif()
|
||||
target_include_directories(gemmlowp_private INTERFACE "${GEMMLOWP_SOURCE_DIR}")
|
||||
|
||||
add_library(gemmlowp INTERFACE)
|
||||
if(GEMMLOWP_ADD_HEADERS_TO_TARGETS)
|
||||
target_sources(gemmlowp INTERFACE ${GEMMLOWP_PUBLIC_HEADERS})
|
||||
endif()
|
||||
target_include_directories(gemmlowp INTERFACE "${GEMMLOWP_SOURCE_DIR}/public")
|
||||
target_link_libraries(gemmlowp INTERFACE gemmlowp_private)
|
||||
|
||||
add_library(gemmlowp_eight_bit_int_gemm
|
||||
${GEMMLOWP_EIGHTBITINT_SOURCES}
|
||||
${GEMMLOWP_EIGHTBITINT_HEADERS}
|
||||
)
|
||||
target_include_directories(gemmlowp_eight_bit_int_gemm
|
||||
PUBLIC "${GEMMLOWP_SOURCE_DIR}/eight_bit_int_gemm"
|
||||
)
|
||||
|
||||
add_library(gemmlowp_fixedpoint INTERFACE)
|
||||
if(GEMMLOWP_ADD_HEADERS_TO_TARGETS)
|
||||
target_sources(gemmlowp_fixedpoint INTERFACE ${GEMMLOWP_FIXEDPOINT_HEADERS})
|
||||
endif()
|
||||
target_include_directories(gemmlowp_fixedpoint
|
||||
INTERFACE "${GEMMLOWP_SOURCE_DIR}/fixedpoint"
|
||||
)
|
||||
target_link_libraries(gemmlowp_fixedpoint INTERFACE gemmlowp_private)
|
||||
|
||||
add_library(gemmlowp_profiler INTERFACE)
|
||||
if(GEMMLOWP_ADD_HEADERS_TO_TARGETS)
|
||||
target_sources(gemmlowp_profiler INTERFACE ${GEMMLOWP_PROFILING_HEADERS})
|
||||
endif()
|
||||
target_include_directories(gemmlowp_profiler
|
||||
INTERFACE "${GEMMLOWP_SOURCE_DIR}/profiling"
|
||||
)
|
||||
|
||||
|
40
tensorflow/lite/tools/cmake/modules/neon2sse.cmake
Normal file
40
tensorflow/lite/tools/cmake/modules/neon2sse.cmake
Normal file
@ -0,0 +1,40 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
if(TARGET neon2sse OR neon2sse_POPULATED)
|
||||
return()
|
||||
endif()
|
||||
|
||||
OverridableFetchContent_Declare(
|
||||
neon2sse
|
||||
GIT_REPOSITORY https://github.com/intel/ARM_NEON_2_x86_SSE
|
||||
GIT_TAG master
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/neon2sse"
|
||||
)
|
||||
|
||||
OverridableFetchContent_GetProperties(neon2sse)
|
||||
if(NOT neon2sse_POPULATED)
|
||||
OverridableFetchContent_Populate(neon2sse)
|
||||
endif()
|
||||
|
||||
add_subdirectory(
|
||||
"${neon2sse_SOURCE_DIR}"
|
||||
"${neon2sse_BINARY_DIR}"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
41
tensorflow/lite/tools/cmake/modules/ruy.cmake
Normal file
41
tensorflow/lite/tools/cmake/modules/ruy.cmake
Normal file
@ -0,0 +1,41 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
if(TARGET ruy OR ruy_POPULATED)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include(OverridableFetchContent)
|
||||
|
||||
OverridableFetchContent_Declare(
|
||||
ruy
|
||||
GIT_REPOSITORY https://github.com/google/ruy
|
||||
GIT_TAG master # TODO
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/ruy"
|
||||
)
|
||||
OverridableFetchContent_GetProperties(ruy)
|
||||
if(NOT ruy_POPULATED)
|
||||
OverridableFetchContent_Populate(ruy)
|
||||
endif()
|
||||
|
||||
set(RUY_SOURCE_DIR "${ruy_SOURCE_DIR}" CACHE PATH "RUY source directory")
|
||||
|
||||
add_subdirectory(
|
||||
"${CMAKE_CURRENT_LIST_DIR}/ruy"
|
||||
"${ruy_BINARY_DIR}"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
38
tensorflow/lite/tools/cmake/modules/ruy/CMakeLists.txt
Normal file
38
tensorflow/lite/tools/cmake/modules/ruy/CMakeLists.txt
Normal file
@ -0,0 +1,38 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(ruy CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14) # Some components require C++14.
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(RUY_SOURCE_DIR "" CACHE PATH
|
||||
"Directory that contains the RUY project"
|
||||
)
|
||||
if(NOT RUY_SOURCE_DIR)
|
||||
message(FATAL_ERROR "Must specify source directory")
|
||||
endif()
|
||||
|
||||
file(GLOB RUY_SOURCES "${RUY_SOURCE_DIR}/ruy/*.*")
|
||||
list(FILTER RUY_SOURCES INCLUDE REGEX ".*\\.(c|cc|h)$")
|
||||
list(FILTER RUY_SOURCES EXCLUDE REGEX ".*(_test)\\.(c|cc|h)$")
|
||||
list(FILTER RUY_SOURCES EXCLUDE REGEX ".*/(benchmark|example|test_.*)\.cc$")
|
||||
list(FILTER RUY_SOURCES EXCLUDE REGEX ".*/gtest_wrapper\\.h$")
|
||||
|
||||
add_library(ruy ${RUY_SOURCES})
|
||||
target_include_directories(ruy PUBLIC "${RUY_SOURCE_DIR}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user