Adding BUILD file into tensorflow/core/example, as part of the build refactoring described in https://github.com/tensorflow/community/pull/179.

PiperOrigin-RevId: 291839268
Change-Id: I4ace5769ae4a41753c56114bbb9d841a0035d9e8
This commit is contained in:
Brian Zhao 2020-01-27 17:49:10 -08:00 committed by TensorFlower Gardener
parent 8890e3f7b5
commit 36404c2135
4 changed files with 191 additions and 95 deletions

View File

@ -140,7 +140,6 @@ load(
) )
load("@local_config_cuda//cuda:build_defs.bzl", "if_cuda") load("@local_config_cuda//cuda:build_defs.bzl", "if_cuda")
load("@local_config_tensorrt//:build_defs.bzl", "if_tensorrt") load("@local_config_tensorrt//:build_defs.bzl", "if_tensorrt")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_proto_library")
load( load(
"//third_party/mkl:build_defs.bzl", "//third_party/mkl:build_defs.bzl",
"if_mkl", "if_mkl",
@ -183,8 +182,6 @@ package_group(name = "experimental_access")
# filegroup; e.g. ones with individual proto_library targets. # filegroup; e.g. ones with individual proto_library targets.
# LINT.IfChange # LINT.IfChange
COMMON_PROTO_SRCS = [ COMMON_PROTO_SRCS = [
"example/example.proto",
"example/feature.proto",
"protobuf/bfc_memory_map.proto", "protobuf/bfc_memory_map.proto",
"protobuf/config.proto", "protobuf/config.proto",
"protobuf/cluster.proto", "protobuf/cluster.proto",
@ -199,6 +196,11 @@ COMMON_PROTO_SRCS = [
"protobuf/trace_events.proto", "protobuf/trace_events.proto",
] ]
EXAMPLE_PROTO_SRCS = [
"//tensorflow/core/example:example.proto",
"//tensorflow/core/example:feature.proto",
]
UTIL_PROTO_SRCS = [ UTIL_PROTO_SRCS = [
"//tensorflow/core/util:event.proto", "//tensorflow/core/util:event.proto",
"//tensorflow/core/util:memmapped_file_system.proto", "//tensorflow/core/util:memmapped_file_system.proto",
@ -242,7 +244,7 @@ ERROR_CODES_PROTO_SRCS = [
] ]
# LINT.ThenChange(//tensorflow/core/android_proto_config.asciipb) # LINT.ThenChange(//tensorflow/core/android_proto_config.asciipb)
CORE_PROTO_SRCS = COMMON_PROTO_SRCS + FRAMEWORK_PROTO_SRCS + UTIL_PROTO_SRCS + PROFILER_PROTO_SRCS + ERROR_CODES_PROTO_SRCS CORE_PROTO_SRCS = COMMON_PROTO_SRCS + EXAMPLE_PROTO_SRCS + FRAMEWORK_PROTO_SRCS + UTIL_PROTO_SRCS + PROFILER_PROTO_SRCS + ERROR_CODES_PROTO_SRCS
tf_proto_library( tf_proto_library(
name = "protos_all", name = "protos_all",
@ -252,6 +254,7 @@ tf_proto_library(
protodeps = [ protodeps = [
":core_protos", ":core_protos",
":error_codes_proto_impl", ":error_codes_proto_impl",
"//tensorflow/core/example:protos_all",
"//tensorflow/core/framework:protos_all", "//tensorflow/core/framework:protos_all",
"//tensorflow/core/lib/core:error_codes_proto", "//tensorflow/core/lib/core:error_codes_proto",
"//tensorflow/core/util:protos_all", "//tensorflow/core/util:protos_all",
@ -266,12 +269,9 @@ tf_jspb_proto_library(
deps = [":protos_all"], deps = [":protos_all"],
) )
proto_library( alias(
name = "example_protos", name = "example_protos",
srcs = [ actual = "//tensorflow/core/example:example_protos",
"example/example.proto",
"example/feature.proto",
],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
@ -281,12 +281,6 @@ java_proto_library(
deps = [":example_protos"], deps = [":example_protos"],
) )
closure_proto_library(
name = "example_protos_closure",
visibility = ["//visibility:public"],
deps = [":example_protos"],
)
cc_library( cc_library(
name = "platform_base", name = "platform_base",
hdrs = ["//tensorflow/core/platform:base_hdrs"], hdrs = ["//tensorflow/core/platform:base_hdrs"],
@ -397,17 +391,10 @@ cc_library(
], ],
) )
cc_library( alias(
name = "feature_util", name = "feature_util",
srcs = ["example/feature_util.cc"], actual = "//tensorflow/core/example:feature_util",
hdrs = ["example/feature_util.h"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [
":core_stringpiece",
":lib_proto_parsing",
":protos_all_cc",
],
alwayslink = 1,
) )
# DEPRECATED: use platform:stringpiece instead. # DEPRECATED: use platform:stringpiece instead.
@ -460,7 +447,7 @@ cc_library(
tf_cuda_library( tf_cuda_library(
name = "framework", name = "framework",
hdrs = [ hdrs = [
"example/feature_util.h", "//tensorflow/core/example:feature_util.h",
"//tensorflow/core/framework:allocator.h", "//tensorflow/core/framework:allocator.h",
"//tensorflow/core/framework:allocator_registry.h", "//tensorflow/core/framework:allocator_registry.h",
"//tensorflow/core/framework:attr_value_util.h", "//tensorflow/core/framework:attr_value_util.h",
@ -1277,6 +1264,7 @@ filegroup(
name = "mobile_srcs_no_runtime", name = "mobile_srcs_no_runtime",
srcs = [ srcs = [
"//tensorflow/compiler/jit:mobile_srcs_no_runtime", "//tensorflow/compiler/jit:mobile_srcs_no_runtime",
"//tensorflow/core/example:mobile_srcs_no_runtime",
"//tensorflow/core/framework:attr_value_proto_text_srcs", "//tensorflow/core/framework:attr_value_proto_text_srcs",
"//tensorflow/core/framework:mobile_srcs_no_runtime", "//tensorflow/core/framework:mobile_srcs_no_runtime",
"//tensorflow/core/lib/bfloat16:mobile_srcs_no_runtime", "//tensorflow/core/lib/bfloat16:mobile_srcs_no_runtime",
@ -1617,20 +1605,13 @@ cc_library(
[ [
alias( alias(
name = "example_%s_pyclif%s" % (proto_name, target_suffix), name = "example_%s_pyclif%s" % (proto_name, target_suffix),
actual = ":example/%s_pyclif%s" % (proto_name, target_suffix), actual = "//tensorflow/core/example:%s_pyclif%s" % (proto_name, target_suffix),
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
for target_suffix in [ for target_suffix in [
"", "",
"_pb2", "_pb2",
] ]
] + [
tf_pyclif_proto_library(
name = "example/%s_pyclif" % proto_name,
proto_lib = ":protos_all",
proto_srcfile = "example/%s.proto" % proto_name,
visibility = ["//visibility:public"],
),
] ]
for proto_name in [ for proto_name in [
"example", "example",
@ -2127,7 +2108,6 @@ tf_proto_library(
# #
# Note that some protos are in neither core_proto_srcs nor this # Note that some protos are in neither core_proto_srcs nor this
# filegroup; e.g. ones with individual proto_library targets. # filegroup; e.g. ones with individual proto_library targets.
"example/example_parser_configuration.proto",
"protobuf/control_flow.proto", "protobuf/control_flow.proto",
# TODO(ebrevdo): Re-enable once CriticalSection is in core. # TODO(ebrevdo): Re-enable once CriticalSection is in core.
# "protobuf/critical_section.proto", # "protobuf/critical_section.proto",
@ -2147,6 +2127,7 @@ tf_proto_library(
make_default_target_header_only = True, make_default_target_header_only = True,
protodeps = [ protodeps = [
":error_codes_proto_impl", ":error_codes_proto_impl",
"//tensorflow/core/example:protos_all",
"//tensorflow/core/framework:protos_all", "//tensorflow/core/framework:protos_all",
"//tensorflow/core/lib/core:error_codes_proto", "//tensorflow/core/lib/core:error_codes_proto",
"//tensorflow/core/profiler/protobuf:xplane_proto", "//tensorflow/core/profiler/protobuf:xplane_proto",
@ -2171,16 +2152,8 @@ FRAMEWORK_INTERNAL_PRIVATE_HEADERS = [
"//tensorflow/core/util/sparse:framework_internal_private_headers_group", "//tensorflow/core/util/sparse:framework_internal_private_headers_group",
"//tensorflow/core/framework:framework_internal_private_hdrs", "//tensorflow/core/framework:framework_internal_private_hdrs",
"//tensorflow/core/util:framework_internal_private_hdrs", "//tensorflow/core/util:framework_internal_private_hdrs",
] + glob( "//tensorflow/core/example:feature_util.h",
[ ] + select({
"example/**/*.h",
],
exclude = [
"**/*test*",
"**/*main.cc",
"example/example_parser_configuration.*",
],
) + select({
"//tensorflow:windows": [], "//tensorflow:windows": [],
"//conditions:default": [ "//conditions:default": [
"//tensorflow/core/util:memmapped_file_system_hdrs", "//tensorflow/core/util:memmapped_file_system_hdrs",
@ -2256,13 +2229,10 @@ tf_cuda_library(
"//tensorflow/core/util/sparse:framework_internal_impl_group", "//tensorflow/core/util/sparse:framework_internal_impl_group",
] + glob( ] + glob(
[ [
"example/**/*.cc",
], ],
exclude = [ exclude = [
"**/*test*", "**/*test*",
"**/*main.cc", "**/*main.cc",
"example/example_parser_configuration.*",
"example/feature_util.cc",
], ],
) + select({ ) + select({
"//tensorflow:windows": [], "//tensorflow:windows": [],
@ -2293,6 +2263,7 @@ tf_cuda_library(
"@com_google_absl//absl/strings", "@com_google_absl//absl/strings",
"@com_google_absl//absl/time", "@com_google_absl//absl/time",
"//third_party/eigen3", "//third_party/eigen3",
"//tensorflow/core/example:feature_util",
"//tensorflow/core/framework:allocator", "//tensorflow/core/framework:allocator",
"//tensorflow/core/framework:allocator_registry_impl", "//tensorflow/core/framework:allocator_registry_impl",
"//tensorflow/core/framework:attr_value_proto_text", "//tensorflow/core/framework:attr_value_proto_text",
@ -2743,22 +2714,10 @@ tf_cuda_library(
alwayslink = 1, alwayslink = 1,
) )
cc_library( alias(
name = "example_parser_configuration", name = "example_parser_configuration",
srcs = ["example/example_parser_configuration.cc"], actual = "//tensorflow/core/example:example_parser_configuration",
hdrs = ["example/example_parser_configuration.h"],
copts = tf_copts(),
linkstatic = 1,
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [
":core_cpu",
":core_cpu_internal",
":framework",
":lib",
":lib_internal",
":protos_all_cc",
],
alwayslink = 1,
) )
tf_proto_library_cc( tf_proto_library_cc(
@ -3181,7 +3140,7 @@ tf_cc_tests(
"common_runtime/placer_test.cc", "common_runtime/placer_test.cc",
"common_runtime/session_test.cc", "common_runtime/session_test.cc",
"common_runtime/threadpool_device_test.cc", "common_runtime/threadpool_device_test.cc",
"example/feature_util_test.cc", "//tensorflow/core/example:feature_util_test.cc",
"//tensorflow/core/graph:algorithm_test.cc", "//tensorflow/core/graph:algorithm_test.cc",
"//tensorflow/core/graph:control_flow_test.cc", "//tensorflow/core/graph:control_flow_test.cc",
"//tensorflow/core/graph:edgeset_test.cc", "//tensorflow/core/graph:edgeset_test.cc",
@ -4251,30 +4210,6 @@ tf_cc_test(
], ],
) )
tf_cc_test(
name = "example_example_parser_configuration_test",
size = "small",
srcs = ["example/example_parser_configuration_test.cc"],
data = [":example_parser_configuration_testdata"],
deps = [
":core_cpu",
":core_cpu_internal",
":direct_session_internal",
":example_parser_configuration",
":framework",
":framework_internal",
":lib",
":lib_internal",
":ops",
":protos_all_cc",
":test",
":test_main",
":testlib",
"//tensorflow/cc:cc_ops",
"//tensorflow/core/kernels:example_parsing_ops",
],
)
tf_cc_test( tf_cc_test(
name = "common_runtime_input_colocation_exemption_registry_test", name = "common_runtime_input_colocation_exemption_registry_test",
size = "small", size = "small",
@ -4468,13 +4403,6 @@ filegroup(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
filegroup(
name = "example_parser_configuration_testdata",
srcs = [
"example/testdata/parse_example_graph_def.pbtxt",
],
)
alias( alias(
name = "cuda_libdevice_path", name = "cuda_libdevice_path",
actual = "//tensorflow/core/platform:cuda_libdevice_path", actual = "//tensorflow/core/platform:cuda_libdevice_path",

View File

@ -0,0 +1,168 @@
load(
"@io_bazel_rules_closure//closure:defs.bzl",
"closure_proto_library",
)
load(
"//tensorflow:tensorflow.bzl",
"tf_cc_test",
"tf_copts",
)
load(
"//tensorflow/core/platform:build_config.bzl",
"tf_proto_library",
"tf_pyclif_proto_library",
)
package(
default_visibility = [
"//tensorflow/core:__subpackages__",
],
licenses = ["notice"], # Apache 2.0
)
# TODO(bmzhao): Refactor this target to use granular dependencies
# after stage 4 of the TF build refactor is complete:
# https://github.com/tensorflow/community/pull/179
cc_library(
name = "example_parser_configuration",
srcs = ["example_parser_configuration.cc"],
hdrs = ["example_parser_configuration.h"],
copts = tf_copts(),
linkstatic = 1,
visibility = ["//visibility:public"],
deps = [
"//tensorflow/core:core_cpu",
"//tensorflow/core:core_cpu_internal",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:protos_all_cc",
],
alwayslink = 1,
)
cc_library(
name = "feature_util",
srcs = ["feature_util.cc"],
hdrs = ["feature_util.h"],
deps = [
":example_protos_cc",
"//tensorflow/core/platform:protobuf",
"//tensorflow/core/platform:stringpiece",
"//tensorflow/core/platform:types",
"@com_google_absl//absl/base:core_headers",
],
alwayslink = 1,
)
# TODO(bmzhao): Refactor this target to use granular dependencies
# after stage 4 of the TF build refactor is complete:
# https://github.com/tensorflow/community/pull/179
tf_cc_test(
name = "example_parser_configuration_test",
size = "small",
srcs = ["example_parser_configuration_test.cc"],
data = [":example_parser_configuration_testdata"],
deps = [
"//tensorflow/cc:cc_ops",
"//tensorflow/core:core_cpu",
"//tensorflow/core:core_cpu_internal",
"//tensorflow/core:direct_session_internal",
"//tensorflow/core:example_parser_configuration",
"//tensorflow/core:framework",
"//tensorflow/core:framework_internal",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:ops",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
"//tensorflow/core:testlib",
"//tensorflow/core/kernels:example_parsing_ops",
],
)
filegroup(
name = "example_parser_configuration_testdata",
srcs = [
"testdata/parse_example_graph_def.pbtxt",
],
)
# TODO(bmzhao): Split this target into separate tf_proto_libraries.
# This target is a holdover from the target tensorflow/core:example_protos,
# but splitting it while require multiple LSCs.
tf_proto_library(
name = "example_protos",
srcs = [
"example.proto",
"feature.proto",
],
cc_api_version = 2,
make_default_target_header_only = True,
)
tf_proto_library(
name = "example_parser_configuration_proto",
srcs = ["example_parser_configuration.proto"],
cc_api_version = 2,
make_default_target_header_only = True,
protodeps = [
"//tensorflow/core/framework:tensor_shape_proto",
"//tensorflow/core/framework:tensor_proto",
"//tensorflow/core/framework:types_proto",
],
)
tf_proto_library(
name = "protos_all",
cc_api_version = 2,
make_default_target_header_only = True,
protodeps = [
":example_protos",
":example_parser_configuration_proto",
],
)
tf_pyclif_proto_library(
name = "example_pyclif",
proto_lib = "//tensorflow/core:protos_all",
proto_srcfile = "example.proto",
)
tf_pyclif_proto_library(
name = "feature_pyclif",
proto_lib = "//tensorflow/core:protos_all",
proto_srcfile = "feature.proto",
)
closure_proto_library(
name = "example_protos_closure",
visibility = ["//visibility:public"],
deps = [":example_protos"],
)
filegroup(
name = "mobile_srcs_no_runtime",
srcs = [
"feature_util.cc",
"feature_util.h",
],
)
# TODO(bmzhao): These files are exported since they are directly referenced
# from targets in tensorflow/core/BUILD. Remove these after phase 4 of the
# TF refactor: https://github.com/tensorflow/community/pull/179
exports_files(
srcs = [
"example.proto",
"example_parser_configuration_test.cc",
"feature.proto",
"feature_util.cc",
"feature_util.h",
"feature_util_test.cc",
],
visibility = [
"//tensorflow/core:__pkg__",
],
)

View File

@ -120,8 +120,8 @@ limitations under the License.
#include "absl/base/macros.h" #include "absl/base/macros.h"
#include "tensorflow/core/example/example.pb.h" #include "tensorflow/core/example/example.pb.h"
#include "tensorflow/core/example/feature.pb.h" #include "tensorflow/core/example/feature.pb.h"
#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/platform/protobuf.h" #include "tensorflow/core/platform/protobuf.h"
#include "tensorflow/core/platform/stringpiece.h"
#include "tensorflow/core/platform/types.h" #include "tensorflow/core/platform/types.h"
namespace tensorflow { namespace tensorflow {

View File

@ -19,7 +19,7 @@ tf_cc_test(
"graph_transferer_test.cc", "graph_transferer_test.cc",
"hexagon_graph_execution_test.cc", "hexagon_graph_execution_test.cc",
], ],
data = ["//tensorflow/core:example_parser_configuration_testdata"], data = ["//tensorflow/core/example:example_parser_configuration_testdata"],
deps = [ deps = [
":graph_transferer", ":graph_transferer",
"//tensorflow/cc:cc_ops", "//tensorflow/cc:cc_ops",