Refactored CMake rules to reduce redundancy. (#4695)

This is a step towards concentrating the platform-specific code in one place.
This commit is contained in:
Derek Murray 2016-09-30 16:31:53 -07:00 committed by GitHub
parent 89d1d5c449
commit e5a71cbe95
23 changed files with 300 additions and 780 deletions

View File

@ -15,10 +15,13 @@ cmake_policy(SET CMP0022 NEW)
# Options
option(tensorflow_VERBOSE "Enable for verbose output" OFF)
option(tensorflow_BUILD_TESTS "Build tests" ON)
option(tensorflow_ENABLE_SSL_SUPPORT "Enable boringssl support" OFF)
option(tensorflow_ENABLE_GRPC_SUPPORT "Enable gRPC support" ON)
option(tensorflow_BUILD_CC_EXAMPLE "Build the C++ tutorial example" ON)
option(tensorflow_BUILD_PYTHON_BINDINGS "Build the Python bindings" ON)
option(tensorflow_BUILD_ALL_KERNELS "Build all OpKernels" ON)
option(tensorflow_BUILD_CONTRIB_KERNELS "Build OpKernels from tensorflow/contrib/..." ON)
#Threads: defines CMAKE_THREAD_LIBS_INIT and adds -pthread compile option for
# targets that link ${CMAKE_THREAD_LIBS_INIT}.
@ -42,6 +45,14 @@ set (DOWNLOAD_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/downloads"
mark_as_advanced(DOWNLOAD_LOCATION)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_definitions(-DEIGEN_AVOID_STL_ARRAY)
if(WIN32)
add_definitions(-DNOMINMAX -D_WIN32_WINNT=0x0A00 -DLANG_CXX11 -DCOMPILER_MSVC)
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-fno-exceptions -std=c++11")
endif()
# External dependencies
include(gif)
@ -49,35 +60,76 @@ include(png)
include(jpeg)
include(eigen)
include(jsoncpp)
if(tensorflow_ENABLE_SSL_SUPPORT)
include(boringssl)
endif()
include(farmhash)
include(highwayhash)
include(protobuf)
include(grpc)
find_package(ZLIB REQUIRED)
set(tensorflow_EXTERNAL_LIBRARIES
${gif_STATIC_LIBRARIES}
${png_STATIC_LIBRARIES}
${jpeg_STATIC_LIBRARIES}
${jsoncpp_STATIC_LIBRARIES}
${farmhash_STATIC_LIBRARIES}
${highwayhash_STATIC_LIBRARIES}
${protobuf_STATIC_LIBRARIES}
${ZLIB_LIBRARIES}
)
set(tensorflow_EXTERNAL_DEPENDENCIES
gif_copy_headers_to_destination png_copy_headers_to_destination jpeg_copy_headers_to_destination jsoncpp farmhash_copy_headers_to_destination highwayhash_copy_headers_to_destination protobuf eigen)
include_directories(
# Source and generated code.
${tensorflow_source_dir}
${CMAKE_CURRENT_BINARY_DIR}
# External dependencies.
${gif_INCLUDE_DIR}
${png_INCLUDE_DIR}
${jpeg_INCLUDE_DIR}
${eigen_INCLUDE_DIRS}
${jsoncpp_INCLUDE_DIR}
${farmhash_INCLUDE_DIR}
${highwayhash_INCLUDE_DIR}
${PROTOBUF_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
)
if(tensorflow_ENABLE_SSL_SUPPORT)
include(boringssl)
list(APPEND tensorflow_EXTERNAL_LIBRARIES ${boringssl_STATIC_LIBRARIES})
list(APPEND tensorflow_EXTERNAL_DEPENDENCIES boringssl)
include_directories(${boringssl_INCLUDE_DIR})
endif()
if(tensorflow_ENABLE_GRPC_SUPPORT)
include(grpc)
list(APPEND tensorflow_EXTERNAL_LIBRARIES ${grpc_STATIC_LIBRARIES})
list(APPEND tensorflow_EXTERNAL_DEPENDENCIES grpc)
include_directories(${GRPC_INCLUDE_DIRS})
endif()
if(WIN32)
list(APPEND tensorflow_EXTERNAL_LIBRARIES wsock32 ws2_32 shlwapi)
endif()
if(UNIX)
list(APPEND tensorflow_EXTERNAL_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
endif()
# Let's get to work!
include(tf_core_framework.cmake)
include(tf_tools.cmake)
# NOTE: Disabled until issue #3996 is fixed.
# include(tf_stream_executor.cmake)
include(tf_core_cpu.cmake)
include(tf_models.cmake)
include(tf_core_ops.cmake)
include(tf_core_direct_session.cmake)
include(tf_core_distributed_runtime.cmake)
if(tensorflow_ENABLE_GRPC_SUPPORT)
include(tf_core_distributed_runtime.cmake)
endif()
include(tf_core_kernels.cmake)
include(tf_cc_ops.cmake)
include(tf_tools.cmake)
if(tensorflow_BUILD_CC_EXAMPLE)
include(tf_tutorials.cmake)
endif()
if(tensorflow_BUILD_PYTHON_BINDINGS)
include(tf_python.cmake)
endif()
if (tensorflow_BUILD_TESTS)
include(tests.cmake)
endif (tensorflow_BUILD_TESTS)
include(install.cmake)

View File

@ -1,6 +1,6 @@
include (ExternalProject)
set(farmhash_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/farmhash_archive)
set(farmhash_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/farmhash_archive ${CMAKE_CURRENT_BINARY_DIR}/external/farmhash_archive/util)
set(farmhash_URL https://github.com/google/farmhash/archive/34c13ddfab0e35422f4c3979f360635a8c050260.zip)
set(farmhash_HASH SHA256=e3d37a59101f38fd58fb799ed404d630f0eee18bfc2a2433910977cc8fea9c28)
set(farmhash_BUILD ${CMAKE_BINARY_DIR}/farmhash/src/farmhash)

View File

@ -4,28 +4,58 @@ set(gif_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/gif_archive/giflib-5.1.
set(gif_URL http://ufpr.dl.sourceforge.net/project/giflib/giflib-5.1.4.tar.gz)
set(gif_HASH SHA256=34a7377ba834397db019e8eb122e551a49c98f49df75ec3fcc92b9a794a4f6d1)
set(gif_INSTALL ${CMAKE_BINARY_DIR}/gif/install)
set(gif_STATIC_LIBRARIES ${gif_INSTALL}/lib/libgif.a)
set(gif_BUILD ${CMAKE_BINARY_DIR}/gif/src/gif)
set(gif_HEADERS
"${gif_INSTALL}/include/gif_lib.h"
)
set(ENV{CFLAGS} "$ENV{CFLAGS} -fPIC")
if(WIN32)
ExternalProject_Add(gif
PREFIX gif
URL ${gif_URL}
URL_HASH ${gif_HASH}
INSTALL_DIR ${gif_INSTALL}
DOWNLOAD_DIR "${DOWNLOAD_LOCATION}"
BUILD_COMMAND $(MAKE)
INSTALL_COMMAND $(MAKE) install
CONFIGURE_COMMAND
${CMAKE_CURRENT_BINARY_DIR}/gif/src/gif/configure
--with-pic
--prefix=${gif_INSTALL}
--enable-shared=yes
)
set(gif_STATIC_LIBRARIES ${gif_INSTALL}/lib/giflib.lib)
ExternalProject_Add(gif
PREFIX gif
URL ${gif_URL}
URL_HASH ${gif_HASH}
PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/patches/gif/CMakeLists.txt ${gif_BUILD}
INSTALL_DIR ${gif_INSTALL}
DOWNLOAD_DIR "${DOWNLOAD_LOCATION}"
CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF
-DCMAKE_INSTALL_PREFIX:STRING=${gif_INSTALL}
)
ExternalProject_Add_Step(gif copy_unistd
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/patches/gif/unistd.h ${gif_BUILD}/lib/unistd.h
DEPENDEES patch
DEPENDERS build
)
else()
set(gif_STATIC_LIBRARIES ${gif_INSTALL}/lib/libgif.a)
set(ENV{CFLAGS} "$ENV{CFLAGS} -fPIC")
ExternalProject_Add(gif
PREFIX gif
URL ${gif_URL}
URL_HASH ${gif_HASH}
INSTALL_DIR ${gif_INSTALL}
DOWNLOAD_DIR "${DOWNLOAD_LOCATION}"
BUILD_COMMAND $(MAKE)
INSTALL_COMMAND $(MAKE) install
CONFIGURE_COMMAND
${CMAKE_CURRENT_BINARY_DIR}/gif/src/gif/configure
--with-pic
--prefix=${gif_INSTALL}
--enable-shared=yes
)
endif()
# put gif includes in the directory where they are expected
add_custom_target(gif_create_destination_dir

View File

@ -6,12 +6,12 @@ set(GRPC_BUILD ${CMAKE_CURRENT_BINARY_DIR}/grpc/src/grpc)
set(GRPC_TAG 3bc78cd0b5bd784a235c01612d634b1ec5f8fb97)
if(WIN32)
set(GRPC_LIBRARIES
set(grpc_STATIC_LIBRARIES
${CMAKE_CURRENT_BINARY_DIR}/grpc/src/grpc/${CMAKE_BUILD_TYPE}/grpc++_unsecure.lib
${CMAKE_CURRENT_BINARY_DIR}/grpc/src/grpc/${CMAKE_BUILD_TYPE}/grpc_unsecure.lib
${CMAKE_CURRENT_BINARY_DIR}/grpc/src/grpc/${CMAKE_BUILD_TYPE}/gpr.lib)
else()
set(GRPC_LIBRARIES
set(grpc_STATIC_LIBRARIES
${CMAKE_CURRENT_BINARY_DIR}/grpc/src/grpc/libgrpc++_unsecure.a
${CMAKE_CURRENT_BINARY_DIR}/grpc/src/grpc/libgrpc_unsecure.a
${CMAKE_CURRENT_BINARY_DIR}/grpc/src/grpc/libgpr.a)
@ -30,6 +30,6 @@ ExternalProject_Add(grpc
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF
-DPROTOBUF_INCLUDE_DIRS:STRING=${PROTOBUF_INCLUDE_DIRS}
-DPROTOBUF_LIBRARIES:STRING=${PROTOBUF_LIBRARIES}
-DPROTOBUF_LIBRARIES:STRING=${protobuf_STATIC_LIBRARIES}
)

View File

@ -17,41 +17,23 @@ add_custom_target(highwayhash_copy_headers_to_destination
if(WIN32)
set(highwayhash_HEADERS "${highwayhash_BUILD}/highwayhash/*.h")
set(highwayhash_STATIC_LIBRARIES ${highwayhash_INSTALL}/lib/highwayhash.lib)
ExternalProject_Add(highwayhash
PREFIX highwayhash
GIT_REPOSITORY ${highwayhash_URL}
GIT_TAG ${highwayhash_TAG}
DOWNLOAD_DIR "${DOWNLOAD_LOCATION}"
BUILD_IN_SOURCE 1
PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/patches/highwayhash/CMakeLists.txt ${highwayhash_BUILD}
INSTALL_DIR ${highwayhash_INSTALL}
CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF
-DCMAKE_INSTALL_PREFIX:STRING=${highwayhash_INSTALL})
add_custom_command(TARGET highwayhash_copy_headers_to_destination PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${highwayhash_INSTALL}/include/ ${highwayhash_INCLUDE_DIR}/highwayhash)
else()
set(highwayhash_HEADERS "${highwayhash_BUILD}/highwayhash/*.h")
set(highwayhash_STATIC_LIBRARIES ${highwayhash_INSTALL}/lib/libhighwayhash.a)
ExternalProject_Add(highwayhash
PREFIX highwayhash
GIT_REPOSITORY ${highwayhash_URL}
GIT_TAG ${highwayhash_TAG}
DOWNLOAD_DIR "${DOWNLOAD_LOCATION}"
BUILD_IN_SOURCE 1
BUILD_COMMAND $(MAKE)
CONFIGURE_COMMAND ""
INSTALL_COMMAND "")
foreach(header_file ${highwayhash_HEADERS})
add_custom_command(TARGET highwayhash_copy_headers_to_destination PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${header_file} ${highwayhash_INCLUDE_DIR}/highwayhash)
endforeach()
endif()
ExternalProject_Add(highwayhash
PREFIX highwayhash
GIT_REPOSITORY ${highwayhash_URL}
GIT_TAG ${highwayhash_TAG}
DOWNLOAD_DIR "${DOWNLOAD_LOCATION}"
BUILD_IN_SOURCE 1
PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/patches/highwayhash/CMakeLists.txt ${highwayhash_BUILD}
INSTALL_DIR ${highwayhash_INSTALL}
CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF
-DCMAKE_INSTALL_PREFIX:STRING=${highwayhash_INSTALL})
add_custom_command(TARGET highwayhash_copy_headers_to_destination PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${highwayhash_INSTALL}/include/ ${highwayhash_INCLUDE_DIR}/highwayhash)

View File

@ -5,16 +5,17 @@ set(PROTOBUF_URL https://github.com/google/protobuf/releases/download/v3.1.0/pro
set(PROTOBUF_HASH SHA256=0c18ccc99e921c407f359047f9b56cca196c3ab36eed79e5979df6c1f9e623b7)
if(WIN32)
set(PROTOBUF_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/protobuf/src/protobuf/${CMAKE_BUILD_TYPE}/libprotobuf.lib)
set(protobuf_STATIC_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/protobuf/src/protobuf/${CMAKE_BUILD_TYPE}/libprotobuf.lib)
set(PROTOBUF_PROTOC_EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/protobuf/src/protobuf/${CMAKE_BUILD_TYPE}/protoc.exe)
else()
set(PROTOBUF_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/protobuf/src/protobuf/libprotobuf.a)
set(protobuf_STATIC_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/protobuf/src/protobuf/libprotobuf.a)
set(PROTOBUF_PROTOC_EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/protobuf/src/protobuf/protoc)
endif()
ExternalProject_Add(protobuf
PREFIX protobuf
URL ${PROTOBUF_URL}
URL_HASH ${PROTOBUF_HASH}
DOWNLOAD_DIR "${DOWNLOAD_LOCATION}"
BUILD_IN_SOURCE 1
SOURCE_DIR ${CMAKE_BINARY_DIR}/protobuf/src/protobuf

View File

@ -1 +0,0 @@
# [TODO]

View File

@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 2.8.3)
project(giflib)
set(GIFLIB_SRCS
"lib/dgif_lib.c"
"lib/egif_lib.c"
"lib/gif_font.c"
"lib/gif_hash.h"
"lib/gifalloc.c"
"lib/openbsd-reallocarray.c"
"lib/gif_err.c"
"lib/quantize.c"
"lib/gif_hash.c"
"lib/gif_lib.h"
"lib/gif_lib_private.h"
)
set(GIFLIB_INCLUDES
"lib/gif_lib.h"
)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib")
add_library(giflib ${GIFLIB_SRCS})
install(TARGETS giflib
RUNTIME DESTINATION bin COMPONENT RuntimeLibraries
LIBRARY DESTINATION lib COMPONENT RuntimeLibraries
ARCHIVE DESTINATION lib COMPONENT Development)
foreach(GIFLIB_INCLUDE ${GIFLIB_INCLUDES})
install(FILES ${GIFLIB_INCLUDE} DESTINATION include COMPONENT Development)
endforeach()

View File

@ -40,6 +40,11 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
add_library(highwayhash ${HIGHWAYHASH_SRCS})
# C++11
target_compile_features(highwayhash PRIVATE
cxx_rvalue_references
)
install(TARGETS highwayhash
LIBRARY DESTINATION lib COMPONENT RuntimeLibraries
ARCHIVE DESTINATION lib COMPONENT Development)

View File

@ -1 +0,0 @@
# [TODO]

View File

@ -12,21 +12,6 @@ add_library(tf_cc_framework OBJECT ${tf_cc_framework_srcs})
add_dependencies(tf_cc_framework tf_core_framework)
target_include_directories(tf_cc_framework PRIVATE
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
)
target_compile_options(tf_cc_framework PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_cc_framework PRIVATE
cxx_rvalue_references
)
########################################################
# tf_cc_op_gen_main library
########################################################
@ -40,67 +25,10 @@ add_library(tf_cc_op_gen_main OBJECT ${tf_cc_op_gen_main_srcs})
add_dependencies(tf_cc_op_gen_main tf_core_framework)
target_include_directories(tf_cc_op_gen_main PRIVATE
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
)
#target_link_libraries(tf_cc_op_gen_main
# ${CMAKE_THREAD_LIBS_INIT}
# ${PROTOBUF_LIBRARIES}
# tf_protos_cc
# tf_core_lib
# tf_core_framework
#)
target_compile_options(tf_cc_op_gen_main PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_cc_op_gen_main PRIVATE
cxx_rvalue_references
)
########################################################
# tf_gen_op_wrapper_cc executables
########################################################
#
# # Run the op generator.
# if name == "sendrecv_ops":
# include_internal = "1"
# else:
# include_internal = "0"
# native.genrule(
# name=name + "_genrule",
# outs=[out_ops_file + ".h", out_ops_file + ".cc"],
# tools=[":" + tool],
# cmd=("$(location :" + tool + ") $(location :" + out_ops_file + ".h) " +
# "$(location :" + out_ops_file + ".cc) " + include_internal))
#def tf_gen_op_wrappers_cc(name,
# op_lib_names=[],
# other_srcs=[],
# other_hdrs=[],
# pkg=""):
# subsrcs = other_srcs
# subhdrs = other_hdrs
# for n in op_lib_names:
# tf_gen_op_wrapper_cc(n, "ops/" + n, pkg=pkg)
# subsrcs += ["ops/" + n + ".cc"]
# subhdrs += ["ops/" + n + ".h"]
#
# native.cc_library(name=name,
# srcs=subsrcs,
# hdrs=subhdrs,
# deps=["//tensorflow/core:core_cpu"],
# copts=tf_copts(),
# alwayslink=1,)
# create directory for ops generated files
set(cc_ops_target_dir ${CMAKE_CURRENT_BINARY_DIR}/tensorflow/cc/ops)
@ -115,18 +43,6 @@ set(tf_cc_op_lib_names
"user_ops"
)
foreach(tf_cc_op_lib_name ${tf_cc_op_lib_names})
#tf_gen_op_wrapper_cc(name, out_ops_file, pkg=""):
# # Construct an op generator binary for these ops.
# tool = out_ops_file + "_gen_cc" #example ops/array_ops_gen_cc
# native.cc_binary(
# name = tool,
# copts = tf_copts(),
# linkopts = ["-lm"],
# linkstatic = 1, # Faster to link this one-time-use binary dynamically
# deps = (["//tensorflow/cc:cc_op_gen_main",
# pkg + ":" + name + "_op_lib"])
# )
# Using <TARGET_OBJECTS:...> to work around an issue where no ops were
# registered (static initializers dropped by the linker because the ops
# are not used explicitly in the *_gen_cc executables).
@ -137,39 +53,9 @@ foreach(tf_cc_op_lib_name ${tf_cc_op_lib_names})
$<TARGET_OBJECTS:tf_core_framework>
)
target_include_directories(${tf_cc_op_lib_name}_gen_cc PRIVATE
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
)
find_package(ZLIB REQUIRED)
target_link_libraries(${tf_cc_op_lib_name}_gen_cc PRIVATE
${CMAKE_THREAD_LIBS_INIT}
${PROTOBUF_LIBRARIES}
tf_protos_cc
${gif_STATIC_LIBRARIES}
${jpeg_STATIC_LIBRARIES}
${png_STATIC_LIBRARIES}
${ZLIB_LIBRARIES}
${jsoncpp_STATIC_LIBRARIES}
${boringssl_STATIC_LIBRARIES}
${CMAKE_DL_LIBS}
)
if(tensorflow_ENABLE_SSL_SUPPORT)
target_link_libraries(${tf_cc_op_lib_name}_gen_cc PRIVATE
${boringssl_STATIC_LIBRARIES})
endif()
target_compile_options(${tf_cc_op_lib_name}_gen_cc PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
-lm
)
# C++11
target_compile_features(${tf_cc_op_lib_name}_gen_cc PRIVATE
cxx_rvalue_references
${tensorflow_EXTERNAL_LIBRARIES}
)
set(cc_ops_include_internal 0)
@ -198,43 +84,3 @@ add_library(tf_cc_ops OBJECT
"${tensorflow_source_dir}/tensorflow/cc/ops/const_op.cc"
"${tensorflow_source_dir}/tensorflow/cc/ops/standard_ops.h"
)
target_include_directories(tf_cc_ops PRIVATE
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
)
#target_link_libraries(tf_cc_ops
# ${CMAKE_THREAD_LIBS_INIT}
# ${PROTOBUF_LIBRARIES}
# tf_protos_cc
# tf_core_lib
# tf_core_cpu
# tf_models_word2vec_ops
#)
target_compile_options(tf_cc_ops PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_cc_ops PRIVATE
cxx_rvalue_references
)
#tf_gen_op_wrappers_cc(
# name = "cc_ops",
# op_lib_names = [
# ...
# ],
# other_hdrs = [
# "ops/const_op.h",
# "ops/standard_ops.h",
# ],
# other_srcs = [
# "ops/const_op.cc",
# ] + glob(["ops/*_grad.cc"]),
# pkg = "//tensorflow/core",
#)

View File

@ -30,30 +30,4 @@ list(APPEND tf_core_cpu_srcs
)
add_library(tf_core_cpu OBJECT ${tf_core_cpu_srcs})
target_include_directories(tf_core_cpu PRIVATE
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
)
add_dependencies(tf_core_cpu
tf_core_framework
)
#target_link_libraries(tf_core_cpu
# ${CMAKE_THREAD_LIBS_INIT}
# ${PROTOBUF_LIBRARIES}
# tf_core_framework
# tf_core_lib
# tf_protos_cc
#)
target_compile_options(tf_core_cpu PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_core_cpu PRIVATE
cxx_rvalue_references
)
add_dependencies(tf_core_cpu tf_core_framework)

View File

@ -18,27 +18,3 @@ list(REMOVE_ITEM tf_core_direct_session_srcs ${tf_core_direct_session_test_srcs}
add_library(tf_core_direct_session OBJECT ${tf_core_direct_session_srcs})
add_dependencies(tf_core_direct_session tf_core_cpu)
target_include_directories(tf_core_direct_session PRIVATE
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
)
#target_link_libraries(tf_core_direct_session
# ${CMAKE_THREAD_LIBS_INIT}
# ${PROTOBUF_LIBRARIES}
# tf_core_cpu
# tf_core_framework
# tf_core_lib
# tf_protos_cc
#)
target_compile_options(tf_core_direct_session PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_core_direct_session PRIVATE
cxx_rvalue_references
)

View File

@ -20,22 +20,6 @@ add_dependencies(tf_core_distributed_runtime
tf_core_cpu grpc
)
target_include_directories(tf_core_distributed_runtime PRIVATE
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
${GRPC_INCLUDE_DIRS}
)
target_compile_options(tf_core_distributed_runtime PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_core_distributed_runtime PRIVATE
cxx_rvalue_references
)
########################################################
# grpc_tensorflow_server executable
########################################################
@ -56,42 +40,7 @@ add_executable(grpc_tensorflow_server
$<TARGET_OBJECTS:tf_core_distributed_runtime>
)
add_dependencies(tf_core_distributed_runtime
grpc
)
target_include_directories(grpc_tensorflow_server PUBLIC
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
${GRPC_INCLUDE_DIRS}
)
find_package(ZLIB REQUIRED)
target_link_libraries(grpc_tensorflow_server PUBLIC
${CMAKE_THREAD_LIBS_INIT}
${PROTOBUF_LIBRARIES}
${GRPC_LIBRARIES}
tf_protos_cc
${farmhash_STATIC_LIBRARIES}
${gif_STATIC_LIBRARIES}
${jpeg_STATIC_LIBRARIES}
${jsoncpp_STATIC_LIBRARIES}
${png_STATIC_LIBRARIES}
${ZLIB_LIBRARIES}
${CMAKE_DL_LIBS}
)
if(tensorflow_ENABLE_SSL_SUPPORT)
target_link_libraries(grpc_tensorflow_server PUBLIC
${boringssl_STATIC_LIBRARIES})
endif()
target_compile_options(grpc_tensorflow_server PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(grpc_tensorflow_server PRIVATE
cxx_rvalue_references
${tensorflow_EXTERNAL_LIBRARIES}
)

View File

@ -71,8 +71,6 @@ endfunction()
# tf_protos_cc library
########################################################
include_directories(${PROTOBUF_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
file(GLOB_RECURSE tf_protos_cc_srcs RELATIVE ${tensorflow_source_dir}
"${tensorflow_source_dir}/tensorflow/core/*.proto"
)
@ -114,16 +112,9 @@ RELATIVE_PROTOBUF_TEXT_GENERATE_CPP(PROTO_TEXT_SRCS PROTO_TEXT_HDRS
)
add_library(tf_protos_cc ${PROTO_SRCS} ${PROTO_HDRS})
target_include_directories(tf_protos_cc PUBLIC
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(tf_protos_cc PUBLIC
${PROTOBUF_LIBRARIES}
)
# C++11
target_compile_features(tf_protos_cc PRIVATE
cxx_rvalue_references
)
########################################################
# tf_core_lib library
@ -131,11 +122,33 @@ target_compile_features(tf_protos_cc PRIVATE
file(GLOB_RECURSE tf_core_lib_srcs
"${tensorflow_source_dir}/tensorflow/core/lib/*.h"
"${tensorflow_source_dir}/tensorflow/core/lib/*.cc"
"${tensorflow_source_dir}/tensorflow/core/platform/*.h"
"${tensorflow_source_dir}/tensorflow/core/platform/*.cc"
"${tensorflow_source_dir}/tensorflow/core/public/*.h"
)
file(GLOB tf_core_platform_srcs
"${tensorflow_source_dir}/tensorflow/core/platform/*.h"
"${tensorflow_source_dir}/tensorflow/core/platform/*.cc"
"${tensorflow_source_dir}/tensorflow/core/platform/default/*.h"
"${tensorflow_source_dir}/tensorflow/core/platform/default/*.cc")
list(APPEND tf_core_lib_srcs ${tf_core_platform_srcs})
if(UNIX)
file(GLOB tf_core_platform_posix_srcs
"${tensorflow_source_dir}/tensorflow/core/platform/posix/*.h"
"${tensorflow_source_dir}/tensorflow/core/platform/posix/*.cc"
)
list(APPEND tf_core_lib_srcs ${tf_core_platform_posix_srcs})
endif(UNIX)
if(tensorflow_ENABLE_SSL_SUPPORT)
# Cloud libraries require boringssl.
file(GLOB tf_core_platform_cloud_srcs
"${tensorflow_source_dir}/tensorflow/core/platform/cloud/*.h"
"${tensorflow_source_dir}/tensorflow/core/platform/cloud/*.cc"
)
list(APPEND tf_core_lib_srcs ${tf_core_platform_cloud_srcs})
endif()
file(GLOB_RECURSE tf_core_lib_test_srcs
"${tensorflow_source_dir}/tensorflow/core/lib/*test*.h"
"${tensorflow_source_dir}/tensorflow/core/lib/*test*.cc"
@ -143,8 +156,7 @@ file(GLOB_RECURSE tf_core_lib_test_srcs
"${tensorflow_source_dir}/tensorflow/core/platform/*test*.cc"
"${tensorflow_source_dir}/tensorflow/core/public/*test*.h"
)
list(REMOVE_ITEM tf_core_lib_srcs ${tf_core_lib_test_srcs})
list(REMOVE_ITEM tf_core_lib_srcs ${tf_core_lib_test_srcs})
if(NOT tensorflow_ENABLE_SSL_SUPPORT)
file(GLOB_RECURSE tf_core_lib_cloud_srcs
@ -155,38 +167,7 @@ if(NOT tensorflow_ENABLE_SSL_SUPPORT)
endif()
add_library(tf_core_lib OBJECT ${tf_core_lib_srcs})
target_include_directories(tf_core_lib PUBLIC
${tensorflow_source_dir}
${gif_INCLUDE_DIR}
${jpeg_INCLUDE_DIR}
${png_INCLUDE_DIR}
${eigen_INCLUDE_DIRS}
${jsoncpp_INCLUDE_DIR}
)
target_compile_options(tf_core_lib PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_core_lib PRIVATE
cxx_rvalue_references
)
add_dependencies(tf_core_lib
gif_copy_headers_to_destination
jpeg_copy_headers_to_destination
png_copy_headers_to_destination
eigen
tf_protos_cc
jsoncpp
)
if(tensorflow_ENABLE_SSL_SUPPORT)
target_include_directories(tf_core_lib PUBLIC ${boringssl_INCLUDE_DIR})
add_dependencies(tf_core_lib boringssl)
endif()
add_dependencies(tf_core_lib ${tensorflow_EXTERNAL_DEPENDENCIES} tf_protos_cc)
# Tricky setup to force always rebuilding
# force_rebuild always runs forcing ${VERSION_INFO_CC} target to run
@ -197,13 +178,12 @@ add_custom_target(force_rebuild_target ALL DEPENDS ${VERSION_INFO_CC})
add_custom_command(OUTPUT __force_rebuild COMMAND cmake -E echo)
add_custom_command(OUTPUT
${VERSION_INFO_CC}
COMMAND ${tensorflow_source_dir}/tensorflow/tools/git/gen_git_source.py
COMMAND ${PYTHON_EXECUTABLE} ${tensorflow_source_dir}/tensorflow/tools/git/gen_git_source.py
--raw_generate ${VERSION_INFO_CC}
DEPENDS __force_rebuild)
set(tf_version_srcs ${tensorflow_source_dir}/tensorflow/core/util/version_info.cc)
########################################################
# tf_core_framework library
########################################################
@ -212,7 +192,6 @@ file(GLOB_RECURSE tf_core_framework_srcs
"${tensorflow_source_dir}/tensorflow/core/framework/*.cc"
"${tensorflow_source_dir}/tensorflow/core/util/*.h"
"${tensorflow_source_dir}/tensorflow/core/util/*.cc"
"${tensorflow_source_dir}/tensorflow/core/client/tensor_c_api.cc"
"${tensorflow_source_dir}/tensorflow/core/common_runtime/session.cc"
"${tensorflow_source_dir}/tensorflow/core/common_runtime/session_factory.cc"
"${tensorflow_source_dir}/tensorflow/core/common_runtime/session_options.cc"
@ -237,19 +216,7 @@ add_library(tf_core_framework OBJECT
${tf_version_srcs}
${PROTO_TEXT_HDRS}
${PROTO_TEXT_SRCS})
target_include_directories(tf_core_framework PUBLIC
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
)
add_dependencies(tf_core_framework
tf_core_lib
proto_text
)
target_compile_options(tf_core_framework PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_core_framework PRIVATE
cxx_rvalue_references
)

View File

@ -1,10 +1,73 @@
########################################################
# tf_core_kernels library
########################################################
file(GLOB_RECURSE tf_core_kernels_srcs
"${tensorflow_source_dir}/tensorflow/core/kernels/*.h"
"${tensorflow_source_dir}/tensorflow/core/kernels/*.cc"
)
if(tensorflow_BUILD_ALL_KERNELS)
file(GLOB_RECURSE tf_core_kernels_srcs
"${tensorflow_source_dir}/tensorflow/core/kernels/*.h"
"${tensorflow_source_dir}/tensorflow/core/kernels/*.cc"
)
else(tensorflow_BUILD_ALL_KERNELS)
# Build a minimal subset of kernels to be able to run a test program.
set(tf_core_kernels_srcs
"${tensorflow_source_dir}/tensorflow/core/kernels/bounds_check.h"
"${tensorflow_source_dir}/tensorflow/core/kernels/constant_op.h"
"${tensorflow_source_dir}/tensorflow/core/kernels/constant_op.cc"
"${tensorflow_source_dir}/tensorflow/core/kernels/fill_functor.h"
"${tensorflow_source_dir}/tensorflow/core/kernels/fill_functor.cc"
"${tensorflow_source_dir}/tensorflow/core/kernels/matmul_op.h"
"${tensorflow_source_dir}/tensorflow/core/kernels/matmul_op.cc"
"${tensorflow_source_dir}/tensorflow/core/kernels/no_op.h"
"${tensorflow_source_dir}/tensorflow/core/kernels/no_op.cc"
"${tensorflow_source_dir}/tensorflow/core/kernels/sendrecv_ops.h"
"${tensorflow_source_dir}/tensorflow/core/kernels/sendrecv_ops.cc"
)
endif(tensorflow_BUILD_ALL_KERNELS)
if(tensorflow_BUILD_CONTRIB_KERNELS)
set(tf_contrib_kernels_srcs
"${tensorflow_source_dir}/tensorflow/contrib/factorization/kernels/clustering_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/factorization/kernels/wals_solver_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/factorization/ops/clustering_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/factorization/ops/factorization_ops.cc"
#"${tensorflow_source_dir}/tensorflow/contrib/ffmpeg/decode_audio_op.cc"
#"${tensorflow_source_dir}/tensorflow/contrib/ffmpeg/encode_audio_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/layers/kernels/bucketization_kernel.cc"
"${tensorflow_source_dir}/tensorflow/contrib/layers/kernels/sparse_feature_cross_kernel.cc"
"${tensorflow_source_dir}/tensorflow/contrib/layers/ops/bucketization_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/layers/ops/sparse_feature_cross_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/metrics/kernels/set_kernels.cc"
"${tensorflow_source_dir}/tensorflow/contrib/metrics/ops/set_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/rnn/kernels/gru_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/rnn/kernels/lstm_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/rnn/ops/gru_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/rnn/ops/lstm_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/core/ops/best_splits_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/core/ops/count_extremely_random_stats_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/core/ops/finished_nodes_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/core/ops/grow_tree_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/core/ops/sample_inputs_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/core/ops/scatter_add_ndim_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/core/ops/topn_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/core/ops/tree_predictions_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/core/ops/tree_utils.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/core/ops/update_fertile_slots_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/data/sparse_values_to_indices.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/data/string_to_float_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/hybrid/core/ops/hard_routing_function_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/hybrid/core/ops/k_feature_gradient_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/hybrid/core/ops/k_feature_routing_function_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/hybrid/core/ops/routing_function_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/hybrid/core/ops/routing_gradient_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/hybrid/core/ops/stochastic_hard_routing_function_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/hybrid/core/ops/stochastic_hard_routing_gradient_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/hybrid/core/ops/unpack_path_op.cc"
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/hybrid/core/ops/utils.cc"
)
list(APPEND tf_core_kernels_srcs ${tf_contrib_kernels_srcs})
endif(tensorflow_BUILD_CONTRIB_KERNELS)
file(GLOB_RECURSE tf_core_kernels_exclude_srcs
"${tensorflow_source_dir}/tensorflow/core/kernels/*test*.h"
@ -13,51 +76,11 @@ file(GLOB_RECURSE tf_core_kernels_exclude_srcs
"${tensorflow_source_dir}/tensorflow/core/kernels/*testutil.cc"
"${tensorflow_source_dir}/tensorflow/core/kernels/*main.cc"
"${tensorflow_source_dir}/tensorflow/core/kernels/*.cu.cc"
"${tensorflow_source_dir}/tensorflow/core/kernels/debug_ops.h"
"${tensorflow_source_dir}/tensorflow/core/kernels/debug_ops.cc"
"${tensorflow_source_dir}/tensorflow/core/kernels/debug_ops.h" # stream_executor dependency
"${tensorflow_source_dir}/tensorflow/core/kernels/debug_ops.cc" # stream_executor dependency
)
list(REMOVE_ITEM tf_core_kernels_srcs ${tf_core_kernels_exclude_srcs})
list(REMOVE_ITEM tf_core_kernels_srcs ${tf_core_kernels_exclude_srcs})
add_library(tf_core_kernels OBJECT ${tf_core_kernels_srcs})
add_dependencies(tf_core_kernels
tf_core_cpu
farmhash
highwayhash
farmhash_copy_headers_to_destination
highwayhash_copy_headers_to_destination
)
target_include_directories(tf_core_kernels PRIVATE
${tensorflow_source_dir}
${png_INCLUDE_DIR}
${eigen_INCLUDE_DIRS}
${farmhash_INCLUDE_DIR}
${highwayhash_INCLUDE_DIR}
)
#target_link_libraries(tf_core_kernels
# ${CMAKE_THREAD_LIBS_INIT}
# ${PROTOBUF_LIBRARIES}
# tf_core_cpu
# tf_core_framework
# tf_core_lib
# tf_protos_cc
# tf_models_word2vec_kernels
# tf_stream_executor
# tf_core_ops
# tf_core_cpu
#)
# "@gemmlowp//:eight_bit_int_gemm",
target_compile_options(tf_core_kernels PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_core_kernels PRIVATE
cxx_rvalue_references
)
add_dependencies(tf_core_kernels tf_core_cpu)

View File

@ -1,39 +1,25 @@
#def tf_gen_op_libs(op_lib_names):
# # Make library out of each op so it can also be used to generate wrappers
# # for various languages.
# for n in op_lib_names:
# native.cc_library(name=n + "_op_lib"
# copts=tf_copts(),
# srcs=["ops/" + n + ".cc"],
# deps=(["//tensorflow/core:framework"]),
# visibility=["//visibility:public"],
# alwayslink=1,
# linkstatic=1,)
set(tf_op_lib_names
"array_ops"
"attention_ops"
"candidate_sampling_ops"
"control_flow_ops"
"ctc_ops"
"data_flow_ops"
"functional_ops"
"image_ops"
"io_ops"
"linalg_ops"
"logging_ops"
"functional_ops"
"math_ops"
"nn_ops"
"no_op"
"parsing_ops"
"random_ops"
"script_ops"
"sdca_ops"
"sendrecv_ops"
"sparse_ops"
"state_ops"
"string_ops"
"summary_ops"
"training_ops"
)
@ -48,32 +34,8 @@ foreach(tf_op_lib_name ${tf_op_lib_names})
add_library(tf_${tf_op_lib_name} OBJECT ${tf_${tf_op_lib_name}_srcs})
add_dependencies(tf_${tf_op_lib_name} tf_core_framework)
target_include_directories(tf_${tf_op_lib_name} PRIVATE
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
)
target_compile_options(tf_${tf_op_lib_name} PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_${tf_op_lib_name} PRIVATE
cxx_rvalue_references
)
endforeach()
#cc_library(
# name = "user_ops_op_lib"
# srcs = glob(["user_ops/**/*.cc"]),
# copts = tf_copts(),
# linkstatic = 1,
# visibility = ["//visibility:public"],
# deps = [":framework"],
# alwayslink = 1,
#)
########################################################
# tf_user_ops library
########################################################
@ -85,50 +47,6 @@ add_library(tf_user_ops OBJECT ${tf_user_ops_srcs})
add_dependencies(tf_user_ops tf_core_framework)
target_include_directories(tf_user_ops PRIVATE
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
)
target_compile_options(tf_user_ops PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_user_ops PRIVATE
cxx_rvalue_references
)
#tf_cuda_library(
# name = "ops"
# srcs = glob(
# [
# "ops/**/*.h"
# "ops/**/*.cc"
# "user_ops/**/*.h"
# "user_ops/**/*.cc"
# ],
# exclude = [
# "**/*test*"
# "**/*main.cc"
# "user_ops/**/*.cu.cc"
# ],
# ),
# copts = tf_copts(),
# linkstatic = 1,
# visibility = ["//visibility:public"],
# deps = [
# ":core"
# ":lib"
# ":protos_cc"
# "//tensorflow/models/embedding:word2vec_ops"
# "//third_party/eigen3"
# ],
# alwayslink = 1,
#)
########################################################
# tf_core_ops library
########################################################
@ -154,29 +72,3 @@ list(REMOVE_ITEM tf_core_ops_srcs ${tf_core_ops_exclude_srcs})
add_library(tf_core_ops OBJECT ${tf_core_ops_srcs})
add_dependencies(tf_core_ops tf_core_cpu)
target_include_directories(tf_core_ops PRIVATE
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
)
#target_link_libraries(tf_core_ops
# ${CMAKE_THREAD_LIBS_INIT}
# ${PROTOBUF_LIBRARIES}
# tf_protos_cc
# tf_core_lib
# tf_core_cpu
# tf_models_word2vec_ops
#)
target_compile_options(tf_core_ops PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_core_ops PRIVATE
cxx_rvalue_references
)

View File

@ -1,15 +1,3 @@
#cc_library(
# name = "word2vec_ops",
# srcs = [
# "word2vec_ops.cc",
# ],
# visibility = ["//tensorflow:internal"],
# deps = [
# "//tensorflow/core:framework",
# ],
# alwayslink = 1,
#)
########################################################
# tf_models_word2vec_ops library
########################################################
@ -19,43 +7,8 @@ file(GLOB tf_models_word2vec_ops_srcs
add_library(tf_models_word2vec_ops OBJECT ${tf_models_word2vec_ops_srcs})
target_include_directories(tf_models_word2vec_ops PRIVATE
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
)
add_dependencies(tf_models_word2vec_ops tf_core_framework)
add_dependencies(tf_models_word2vec_ops
tf_core_framework
)
#target_link_libraries(tf_models_word2vec_ops
# ${CMAKE_THREAD_LIBS_INIT}
# ${PROTOBUF_LIBRARIES}
# tf_core_framework
# tf_core_lib
# tf_protos_cc
#)
target_compile_options(tf_models_word2vec_ops PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_models_word2vec_ops PRIVATE
cxx_rvalue_references
)
#cc_library(
# name = "word2vec_kernels",
# srcs = [
# "word2vec_kernels.cc",
# ],
# visibility = ["//tensorflow:internal"],
# deps = [
# "//tensorflow/core",
# ],
# alwayslink = 1,
#)
########################################################
# tf_models_word2vec_kernels library
########################################################
@ -65,30 +18,4 @@ file(GLOB tf_models_word2vec_kernels_srcs
add_library(tf_models_word2vec_kernels OBJECT ${tf_models_word2vec_kernels_srcs})
target_include_directories(tf_models_word2vec_kernels PRIVATE
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
)
add_dependencies(tf_models_word2vec_kernels
tf_core_cpu
)
#target_link_libraries(tf_models_word2vec_kernels
# ${CMAKE_THREAD_LIBS_INIT}
# ${PROTOBUF_LIBRARIES}
# tf_core_framework
# tf_core_lib
# tf_protos_cc
# tf_core_cpu
#)
target_compile_options(tf_models_word2vec_kernels PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_models_word2vec_kernels PRIVATE
cxx_rvalue_references
)
add_dependencies(tf_models_word2vec_kernels tf_core_cpu)

View File

@ -18,7 +18,7 @@ include(FindPythonInterp)
if(NOT PYTHON_INCLUDE_DIR)
set(PYTHON_NOT_FOUND false)
exec_program("${PYTHON_EXECUTABLE}"
ARGS "-c 'import distutils.sysconfig; print distutils.sysconfig.get_python_inc()'"
ARGS "-c \"import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())\""
OUTPUT_VARIABLE PYTHON_INCLUDE_DIR
RETURN_VALUE PYTHON_NOT_FOUND)
if(${PYTHON_NOT_FOUND})
@ -32,7 +32,7 @@ FIND_PACKAGE(PythonLibs)
if(NOT NUMPY_INCLUDE_DIR)
set(NUMPY_NOT_FOUND false)
exec_program("${PYTHON_EXECUTABLE}"
ARGS "-c 'import numpy; print numpy.get_include()'"
ARGS "-c \"import numpy; print(numpy.get_include())\""
OUTPUT_VARIABLE NUMPY_INCLUDE_DIR
RETURN_VALUE NUMPY_NOT_FOUND)
if(${NUMPY_NOT_FOUND})
@ -50,7 +50,6 @@ find_package(ZLIB REQUIRED)
########################################################
# TODO(mrry): Configure this to build in a directory other than tf_python/
# TODO(mrry): Assemble the Python files into a PIP package.
# tf_python_srcs contains all static .py files
file(GLOB_RECURSE tf_python_srcs RELATIVE ${tensorflow_source_dir}
@ -172,21 +171,6 @@ add_library(tf_python_op_gen_main OBJECT ${tf_python_op_gen_main_srcs})
add_dependencies(tf_python_op_gen_main tf_core_framework)
target_include_directories(tf_python_op_gen_main PRIVATE
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
)
target_compile_options(tf_python_op_gen_main PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_python_op_gen_main PRIVATE
cxx_rvalue_references
)
# create directory for ops generated files
set(python_ops_target_dir ${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow/python/ops)
@ -216,37 +200,13 @@ function(GENERATE_PYTHON_OP_LIB tf_python_op_lib_name)
$<TARGET_OBJECTS:tf_${tf_python_op_lib_name}>
$<TARGET_OBJECTS:tf_core_lib>
$<TARGET_OBJECTS:tf_core_framework>
${GENERATE_PYTHON_OP_LIB_ADDITIONAL_LIBRARIES}
)
target_include_directories(${tf_python_op_lib_name}_gen_python PRIVATE
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
${GENERATE_PYTHON_OP_LIB_ADDITIONAL_LIBRARIES}
)
target_link_libraries(${tf_python_op_lib_name}_gen_python PRIVATE
${CMAKE_THREAD_LIBS_INIT}
${PROTOBUF_LIBRARIES}
tf_protos_cc
${gif_STATIC_LIBRARIES}
${jpeg_STATIC_LIBRARIES}
${png_STATIC_LIBRARIES}
${ZLIB_LIBRARIES}
${jsoncpp_STATIC_LIBRARIES}
${CMAKE_DL_LIBS}
${tensorflow_EXTERNAL_LIBRARIES}
)
target_compile_options(${tf_python_op_lib_name}_gen_python PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
-lm
)
# C++11
target_compile_features(${tf_python_op_lib_name}_gen_python PRIVATE
cxx_rvalue_references
)
if(tensorflow_ENABLE_SSL_SUPPORT)
target_link_libraries(${tf_python_op_lib_name}_gen_python PRIVATE
${boringssl_STATIC_LIBRARIES})
endif()
# Use the generated C++ executable to create a Python file
# containing the wrappers.
add_custom_command(
@ -275,6 +235,7 @@ GENERATE_PYTHON_OP_LIB("nn_ops")
GENERATE_PYTHON_OP_LIB("parsing_ops")
GENERATE_PYTHON_OP_LIB("random_ops")
GENERATE_PYTHON_OP_LIB("script_ops")
GENERATE_PYTHON_OP_LIB("sdca_ops")
GENERATE_PYTHON_OP_LIB("state_ops")
GENERATE_PYTHON_OP_LIB("sparse_ops")
GENERATE_PYTHON_OP_LIB("string_ops")
@ -340,38 +301,18 @@ add_library(pywrap_tensorflow SHARED
$<TARGET_OBJECTS:tf_core_framework>
$<TARGET_OBJECTS:tf_core_ops>
$<TARGET_OBJECTS:tf_core_direct_session>
$<TARGET_OBJECTS:tf_core_distributed_runtime>
$<$<BOOL:${tensorflow_ENABLE_GRPC_SUPPORT}>:$<TARGET_OBJECTS:tf_core_distributed_runtime>>
$<TARGET_OBJECTS:tf_core_kernels>
)
target_link_libraries(pywrap_tensorflow
${CMAKE_THREAD_LIBS_INIT}
tf_protos_cc
${GRPC_LIBRARIES}
${PROTOBUF_LIBRARY}
${farmhash_STATIC_LIBRARIES}
${gif_STATIC_LIBRARIES}
${jpeg_STATIC_LIBRARIES}
${jsoncpp_STATIC_LIBRARIES}
${png_STATIC_LIBRARIES}
${ZLIB_LIBRARIES}
${CMAKE_DL_LIBS}
)
target_include_directories(pywrap_tensorflow PUBLIC
${tensorflow_source_dir}
${CMAKE_CURRENT_BINARY_DIR}
${eigen_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIR}
${NUMPY_INCLUDE_DIR}
)
# C++11
target_compile_features(pywrap_tensorflow PRIVATE
cxx_rvalue_references
target_link_libraries(pywrap_tensorflow
${tensorflow_EXTERNAL_LIBRARIES}
tf_protos_cc
${PYTHON_LIBRARIES}
)
if(tensorflow_ENABLE_SSL_SUPPORT)
target_link_libraries(pywrap_tensorflow ${boringssl_STATIC_LIBRARIES})
endif()
############################################################
# Build a PIP package containing the TensorFlow runtime.
@ -385,9 +326,15 @@ add_dependencies(tf_python_build_pip_package
add_custom_command(TARGET tf_python_build_pip_package POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${tensorflow_source_dir}/tensorflow/contrib/cmake/setup.py
${CMAKE_CURRENT_BINARY_DIR}/tf_python/)
add_custom_command(TARGET tf_python_build_pip_package POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/libpywrap_tensorflow.so
${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow/python/_pywrap_tensorflow.so)
if(WIN32)
add_custom_command(TARGET tf_python_build_pip_package POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/pywrap_tensorflow.dll
${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow/python/_pywrap_tensorflow.pyd)
else()
add_custom_command(TARGET tf_python_build_pip_package POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/libpywrap_tensorflow.so
${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow/python/_pywrap_tensorflow.so)
endif()
add_custom_command(TARGET tf_python_build_pip_package POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${tensorflow_source_dir}/tensorflow/tools/pip_package/README
${CMAKE_CURRENT_BINARY_DIR}/tf_python/)

View File

@ -56,10 +56,6 @@ file(GLOB tf_stream_executor_srcs
add_library(tf_stream_executor OBJECT ${tf_stream_executor_srcs})
target_include_directories(tf_stream_executor PRIVATE
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
)
add_dependencies(tf_stream_executor
tf_core_lib
)
@ -69,14 +65,3 @@ add_dependencies(tf_stream_executor
# tf_protos_cc
# tf_core_lib
#)
target_compile_options(tf_stream_executor PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_stream_executor PRIVATE
cxx_rvalue_references
)

View File

@ -13,37 +13,9 @@ add_executable(${proto_text}
$<TARGET_OBJECTS:tf_core_lib>
)
target_include_directories(${proto_text} PUBLIC
${tensorflow_source_dir}
)
# TODO(mrry): Cut down the dependencies of this tool.
target_link_libraries(${proto_text} PUBLIC
${CMAKE_THREAD_LIBS_INIT}
${PROTOBUF_LIBRARIES}
${gif_STATIC_LIBRARIES}
${jpeg_STATIC_LIBRARIES}
${png_STATIC_LIBRARIES}
${ZLIB_LIBRARIES}
${jsoncpp_STATIC_LIBRARIES}
${CMAKE_DL_LIBS}
)
if(tensorflow_ENABLE_SSL_SUPPORT)
target_link_libraries(${proto_text} PUBLIC ${boringssl_STATIC_LIBRARIES})
endif()
target_link_libraries(${proto_text} PUBLIC ${tensorflow_EXTERNAL_LIBRARIES})
add_dependencies(${proto_text}
tf_core_lib
protobuf
)
target_compile_options(${proto_text} PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(${proto_text} PRIVATE
cxx_rvalue_references
grpc
)

View File

@ -1,18 +1,3 @@
#cc_binary(
# name = "tutorials_example_trainer",
# srcs = ["tutorials/example_trainer.cc"],
# copts = tf_copts(),
# linkopts = [
# "-lpthread",
# "-lm",
# ],
# deps = [
# ":cc_ops",
# "//tensorflow/core:kernels",
# "//tensorflow/core:tensorflow",
# ],
#)
set(tf_tutorials_example_trainer_srcs
"${tensorflow_source_dir}/tensorflow/cc/tutorials/example_trainer.cc"
)
@ -29,31 +14,7 @@ add_executable(tf_tutorials_example_trainer
$<TARGET_OBJECTS:tf_core_direct_session>
)
target_include_directories(tf_tutorials_example_trainer PUBLIC
${tensorflow_source_dir}
${eigen_INCLUDE_DIRS}
)
target_link_libraries(tf_tutorials_example_trainer PUBLIC
${CMAKE_THREAD_LIBS_INIT}
${PROTOBUF_STATIC_LIBRARIES}
tf_protos_cc
${boringssl_STATIC_LIBRARIES}
${farmhash_STATIC_LIBRARIES}
${gif_STATIC_LIBRARIES}
${jpeg_STATIC_LIBRARIES}
${jsoncpp_STATIC_LIBRARIES}
${png_STATIC_LIBRARIES}
${ZLIB_LIBRARIES}
${CMAKE_DL_LIBS}
)
target_compile_options(tf_tutorials_example_trainer PRIVATE
-fno-exceptions
-DEIGEN_AVOID_STL_ARRAY
)
# C++11
target_compile_features(tf_tutorials_example_trainer PRIVATE
cxx_rvalue_references
${tensorflow_EXTERNAL_LIBRARIES}
)