From 786d2e112e528499a13a70faca2b540be0caa8c9 Mon Sep 17 00:00:00 2001 From: Brian Zhao <bmzhao@google.com> Date: Wed, 6 Nov 2019 12:52:10 -0800 Subject: [PATCH] Adding remaining non-test targets to tensorflow/core/lib/io, and wiring them into tensorflow/core/BUILD. PiperOrigin-RevId: 278921246 Change-Id: Iabf33f28f670e2d8554c176fa61d960665b36f7c --- tensorflow/core/BUILD | 23 +- tensorflow/core/lib/io/BUILD | 243 ++++++++++++++++++--- tensorflow/core/lib/io/zlib_inputstream.cc | 6 +- 3 files changed, 238 insertions(+), 34 deletions(-) diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index f1bda9b425f..09c6b169af4 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -2216,7 +2216,6 @@ cc_library( "//tensorflow/core/platform:legacy_monitoring_srcs", "//tensorflow/core/platform:legacy_platform_lib_srcs", "//tensorflow/core/platform:legacy_lib_internal_srcs", - "//tensorflow/core/lib/io:legacy_lib_internal_impl_srcs", ], hdrs = LIB_INTERNAL_PUBLIC_HEADERS, copts = tf_copts(), @@ -2258,12 +2257,24 @@ cc_library( "//tensorflow/core/lib/gtl:top_n", "//tensorflow/core/lib/hash:crc32c", "//tensorflow/core/lib/hash:hash", + "//tensorflow/core/lib/io:block", + "//tensorflow/core/lib/io:buffered_inputstream", "//tensorflow/core/lib/io:compression", + "//tensorflow/core/lib/io:inputbuffer", "//tensorflow/core/lib/io:inputstream_interface", "//tensorflow/core/lib/io:iterator", "//tensorflow/core/lib/io:path", "//tensorflow/core/lib/io:proto_encode_helper", + "//tensorflow/core/lib/io:random_inputstream", + "//tensorflow/core/lib/io:record_reader", + "//tensorflow/core/lib/io:record_writer", + "//tensorflow/core/lib/io:snappy_inputbuffer", + "//tensorflow/core/lib/io:snappy_outputbuffer", + "//tensorflow/core/lib/io:table", "//tensorflow/core/lib/io:table_options", + "//tensorflow/core/lib/io:zlib_compression_options", + "//tensorflow/core/lib/io:zlib_inputstream", + "//tensorflow/core/lib/io:zlib_outputbuffer", "//tensorflow/core/lib/math:math_util", "//tensorflow/core/lib/random:exact_uniform_int", "//tensorflow/core/lib/random:philox", @@ -2323,6 +2334,16 @@ cc_library( "@double_conversion//:double-conversion", "@com_google_protobuf//:protobuf", ] + tf_protos_all_impl() + tf_protos_grappler_impl(), + # Alwayslink causes a cc_binary to "always link" in the + # srcs for a given cc_library, even if they are unreferenced, see: + # https://docs.bazel.build/versions/master/be/c-cpp.html#cc_library.alwayslink + # tensorflow/core:lib_internal_impl has alwayslink set so that libtensorflow_framework.so + # contains all of the srcs within lib_internal_impl. + # NOTE(bmzhao): As we refactor tensorflow's BUILD files to more granular targets, + # we've removed srcs from core:lib_internal_impl, and have added deps on these + # granular targets instead. Since alwayslink doesn't apply to these deps, + # we will sometimes need to add alwayslink to the granular libraries instead. + # Ideally, this will be resolved once bazel has full cc_shared_library support. alwayslink = 1, ) diff --git a/tensorflow/core/lib/io/BUILD b/tensorflow/core/lib/io/BUILD index 0676757abc4..aa4f34d45c5 100644 --- a/tensorflow/core/lib/io/BUILD +++ b/tensorflow/core/lib/io/BUILD @@ -10,19 +10,71 @@ package( licenses = ["notice"], # Apache 2.0 ) -# TODO(bmzhao): Remaining targets to add to this BUILD file are: -# block, block_builder, buffered_inputstream, format, inputbuffer, -# random_inputstream, record_reader, record_writer, snappy/snappy_inputbuffer -# snappy/snappy_outputbuffer, table, table_builder, two_level_iterator, -# zlib_inputstream, zlib_outputbuffer, zlib_compression_options, and all tests. +# TODO(bmzhao): Remaining targets to add to this BUILD file are: all tests. -# Note(bmzhao): After tensorflow/core/platform:env is fully integrated into -# tensorflow/core/BUILD, we can finish adding the rest of the targets in this package. +cc_library( + name = "block", + srcs = [ + "block.cc", + "block_builder.cc", + "format.cc", + "table_builder.cc", + ], + hdrs = [ + "block.h", + "block_builder.h", + "format.h", + "table_builder.h", + ], + deps = [ + ":iterator", + ":table_options", + "//tensorflow/core/lib/core:coding", + "//tensorflow/core/lib/core:errors", + "//tensorflow/core/lib/core:status", + "//tensorflow/core/lib/core:stringpiece", + "//tensorflow/core/lib/hash:crc32c", + "//tensorflow/core/platform:env", + "//tensorflow/core/platform:logging", + "//tensorflow/core/platform:platform_port", + "//tensorflow/core/platform:types", + ], + alwayslink = True, +) + +cc_library( + name = "buffered_inputstream", + srcs = ["buffered_inputstream.cc"], + hdrs = ["buffered_inputstream.h"], + deps = [ + ":inputstream_interface", + ":random_inputstream", + "//tensorflow/core/platform:env", + ], + alwayslink = True, +) cc_library( name = "compression", srcs = ["compression.cc"], hdrs = ["compression.h"], + alwayslink = True, +) + +cc_library( + name = "inputbuffer", + srcs = ["inputbuffer.cc"], + hdrs = ["inputbuffer.h"], + deps = [ + "//tensorflow/core/lib/core:coding", + "//tensorflow/core/lib/core:errors", + "//tensorflow/core/lib/core:status", + "//tensorflow/core/platform:env", + "//tensorflow/core/platform:logging", + "//tensorflow/core/platform:macros", + "//tensorflow/core/platform:types", + ], + alwayslink = True, ) cc_library( @@ -35,6 +87,7 @@ cc_library( "//tensorflow/core/platform:cord", "//tensorflow/core/platform:types", ], + alwayslink = True, ) cc_library( @@ -45,6 +98,7 @@ cc_library( "//tensorflow/core/lib/core:status", "//tensorflow/core/platform:stringpiece", ], + alwayslink = True, ) cc_library( @@ -59,6 +113,7 @@ cc_library( "//tensorflow/core/platform:stringpiece", "//tensorflow/core/platform:types", ], + alwayslink = True, ) cc_library( @@ -71,11 +126,162 @@ cc_library( ], ) +cc_library( + name = "random_inputstream", + srcs = ["random_inputstream.cc"], + hdrs = ["random_inputstream.h"], + deps = [ + ":inputstream_interface", + "//tensorflow/core/platform:cord", + "//tensorflow/core/platform:env", + ], + alwayslink = True, +) + +cc_library( + name = "record_reader", + srcs = ["record_reader.cc"], + hdrs = ["record_reader.h"], + deps = [ + ":buffered_inputstream", + ":compression", + ":inputstream_interface", + ":random_inputstream", + ":zlib_compression_options", + ":zlib_inputstream", + "//tensorflow/core/lib/core:coding", + "//tensorflow/core/lib/core:errors", + "//tensorflow/core/lib/core:stringpiece", + "//tensorflow/core/lib/hash:crc32c", + "//tensorflow/core/platform:env", + "//tensorflow/core/platform:macros", + "//tensorflow/core/platform:types", + ], + alwayslink = True, +) + +cc_library( + name = "record_writer", + srcs = ["record_writer.cc"], + hdrs = ["record_writer.h"], + deps = [ + ":compression", + ":zlib_compression_options", + ":zlib_outputbuffer", + "//tensorflow/core/lib/core:coding", + "//tensorflow/core/lib/core:status", + "//tensorflow/core/lib/core:stringpiece", + "//tensorflow/core/lib/hash:crc32c", + "//tensorflow/core/platform:cord", + "//tensorflow/core/platform:env", + "//tensorflow/core/platform:macros", + "//tensorflow/core/platform:types", + ], + alwayslink = True, +) + +cc_library( + name = "snappy_inputbuffer", + srcs = ["snappy/snappy_inputbuffer.cc"], + hdrs = ["snappy/snappy_inputbuffer.h"], + deps = [ + ":inputstream_interface", + "//tensorflow/core/lib/core:status", + "//tensorflow/core/platform:env", + "//tensorflow/core/platform:macros", + "//tensorflow/core/platform:platform_port", + "//tensorflow/core/platform:types", + ], + alwayslink = True, +) + +cc_library( + name = "snappy_outputbuffer", + srcs = ["snappy/snappy_outputbuffer.cc"], + hdrs = ["snappy/snappy_outputbuffer.h"], + deps = [ + "//tensorflow/core/lib/core:status", + "//tensorflow/core/platform", + "//tensorflow/core/platform:env", + "//tensorflow/core/platform:macros", + "//tensorflow/core/platform:platform_port", + "//tensorflow/core/platform:types", + ], + alwayslink = True, +) + +cc_library( + name = "table", + srcs = [ + "table.cc", + "two_level_iterator.cc", + ], + hdrs = [ + "table.h", + "two_level_iterator.h", + ], + deps = [ + ":block", + ":iterator", + ":table_options", + "//tensorflow/core/lib/core:coding", + "//tensorflow/core/lib/core:errors", + "//tensorflow/core/platform:env", + ], + alwayslink = True, +) + cc_library( name = "table_options", hdrs = ["table_options.h"], ) +cc_library( + name = "zlib_compression_options", + srcs = ["zlib_compression_options.cc"], + hdrs = ["zlib_compression_options.h"], + deps = [ + "//tensorflow/core/platform:types", + "@zlib_archive//:zlib", + ], + alwayslink = True, +) + +cc_library( + name = "zlib_inputstream", + srcs = ["zlib_inputstream.cc"], + hdrs = ["zlib_inputstream.h"], + deps = [ + ":inputstream_interface", + ":zlib_compression_options", + "//tensorflow/core/lib/core:status", + "//tensorflow/core/platform:env", + "//tensorflow/core/platform:logging", + "//tensorflow/core/platform:macros", + "//tensorflow/core/platform:strcat", + "//tensorflow/core/platform:types", + "@zlib_archive//:zlib", + ], + alwayslink = True, +) + +cc_library( + name = "zlib_outputbuffer", + srcs = ["zlib_outputbuffer.cc"], + hdrs = ["zlib_outputbuffer.h"], + deps = [ + ":zlib_compression_options", + "//tensorflow/core/lib/core:errors", + "//tensorflow/core/lib/core:status", + "//tensorflow/core/lib/core:stringpiece", + "//tensorflow/core/platform:env", + "//tensorflow/core/platform:macros", + "//tensorflow/core/platform:types", + "@zlib_archive//:zlib", + ], + alwayslink = True, +) + filegroup( name = "legacy_lib_io_all_headers", srcs = [ @@ -132,29 +338,6 @@ filegroup( visibility = ["//tensorflow/core:__pkg__"], ) -filegroup( - name = "legacy_lib_internal_impl_srcs", - srcs = [ - "block.cc", - "block_builder.cc", - "buffered_inputstream.cc", - "format.cc", - "inputbuffer.cc", - "random_inputstream.cc", - "record_reader.cc", - "record_writer.cc", - "snappy/snappy_inputbuffer.cc", - "snappy/snappy_outputbuffer.cc", - "table.cc", - "table_builder.cc", - "two_level_iterator.cc", - "zlib_compression_options.cc", - "zlib_inputstream.cc", - "zlib_outputbuffer.cc", - ], - visibility = ["//tensorflow/core:__pkg__"], -) - filegroup( name = "legacy_lib_io_all_tests", srcs = [ diff --git a/tensorflow/core/lib/io/zlib_inputstream.cc b/tensorflow/core/lib/io/zlib_inputstream.cc index 39404dfac39..7ea8508c569 100644 --- a/tensorflow/core/lib/io/zlib_inputstream.cc +++ b/tensorflow/core/lib/io/zlib_inputstream.cc @@ -13,12 +13,12 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -#include <zlib.h> - #include "tensorflow/core/lib/io/zlib_inputstream.h" -#include "tensorflow/core/lib/strings/strcat.h" +#include <zlib.h> + #include "tensorflow/core/platform/logging.h" +#include "tensorflow/core/platform/strcat.h" namespace tensorflow { namespace io {