Restore a working cmake build. (#3606)

This commit is contained in:
Derek Murray 2016-08-03 11:16:09 -07:00 committed by GitHub
parent 27eeb441ba
commit c5f94b10bb
8 changed files with 90 additions and 3 deletions

View File

@ -39,6 +39,7 @@ set (DOWNLOAD_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/downloads"
mark_as_advanced(DOWNLOAD_LOCATION)
# External dependencies
include(gif)
include(png)
include(jpeg)
include(re2)

View File

@ -0,0 +1,38 @@
include (ExternalProject)
set(gif_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/gif_archive)
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_HEADERS
"${gif_INSTALL}/include/gif_lib.h"
)
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
--prefix=${gif_INSTALL}
--enable-shared=yes
)
# put gif includes in the directory where they are expected
add_custom_target(gif_create_destination_dir
COMMAND ${CMAKE_COMMAND} -E make_directory ${gif_INCLUDE_DIR}/giflib-5.1.4/lib
DEPENDS gif)
add_custom_target(gif_copy_headers_to_destination
DEPENDS gif_create_destination_dir)
foreach(header_file ${gif_HEADERS})
add_custom_command(TARGET gif_copy_headers_to_destination PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${header_file} ${gif_INCLUDE_DIR}/giflib-5.1.4/lib/)
endforeach()

View File

@ -1,10 +1,39 @@
########################################################
# tf_cc_framework library
########################################################
set(tf_cc_framework_srcs
"${tensorflow_source_dir}/tensorflow/cc/framework/ops.h"
"${tensorflow_source_dir}/tensorflow/cc/framework/ops.cc"
"${tensorflow_source_dir}/tensorflow/cc/framework/scope.h"
"${tensorflow_source_dir}/tensorflow/cc/framework/scope.cc"
)
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
########################################################
set(tf_cc_op_gen_main_srcs
"${tensorflow_source_dir}/tensorflow/cc/ops/cc_op_gen.cc"
"${tensorflow_source_dir}/tensorflow/cc/ops/cc_op_gen_main.cc"
"${tensorflow_source_dir}/tensorflow/cc/ops/cc_op_gen.h"
"${tensorflow_source_dir}/tensorflow/cc/framework/cc_op_gen.cc"
"${tensorflow_source_dir}/tensorflow/cc/framework/cc_op_gen_main.cc"
"${tensorflow_source_dir}/tensorflow/cc/framework/cc_op_gen.h"
)
add_library(tf_cc_op_gen_main OBJECT ${tf_cc_op_gen_main_srcs})
@ -120,6 +149,7 @@ foreach(tf_cc_op_lib_name ${tf_cc_op_lib_names})
${PROTOBUF_LIBRARIES}
tf_protos_cc
re2_lib
${gif_STATIC_LIBRARIES}
${jpeg_STATIC_LIBRARIES}
${png_STATIC_LIBRARIES}
${ZLIB_LIBRARIES}

View File

@ -4,8 +4,17 @@
file(GLOB tf_core_direct_session_srcs
"${tensorflow_source_dir}/tensorflow/core/common_runtime/direct_session.cc"
"${tensorflow_source_dir}/tensorflow/core/common_runtime/direct_session.h"
"${tensorflow_source_dir}/tensorflow/core/debug/*.h"
"${tensorflow_source_dir}/tensorflow/core/debug/*.cc"
)
file(GLOB_RECURSE tf_core_direct_session_test_srcs
"${tensorflow_source_dir}/tensorflow/core/debug/*test*.h"
"${tensorflow_source_dir}/tensorflow/core/debug/*test*.cc"
)
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)

View File

@ -150,6 +150,7 @@ list(REMOVE_ITEM tf_core_lib_srcs ${tf_core_lib_test_srcs})
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}
@ -168,6 +169,7 @@ target_compile_features(tf_core_lib PRIVATE
)
add_dependencies(tf_core_lib
gif_copy_headers_to_destination
jpeg_copy_headers_to_destination
png_copy_headers_to_destination
re2_copy_headers_to_destination

View File

@ -22,6 +22,7 @@ target_link_libraries(${proto_text} PUBLIC
${PROTOBUF_LIBRARIES}
# tf_protos_cc
# re2_lib
${gif_STATIC_LIBRARIES}
${jpeg_STATIC_LIBRARIES}
${png_STATIC_LIBRARIES}
${ZLIB_LIBRARIES}

View File

@ -23,6 +23,7 @@ add_executable(tf_tutorials_example_trainer
$<TARGET_OBJECTS:tf_core_cpu>
$<TARGET_OBJECTS:tf_core_framework>
$<TARGET_OBJECTS:tf_core_kernels>
$<TARGET_OBJECTS:tf_cc_framework>
$<TARGET_OBJECTS:tf_cc_ops>
$<TARGET_OBJECTS:tf_core_ops>
$<TARGET_OBJECTS:tf_core_direct_session>
@ -40,6 +41,7 @@ target_link_libraries(tf_tutorials_example_trainer PUBLIC
re2_lib
${boringssl_STATIC_LIBRARIES}
${farmhash_STATIC_LIBRARIES}
${gif_STATIC_LIBRARIES}
${jpeg_STATIC_LIBRARIES}
${jsoncpp_STATIC_LIBRARIES}
${png_STATIC_LIBRARIES}

View File

@ -47,6 +47,7 @@ class CopyOp : public OpKernel {
Tensor* copied_tensor;
OP_REQUIRES_OK(context, context->allocate_output(0, src_tensor.shape(),
&copied_tensor));
#if GOOGLE_CUDA
if (off_host_input) {
// Input is not on host: deep-copy it from GPU to the same GPU.
Notification done_copy;
@ -58,6 +59,9 @@ class CopyOp : public OpKernel {
// The input tensor is on the host (CPU): deep-copy from CPU to CPU.
*copied_tensor = tensor::DeepCopy(src_tensor);
}
#else
*copied_tensor = tensor::DeepCopy(src_tensor);
#endif // GOOGLE_CUDA
}
bool IsExpensive() override { return false; }