diff --git a/tensorflow/BUILD b/tensorflow/BUILD index c2a5de963b1..2b151a76f14 100644 --- a/tensorflow/BUILD +++ b/tensorflow/BUILD @@ -44,6 +44,12 @@ config_setting( visibility = ["//visibility:public"], ) +config_setting( + name = "windows", + values = {"cpu": "x64_windows_msvc"}, + visibility = ["//visibility:public"], +) + config_setting( name = "ios", values = { diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index 2c936bd5747..f32cd0e6fc8 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -64,6 +64,7 @@ load( "//tensorflow:tensorflow.bzl", "if_android", "if_ios", + "if_not_windows", "tf_copts", "tf_cc_test", "tf_cc_tests", @@ -140,6 +141,7 @@ cc_library( "platform/protobuf.h", "platform/types.h", ] + glob(tf_additional_proto_hdrs()), + copts = tf_copts(), deps = [ ":protos_all_cc", "//tensorflow/core/platform/default/build_config:proto_parsing", @@ -293,8 +295,6 @@ tf_cuda_library( "util/example_proto_fast_parsing.h", "util/example_proto_helper.h", "util/guarded_philox_random.h", - "util/memmapped_file_system.h", - "util/memmapped_file_system_writer.h", "util/mirror_pad_mode.h", "util/padding.h", "util/port.h", @@ -311,7 +311,13 @@ tf_cuda_library( "util/use_cudnn.h", "util/util.h", "util/work_sharder.h", - ], + ] + select({ + "//tensorflow:windows": [], + "//conditions:default": [ + "util/memmapped_file_system.h", + "util/memmapped_file_system_writer.h", + ], + }), visibility = ["//visibility:public"], deps = [":framework_internal"], ) @@ -512,7 +518,6 @@ cc_library( "//tensorflow/core/kernels:control_flow_ops", "//tensorflow/core/kernels:ctc_ops", "//tensorflow/core/kernels:data_flow", - "//tensorflow/core/kernels:fact_op", "//tensorflow/core/kernels:function_ops", "//tensorflow/core/kernels:image", "//tensorflow/core/kernels:io", @@ -531,7 +536,11 @@ cc_library( "//tensorflow/core/kernels:string", "//tensorflow/core/kernels:training_ops", "//tensorflow/models/embedding:word2vec_kernels", - ], + ] + if_not_windows([ + "//tensorflow/core/kernels:fact_op", + "//tensorflow/core/kernels:array_not_windows", + "//tensorflow/core/kernels:math_not_windows", + ]), ) tf_cuda_library( @@ -871,12 +880,12 @@ cc_library( # Libraries with GPU facilities that are useful for writing kernels. cc_library( name = "gpu_lib", - srcs = [ + srcs = if_not_windows([ "common_runtime/gpu/gpu_event_mgr.cc", - ], - hdrs = [ + ]), + hdrs = if_not_windows([ "common_runtime/gpu/gpu_event_mgr.h", - ], + ]), copts = tf_copts(), visibility = ["//visibility:public"], deps = [ @@ -886,8 +895,7 @@ cc_library( ":lib_internal", ":proto_text", ":protos_all_cc", - ":stream_executor", - ], + ] + if_not_windows([":stream_executor"]), ) cc_library( @@ -947,26 +955,47 @@ tf_proto_library_cc( cc_library( name = "lib_internal", - srcs = glob( - [ - "lib/**/*.h", - "lib/**/*.cc", - "platform/*.h", - "platform/*.cc", - "platform/profile_utils/**/*.h", - "platform/profile_utils/**/*.cc", - ] + tf_additional_lib_srcs(), - exclude = + srcs = select({ + "//tensorflow:windows": glob( [ + "lib/**/*.h", + "lib/**/*.cc", + "platform/*.h", + "platform/*.cc", + ], + exclude = [ "**/*test*", "platform/**/cuda.h", "platform/**/stream_executor.h", - ] + - # Protobuf deps already included through the ":lib_proto_parsing" - # dependency. - tf_additional_proto_srcs(), + "platform/load_library.cc", + ], + ), + "//conditions:default": glob( + [ + "lib/**/*.h", + "lib/**/*.cc", + "platform/*.h", + "platform/*.cc", + "platform/profile_utils/**/*.h", + "platform/profile_utils/**/*.cc", + ], + exclude = [ + "**/*test*", + "platform/**/cuda.h", + "platform/**/stream_executor.h", + ], + ), + }) + tf_additional_lib_srcs( + exclude = [ + "**/*test*", + "platform/**/cuda.h", + "platform/**/stream_executor.h", + ] + + # Protobuf deps already included through the ":lib_proto_parsing" + # dependency. + tf_additional_proto_srcs(), ), - hdrs = glob(tf_additional_lib_hdrs()) + [ + hdrs = tf_additional_lib_hdrs() + [ "lib/core/blocking_counter.h", "lib/core/refcount.h", "lib/gif/gif_io.h", @@ -1037,6 +1066,7 @@ tf_version_info_genrule() cc_library( name = "version_lib", srcs = ["util/version_info.cc"], + copts = tf_copts(), ) tf_cuda_library( @@ -1058,8 +1088,18 @@ tf_cuda_library( "util/reporter.h", "util/reporter.cc", "framework/fake_input.*", + "util/memmapped_file_system.*", + "util/memmapped_file_system_writer.*", ], - ), + ) + select({ + "//tensorflow:windows": [], + "//conditions:default": [ + "util/memmapped_file_system.h", + "util/memmapped_file_system.cc", + "util/memmapped_file_system_writer.h", + "util/memmapped_file_system_writer.cc", + ], + }), hdrs = [ "framework/op_segment.h", "framework/rendezvous.h", # only needed for tests @@ -1333,7 +1373,7 @@ tf_cuda_library( tf_cuda_library( name = "gpu_runtime", - srcs = [ + srcs = if_not_windows([ "common_runtime/gpu/gpu_bfc_allocator.cc", "common_runtime/gpu/gpu_debug_allocator.cc", "common_runtime/gpu/gpu_device.cc", @@ -1345,8 +1385,8 @@ tf_cuda_library( "common_runtime/gpu/pool_allocator.cc", "common_runtime/gpu/process_state.cc", "common_runtime/gpu_device_context.h", - ], - hdrs = [ + ]), + hdrs = if_not_windows([ "common_runtime/gpu/gpu_bfc_allocator.h", "common_runtime/gpu/gpu_debug_allocator.h", "common_runtime/gpu/gpu_device.h", @@ -1355,7 +1395,7 @@ tf_cuda_library( "common_runtime/gpu/gpu_util.h", "common_runtime/gpu/pool_allocator.h", "common_runtime/gpu/process_state.h", - ], + ]), copts = tf_copts(), linkstatic = 1, deps = [ @@ -1367,9 +1407,10 @@ tf_cuda_library( ":lib", ":lib_internal", ":protos_all_cc", - ":stream_executor", "//third_party/eigen3", - ], + ] + if_not_windows([ + ":stream_executor", + ]), alwayslink = 1, ) diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD index 36b4def0ef6..e5295e41eba 100644 --- a/tensorflow/core/kernels/BUILD +++ b/tensorflow/core/kernels/BUILD @@ -25,6 +25,7 @@ package_group( load( "//tensorflow:tensorflow.bzl", + "if_not_windows", "tf_cc_test", "tf_cc_tests", "tf_copts", @@ -384,6 +385,41 @@ cc_header_only_library( # OpKernel libraries ---------------------------------------------------------- +ARRAY_DEPS = [ + ":batch_space_ops", + ":bounds_check", + ":concat_lib", + ":cuda_device_array", + ":depth_space_ops", + ":extract_image_patches_op", + ":fill_functor", + ":gather_functor", + ":ops_util", + ":split_lib", + ":strided_slice_op", + ":transpose_functor", + "//tensorflow/core:array_grad", + "//tensorflow/core:array_ops_op_lib", + "//tensorflow/core:core_cpu", + "//tensorflow/core:framework", + "//tensorflow/core:gpu_runtime", + "//tensorflow/core:lib", + "//tensorflow/core:lib_internal", + "//tensorflow/core:proto_text", + "//tensorflow/core:protos_all_cc", + "//tensorflow/core/debug:debug_io_utils", + "//third_party/eigen3", +] + +tf_kernel_libraries( + name = "array_not_windows", + prefixes = [ + "debug_ops", + "immutable_constant_op", + ], + deps = ARRAY_DEPS, +) + tf_kernel_libraries( name = "array", prefixes = [ @@ -391,7 +427,6 @@ tf_kernel_libraries( "bitcast_op", "concat_op", "constant_op", - "debug_ops", "diag_op", "matrix_band_part_op", "matrix_diag_op", @@ -400,7 +435,6 @@ tf_kernel_libraries( "gather_op", "gather_nd_op", "identity_op", - "immutable_constant_op", "listdiff_op", "mirror_pad_op", "one_hot_op", @@ -419,31 +453,7 @@ tf_kernel_libraries( "unpack_op", "where_op", ], - deps = [ - ":batch_space_ops", - ":bounds_check", - ":concat_lib", - ":cuda_device_array", - ":depth_space_ops", - ":extract_image_patches_op", - ":fill_functor", - ":gather_functor", - ":ops_util", - ":split_lib", - ":strided_slice_op", - ":transpose_functor", - "//tensorflow/core:array_grad", - "//tensorflow/core:array_ops_op_lib", - "//tensorflow/core:core_cpu", - "//tensorflow/core:framework", - "//tensorflow/core:gpu_runtime", - "//tensorflow/core:lib", - "//tensorflow/core:lib_internal", - "//tensorflow/core:proto_text", - "//tensorflow/core:protos_all_cc", - "//tensorflow/core/debug:debug_io_utils", - "//third_party/eigen3", - ], + deps = ARRAY_DEPS, ) tf_cc_test( @@ -1262,6 +1272,27 @@ tf_cc_tests( ], ) +MATH_DEPS = [ + ":bounds_check", + ":fill_functor", + ":transpose_functor", + "//tensorflow/core:core_cpu", + "//tensorflow/core:framework", + "//tensorflow/core:lib", + "//tensorflow/core:lib_internal", + "//tensorflow/core:math_grad", + "//tensorflow/core:math_ops_op_lib", + "//third_party/eigen3", +] + +tf_kernel_libraries( + name = "math_not_windows", + prefixes = [ + "sparse_matmul_op", + ], + deps = MATH_DEPS, +) + tf_kernel_libraries( name = "math", prefixes = [ @@ -1279,20 +1310,8 @@ tf_kernel_libraries( "segment_reduction_ops", "scan_ops", "sequence_ops", - "sparse_matmul_op", - ], - deps = [ - ":bounds_check", - ":fill_functor", - ":transpose_functor", - "//tensorflow/core:core_cpu", - "//tensorflow/core:framework", - "//tensorflow/core:lib", - "//tensorflow/core:lib_internal", - "//tensorflow/core:math_grad", - "//tensorflow/core:math_ops_op_lib", - "//third_party/eigen3", ], + deps = MATH_DEPS, ) tf_cuda_cc_test( @@ -1572,7 +1591,6 @@ tf_kernel_libraries( ":conv_2d", ":conv_ops", ":depthwise_conv_grad_op", - ":depthwise_conv_op", ":dilation_ops", ":fused_batch_norm_util_gpu", ":ops_util", @@ -1583,7 +1601,9 @@ tf_kernel_libraries( "//tensorflow/core:nn_grad", "//tensorflow/core:nn_ops_op_lib", "//third_party/eigen3", - ], + ] + if_not_windows([ + ":depthwise_conv_op", + ]), ) tf_cuda_cc_test( diff --git a/tensorflow/core/platform/default/build_config.bzl b/tensorflow/core/platform/default/build_config.bzl index 23404cd4240..17e68a134cc 100644 --- a/tensorflow/core/platform/default/build_config.bzl +++ b/tensorflow/core/platform/default/build_config.bzl @@ -90,17 +90,31 @@ def tf_proto_library(name, srcs = [], has_services = None, visibility = visibility, ) -def tf_additional_lib_hdrs(): - return [ - "platform/default/*.h", - "platform/posix/*.h", - ] +def tf_additional_lib_hdrs(exclude = []): + return select({ + "//tensorflow:windows" : native.glob([ + "platform/default/*.h", + "platform/windows/*.h", + "platform/posix/error.h", + ], exclude = exclude), + "//conditions:default" : native.glob([ + "platform/default/*.h", + "platform/posix/*.h", + ], exclude = exclude), + }) -def tf_additional_lib_srcs(): - return [ - "platform/default/*.cc", - "platform/posix/*.cc", - ] +def tf_additional_lib_srcs(exclude = []): + return select({ + "//tensorflow:windows" : native.glob([ + "platform/default/*.cc", + "platform/windows/*.cc", + "platform/posix/error.cc", + ], exclude = exclude), + "//conditions:default" : native.glob([ + "platform/default/*.cc", + "platform/posix/*.cc", + ], exclude = exclude), + }) def tf_additional_minimal_lib_srcs(): return [ diff --git a/tensorflow/core/platform/windows/env.cc b/tensorflow/core/platform/windows/env.cc index a2182a831cb..09edc10a94b 100644 --- a/tensorflow/core/platform/windows/env.cc +++ b/tensorflow/core/platform/windows/env.cc @@ -32,6 +32,8 @@ limitations under the License. #include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/windows/windows_file_system.h" +#pragma comment(lib, "Shlwapi.lib") + namespace tensorflow { namespace { diff --git a/tensorflow/core/platform/windows/port.cc b/tensorflow/core/platform/windows/port.cc index b08c1cf9f4e..0721976f3e0 100644 --- a/tensorflow/core/platform/windows/port.cc +++ b/tensorflow/core/platform/windows/port.cc @@ -20,6 +20,7 @@ limitations under the License. #include <snappy.h> #endif #include <WinSock2.h> +#pragma comment(lib, "Ws2_32.lib") #include "tensorflow/core/platform/cpu_info.h" #include "tensorflow/core/platform/demangle.h" diff --git a/tensorflow/core/util/tensor_bundle/BUILD b/tensorflow/core/util/tensor_bundle/BUILD index 6b2c37fe392..d6db84277f7 100644 --- a/tensorflow/core/util/tensor_bundle/BUILD +++ b/tensorflow/core/util/tensor_bundle/BUILD @@ -9,6 +9,8 @@ licenses(["notice"]) # Apache 2.0 exports_files(["LICENSE"]) +load("//tensorflow:tensorflow.bzl", "tf_copts") + # To be exported to tensorflow/core:android_srcs. filegroup( name = "android_srcs", @@ -24,6 +26,7 @@ cc_library( name = "tensor_bundle", srcs = ["tensor_bundle.cc"], hdrs = ["tensor_bundle.h"], + copts = tf_copts(), deps = [ ":naming", "//tensorflow/core:core_cpu_internal", diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index 1abac91e1a4..6d60d50acdf 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -140,6 +140,12 @@ def if_not_mobile(a): "//conditions:default": a, }) +def if_not_windows(a): + return select({ + "//tensorflow:windows": [], + "//conditions:default": a, + }) + def tf_copts(): return (["-fno-exceptions", "-DEIGEN_AVOID_STL_ARRAY"] + if_cuda(["-DGOOGLE_CUDA=1"]) + @@ -151,6 +157,10 @@ def tf_copts(): "-O2", ], "//tensorflow:darwin": [], + "//tensorflow:windows": [ + "/DLANG_CXX11", + "/D__VERSION__=\\\"MSVC\\\"", + ], "//tensorflow:ios": ["-std=c++11",], "//conditions:default": ["-pthread"]})) diff --git a/tensorflow/tools/proto_text/BUILD b/tensorflow/tools/proto_text/BUILD index af80d3a4412..d439c9abfdc 100644 --- a/tensorflow/tools/proto_text/BUILD +++ b/tensorflow/tools/proto_text/BUILD @@ -42,12 +42,17 @@ cc_library( name = "gen_proto_text_functions_lib", srcs = ["gen_proto_text_functions_lib.cc"], hdrs = ["gen_proto_text_functions_lib.h"], - linkopts = [ - "-lm", - "-lpthread", - ] + select({ - "//tensorflow:darwin": [], - "//conditions:default": ["-lrt"], + linkopts = select({ + "//tensorflow:windows": [], + "//tensorflow:darwin": [ + "-lm", + "-lpthread", + ], + "//conditions:default": [ + "-lm", + "-lpthread", + "-lrt", + ], }), deps = [ "//tensorflow/core:lib_proto_parsing", diff --git a/third_party/gpus/cuda/platform.bzl.tpl b/third_party/gpus/cuda/platform.bzl.tpl index 7565dfc1294..539ed58d2c7 100644 --- a/third_party/gpus/cuda/platform.bzl.tpl +++ b/third_party/gpus/cuda/platform.bzl.tpl @@ -14,6 +14,11 @@ def cuda_library_path(name, version = cuda_sdk_version()): return "lib/lib{}.dylib".format(name) else: return "lib/lib{}.{}.dylib".format(name, version) + elif PLATFORM == "Windows": + if not version: + return "lib/{}.dll".format(name) + else: + return "lib/{}{}.dll".format(name, version) else: if not version: return "lib64/lib{}.so".format(name) @@ -23,6 +28,8 @@ def cuda_library_path(name, version = cuda_sdk_version()): def cuda_static_library_path(name): if PLATFORM == "Darwin": return "lib/lib{}_static.a".format(name) + elif PLATFORM == "Windows": + return "lib/{}_static.lib".format(name) else: return "lib64/lib{}_static.a".format(name) @@ -32,6 +39,11 @@ def cudnn_library_path(version = cudnn_sdk_version()): return "lib/libcudnn.dylib" else: return "lib/libcudnn.{}.dylib".format(version) + elif PLATFORM == "Windows": + if not version: + return "lib/cudnn.dll" + else: + return "lib/cudnn{}.dll".format(version) else: if not version: return "lib64/libcudnn.so" @@ -44,6 +56,11 @@ def cupti_library_path(version = cuda_sdk_version()): return "extras/CUPTI/lib/libcupti.dylib" else: return "extras/CUPTI/lib/libcupti.{}.dylib".format(version) + elif PLATFORM == "Windows": + if not version: + return "extras/CUPTI/lib/cupti.dll" + else: + return "extras/CUPTI/lib/cupti{}.dll".format(version) else: if not version: return "extras/CUPTI/lib64/libcupti.so"