Add tensorflow/core/util/BUILD, which currently just exports the files in
that directory and adds tf_proto_library rules where necessary.

PiperOrigin-RevId: 284716215
Change-Id: I0f90fe1b26a6fbddfa90005aceb0da21eecd707a
diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD
index 9af8e12..0c1607a 100644
--- a/tensorflow/core/BUILD
+++ b/tensorflow/core/BUILD
@@ -99,7 +99,6 @@
 
 # Placeholder: load("//tensorflow:tensorflow.bzl", "tf_portable_proto_lib")
 load("//tensorflow:tensorflow.bzl", "tf_portable_proto_library")
-load("//tensorflow:tensorflow.bzl", "tf_version_info_genrule")
 
 # For platform specific build config
 load(
@@ -188,9 +187,12 @@
     "protobuf/saver.proto",
     "protobuf/verifier_config.proto",
     "protobuf/trace_events.proto",
-    "util/event.proto",
-    "util/memmapped_file_system.proto",
-    "util/saved_tensor_slice.proto",
+]
+
+UTIL_PROTO_SRCS = [
+    "//tensorflow/core/util:event.proto",
+    "//tensorflow/core/util:memmapped_file_system.proto",
+    "//tensorflow/core/util:saved_tensor_slice.proto",
 ]
 
 FRAMEWORK_PROTO_SRCS = [
@@ -230,7 +232,7 @@
 ]
 # LINT.ThenChange(//tensorflow/core/android_proto_config.asciipb)
 
-CORE_PROTO_SRCS = COMMON_PROTO_SRCS + FRAMEWORK_PROTO_SRCS + PROFILER_PROTO_SRCS + ERROR_CODES_PROTO_SRCS
+CORE_PROTO_SRCS = COMMON_PROTO_SRCS + FRAMEWORK_PROTO_SRCS + UTIL_PROTO_SRCS + PROFILER_PROTO_SRCS + ERROR_CODES_PROTO_SRCS
 
 tf_proto_library(
     name = "protos_all",
@@ -238,11 +240,12 @@
     cc_api_version = 2,
     make_default_target_header_only = True,
     protodeps = [
-        ":error_codes_proto_impl",
-        ":test_log_proto_impl",
         ":core_protos",
+        ":error_codes_proto_impl",
         "//tensorflow/core/framework:protos_all",
         "//tensorflow/core/lib/core:error_codes_proto",
+        "//tensorflow/core/util:protos_all",
+        "//tensorflow/core/util:test_log_proto_impl",
     ],
     visibility = ["//visibility:public"],
 )
@@ -274,14 +277,6 @@
     deps = [":example_protos"],
 )
 
-tf_proto_library(
-    name = "protos_test",
-    srcs = ["util/example_proto_fast_parsing_test.proto"],
-    cc_api_version = 2,
-    protodeps = tf_additional_all_protos(),
-    visibility = ["//visibility:public"],
-)
-
 filegroup(
     name = "platform_base_hdrs",
     srcs = [
@@ -333,17 +328,6 @@
 )
 
 filegroup(
-    name = "util_port_hdrs",
-    srcs = [
-        "util/port.h",
-    ],
-    visibility = [
-        "//tensorflow/core:__pkg__",
-        "//tensorflow/python:__pkg__",
-    ],
-)
-
-filegroup(
     name = "quantize_training_hdrs",
     srcs = [
         "graph/quantize_training.h",
@@ -354,18 +338,6 @@
     ],
 )
 
-cc_library(
-    name = "util_port",
-    srcs = ["util/port.cc"],
-    hdrs = ["util/port.h"],
-    copts = tf_copts(),
-    visibility = [
-        "//tensorflow/core:__pkg__",
-        "//tensorflow/python:__pkg__",
-    ],
-    alwayslink = 1,
-)
-
 filegroup(
     name = "platform_port_hdrs",
     srcs = [
@@ -520,6 +492,7 @@
         "//tensorflow/core/lib/monitoring:legacy_lib_monitoring_lib_headers",
         "//tensorflow/core/lib/random:legacy_lib_random_headers",
         "//tensorflow/core/lib/strings:legacy_lib_string_headers",
+        "//tensorflow/core/util:gpu_cuda_alias.h",
     ],
     visibility = ["//visibility:public"],
     deps = [
@@ -569,27 +542,10 @@
     ],
 )
 
-# TODO(gunan): Move this to core/util/BUILD once the  file is created
-cc_library(
-    name = "util_reporter",
-    srcs = ["util/reporter.cc"],
-    hdrs = ["util/reporter.h"],
-    # This should only be used in tensorflow/core/platform:test_benchmark
-    visibility = ["//tensorflow/core/platform:__subpackages__"],
-    deps = [
-        ":test_log_proto_impl_cc",
-        "//tensorflow/core/platform:env",
-        "//tensorflow/core/platform:errors",
-        "//tensorflow/core/platform:macros",
-        "//tensorflow/core/platform:mutex",
-        "//tensorflow/core/platform:str_util",
-        "//tensorflow/core/platform:types",
-    ],
-)
-
 # Test support library needed for all tests
 # This is currently public, but may be made internal in the
 # future.  Try to avoid depending on it.
+
 cc_library(
     name = "test",
     testonly = 1,
@@ -597,10 +553,10 @@
         "//tensorflow/core/platform:legacy_test_srcs",
     ],
     hdrs = [
-        "util/reporter.h",
         "//tensorflow/core/lib/core:legacy_lib_core_status_test_util_header",
         "//tensorflow/core/platform:test.h",
         "//tensorflow/core/platform:test_benchmark.h",
+        "//tensorflow/core/util:reporter.h",
     ],
     copts = tf_copts(),
     linkopts = select({
@@ -629,15 +585,10 @@
     hdrs = [
         "example/feature_util.h",
         "//tensorflow/core/framework:allocator.h",
-        "//tensorflow/core/framework:bounds_check.h",
-        "//tensorflow/core/framework:variant.h",
-        "//tensorflow/core/framework:variant_encode_decode.h",
-        "//tensorflow/core/framework:variant_op_registry.h",
-        "//tensorflow/core/framework:variant_tensor_data.h",
-        "//tensorflow/core/framework:shared_ptr_variant.h",
         "//tensorflow/core/framework:allocator_registry.h",
         "//tensorflow/core/framework:attr_value_util.h",
         "//tensorflow/core/framework:bfloat16.h",
+        "//tensorflow/core/framework:bounds_check.h",
         "//tensorflow/core/framework:cancellation.h",
         "//tensorflow/core/framework:collective.h",
         "//tensorflow/core/framework:common_shape_fns.h",
@@ -675,6 +626,7 @@
         "//tensorflow/core/framework:selective_registration.h",
         "//tensorflow/core/framework:session_state.h",
         "//tensorflow/core/framework:shape_inference.h",
+        "//tensorflow/core/framework:shared_ptr_variant.h",
         "//tensorflow/core/framework:stats_aggregator.h",
         "//tensorflow/core/framework:tensor.h",
         "//tensorflow/core/framework:tensor_shape.h",
@@ -687,48 +639,51 @@
         "//tensorflow/core/framework:type_traits.h",
         "//tensorflow/core/framework:typed_allocator.h",
         "//tensorflow/core/framework:types.h",
-        "public/version.h",
-        "util/activation_mode.h",
-        "util/batch_util.h",
-        "util/bcast.h",
-        "util/matmul_bcast.h",
-        "util/debug_events_writer.h",
-        "util/device_name_utils.h",
-        "util/dump_graph.h",
-        "util/events_writer.h",
-        "util/example_proto_fast_parsing.h",
-        "util/example_proto_helper.h",
-        "util/gpu_kernel_helper.h",
-        "util/guarded_philox_random.h",
-        "util/mirror_pad_mode.h",
-        "util/padding.h",
-        "util/einsum_op_util.h",
-        "util/port.h",
-        "util/ptr_util.h",
-        "util/reffed_status_callback.h",
-        "util/saved_tensor_slice_util.h",
-        "util/stat_summarizer.h",
-        "util/stat_summarizer_options.h",
-        "util/stream_executor_util.h",
-        "util/strided_slice_op.h",
-        "util/tensor_format.h",
-        "util/tensor_ops_util.h",
-        "util/tensor_slice_reader.h",
-        "util/tensor_slice_reader_cache.h",
-        "util/tensor_slice_writer.h",
-        "util/use_cudnn.h",
-        "util/matmul_autotune.h",
-        "util/util.h",
-        "util/work_sharder.h",
+        "//tensorflow/core/framework:variant.h",
+        "//tensorflow/core/framework:variant_encode_decode.h",
+        "//tensorflow/core/framework:variant_op_registry.h",
+        "//tensorflow/core/framework:variant_tensor_data.h",
         "//tensorflow/core/util/sparse:framework_group",
+        "//tensorflow/core/util:activation_mode.h",
+        "//tensorflow/core/util:batch_util.h",
+        "//tensorflow/core/util:bcast.h",
+        "//tensorflow/core/util:debug_events_writer.h",
+        "//tensorflow/core/util:device_name_utils.h",
+        "//tensorflow/core/util:dump_graph.h",
+        "//tensorflow/core/util:einsum_op_util.h",
+        "//tensorflow/core/util:events_writer.h",
+        "//tensorflow/core/util:example_proto_fast_parsing.h",
+        "//tensorflow/core/util:example_proto_helper.h",
+        "//tensorflow/core/util:gpu_kernel_helper.h",
+        "//tensorflow/core/util:guarded_philox_random.h",
+        "//tensorflow/core/util:matmul_autotune.h",
+        "//tensorflow/core/util:matmul_bcast.h",
+        "//tensorflow/core/util:mirror_pad_mode.h",
+        "//tensorflow/core/util:padding.h",
+        "//tensorflow/core/util:port.h",
+        "//tensorflow/core/util:ptr_util.h",
+        "//tensorflow/core/util:reffed_status_callback.h",
+        "//tensorflow/core/util:saved_tensor_slice_util.h",
+        "//tensorflow/core/util:stat_summarizer.h",
+        "//tensorflow/core/util:stat_summarizer_options.h",
+        "//tensorflow/core/util:stream_executor_util.h",
+        "//tensorflow/core/util:strided_slice_op.h",
+        "//tensorflow/core/util:tensor_format.h",
+        "//tensorflow/core/util:tensor_ops_util.h",
+        "//tensorflow/core/util:tensor_slice_reader.h",
+        "//tensorflow/core/util:tensor_slice_reader_cache.h",
+        "//tensorflow/core/util:tensor_slice_writer.h",
+        "//tensorflow/core/util:use_cudnn.h",
+        "//tensorflow/core/util:util.h",
+        "//tensorflow/core/util:work_sharder.h",
+        "public/version.h",
     ] + select({
         "//tensorflow:windows": [],
         "//conditions:default": [
-            "util/memmapped_file_system.h",
-            "util/memmapped_file_system_writer.h",
+            "//tensorflow/core/util:memmapped_file_system_hdrs",
         ],
     }) + if_mkl([
-        "util/mkl_util.h",
+        "//tensorflow/core/util:mkl_util.h",
     ]),
     visibility = ["//visibility:public"],
     deps = [
@@ -788,30 +743,8 @@
 )
 
 cc_library(
-    name = "stats_calculator_portable",
-    srcs = [
-        "util/stat_summarizer_options.h",
-        "util/stats_calculator.cc",
-    ],
-    hdrs = [
-        "util/stats_calculator.h",
-    ],
-    copts = tf_copts(),
-)
-
-tf_cc_test(
-    name = "stats_calculator_test",
-    srcs = ["util/stats_calculator_test.cc"],
-    deps = [
-        ":stats_calculator_portable",
-        ":test",
-        ":test_main",
-    ],
-)
-
-cc_library(
     name = "overflow",
-    hdrs = ["util/overflow.h"],
+    hdrs = ["//tensorflow/core/util:overflow.h"],
     deps = [
         ":framework_lite",
         ":lib",
@@ -820,13 +753,13 @@
 
 cc_library(
     name = "exec_on_stall",
-    hdrs = ["util/exec_on_stall.h"],
+    hdrs = ["//tensorflow/core/util:exec_on_stall.h"],
     deps = [":framework_lite"],
 )
 
 cc_library(
     name = "ptr_util",
-    hdrs = ["util/ptr_util.h"],
+    hdrs = ["//tensorflow/core/util:ptr_util.h"],
 )
 
 cc_library(
@@ -1556,10 +1489,10 @@
         "//tensorflow/core/lib/core:legacy_lib_core_all_headers",
         "//tensorflow/core/lib/core:legacy_lib_core_all_srcs",
         "//tensorflow/core/lib/gtl:legacy_lib_gtl_all_headers",
-        "//tensorflow/core/lib/histogram:legacy_lib_histogram_all_headers",
-        "//tensorflow/core/lib/histogram:legacy_lib_histogram_all_srcs",
         "//tensorflow/core/lib/hash:legacy_lib_hash_all_headers",
         "//tensorflow/core/lib/hash:legacy_lib_hash_all_srcs",
+        "//tensorflow/core/lib/histogram:legacy_lib_histogram_all_headers",
+        "//tensorflow/core/lib/histogram:legacy_lib_histogram_all_srcs",
         "//tensorflow/core/lib/io:legacy_lib_io_all_headers",
         "//tensorflow/core/lib/io:legacy_lib_io_all_srcs",
         "//tensorflow/core/lib/math:math_util.h",
@@ -1573,14 +1506,13 @@
         "//tensorflow/core/profiler:mobile_srcs",
         "//tensorflow/core/util/ctc:android_srcs",
         "//tensorflow/core/util/sparse:mobile_srcs_no_runtime_group",
+        "//tensorflow/core/util:mobile_srcs_no_runtime",
     ] + glob(
         [
             "client/**/*.cc",
             "lib/**/*.h",
             "lib/**/*.cc",
             "public/**/*.h",
-            "util/**/*.h",
-            "util/**/*.cc",
         ],
         exclude = [
             "**/*test.*",
@@ -1591,15 +1523,7 @@
             "lib/jpeg/**/*",
             "lib/png/**/*",
             "lib/gif/**/*",
-            "util/debug_events_writer.*",
-            "util/events_writer.*",
-            "util/stats_calculator.*",
-            "util/reporter.*",
             "user_ops/**/*.cu.cc",
-            "util/ctc/*.h",
-            "util/ctc/*.cc",
-            "util/tensor_bundle/*.h",
-            "util/tensor_bundle/*.cc",
             "common_runtime/gpu/**/*",
             "common_runtime/eager/*",
             "common_runtime/gpu_device_factory.*",
@@ -1614,13 +1538,13 @@
 filegroup(
     name = "mobile_srcs_only_runtime",
     srcs = [
-        "//tensorflow/core/framework:mobile_srcs_only_runtime",
+        "//tensorflow/c/eager:srcs",
+        "//tensorflow/c:srcs",
         "//tensorflow/core/common_runtime/eager:srcs",
+        "//tensorflow/core/framework:mobile_srcs_only_runtime",
         "//tensorflow/core/kernels:android_srcs",
         "//tensorflow/core/util/ctc:android_srcs",
         "//tensorflow/core/util/tensor_bundle:android_srcs",
-        "//tensorflow/c:srcs",
-        "//tensorflow/c/eager:srcs",
     ] + glob(
         [
             "common_runtime/**/*.h",
@@ -1679,7 +1603,6 @@
     deps = [
         ":mobile_additional_lib_deps",
         ":protos_all_cc_impl",
-        ":stats_calculator_portable",
         "//third_party/eigen3",
         "@com_google_protobuf//:protobuf",
         "@double_conversion//:double-conversion",
@@ -1704,7 +1627,6 @@
     deps = [
         ":mobile_additional_lib_deps",
         ":protos_all_cc_impl",
-        ":stats_calculator_portable",
         "//third_party/eigen3",
         "@com_google_protobuf//:protobuf",
         "@double_conversion//:double-conversion",
@@ -1737,7 +1659,6 @@
     deps = [
         ":emscripten_proto_lib_no_rtti_lite_runtime",
         ":mobile_additional_lib_deps",
-        ":stats_calculator_portable",
         "//third_party/eigen3",
         "@double_conversion//:double-conversion",
         "@farmhash_archive//:farmhash",
@@ -1780,7 +1701,6 @@
     deps = [
         ":mobile_additional_lib_deps",
         ":protos_all_cc_impl",
-        ":stats_calculator_portable",
         "//third_party/eigen3",
         "@com_google_protobuf//:protobuf",
         "@double_conversion//:double-conversion",
@@ -1852,8 +1772,6 @@
     # TODO(andrewharp/nhua):
     # make more test-related sources portable e.g. "//tensorflow/core/platform:test.cc",
     srcs = [
-        ":util/reporter.cc",
-        ":util/reporter.h",
         "//tensorflow/core/framework:fake_input.cc",
         "//tensorflow/core/framework:fake_input.h",
         "//tensorflow/core/framework:shape_inference_testutil.cc",
@@ -1861,6 +1779,8 @@
         "//tensorflow/core/framework:tensor_testutil.cc",
         "//tensorflow/core/framework:tensor_testutil.h",
         "//tensorflow/core/platform:test.h",
+        "//tensorflow/core/util:reporter.cc",
+        "//tensorflow/core/util:reporter.h",
     ],
     visibility = ["//visibility:public"],
 )
@@ -1869,13 +1789,13 @@
 filegroup(
     name = "android_test_srcs_no_core",
     srcs = [
-        ":util/reporter.cc",
-        ":util/reporter.h",
         "//tensorflow/core/framework:shape_inference_testutil.cc",
         "//tensorflow/core/framework:shape_inference_testutil.h",
         "//tensorflow/core/framework:tensor_testutil.cc",
         "//tensorflow/core/framework:tensor_testutil.h",
         "//tensorflow/core/platform:test.h",
+        "//tensorflow/core/util:reporter.cc",
+        "//tensorflow/core/util:reporter.h",
     ],
     visibility = ["//visibility:public"],
 )
@@ -1886,10 +1806,10 @@
     testonly = 1,
     srcs = if_android([":android_test_srcs"]),
     hdrs = [
-        "util/reporter.h",
         "//tensorflow/core/framework:fake_input.h",
         "//tensorflow/core/framework:shape_inference_testutil.h",
         "//tensorflow/core/framework:tensor_testutil.h",
+        "//tensorflow/core/util:reporter.h",
     ],
     copts = tf_copts(android_optimization_level_override = None),
     tags = [
@@ -2128,7 +2048,7 @@
     "//tensorflow/core/platform:tracing.h",
     "//tensorflow/core/platform:unbounded_work_queue.h",
     "//tensorflow/core/platform:legacy_platform_lib_hdrs",
-    "util/env_var.h",
+    "//tensorflow/core/util:env_var.h",
 ]
 
 cc_library(
@@ -2159,7 +2079,6 @@
     srcs = LIB_INTERNAL_PRIVATE_HEADERS + glob(
         [
             "lib/**/*.cc",
-            "util/env_var.cc",
         ],
         exclude = [
             "**/*test*",
@@ -2170,13 +2089,13 @@
         ],
     ) + [
         "//tensorflow/core/platform:legacy_lib_internal_srcs",
+        "//tensorflow/core/util:lib_internal_impl_srcs",
     ],
     hdrs = LIB_INTERNAL_PUBLIC_HEADERS,
     copts = tf_copts(),
     deps = tf_additional_lib_deps() + [
         ":core_stringpiece",
         ":lib_proto_parsing",
-        ":util_reporter",  # TODO(gunan): REMOVE as soon as cc_shared_library is supported.
         "@com_google_absl//absl/memory",
         "@com_google_absl//absl/strings",
         "//third_party/eigen3",
@@ -2303,6 +2222,7 @@
         "//tensorflow/core/platform:tstring",
         "//tensorflow/core/platform:unbounded_work_queue",
         "//tensorflow/core/platform/default/build_config:platformlib",
+        "//tensorflow/core/util:reporter",  # TODO(gunan): REMOVE as soon as cc_shared_library is supported.
         "@snappy",
         "@zlib_archive//:zlib",
         "@double_conversion//:double-conversion",
@@ -2477,15 +2397,6 @@
 )
 
 tf_proto_library(
-    name = "test_log_proto_impl",
-    srcs = ["util/test_log.proto"],
-    cc_api_version = 2,
-    make_default_target_header_only = True,
-    # Not to be used outside this file.
-    visibility = ["//visibility:private"],
-)
-
-tf_proto_library(
     name = "core_protos",
     srcs = COMMON_PROTO_SRCS + [
         # Protos which are not needed on mobile builds, but should be included
@@ -2513,10 +2424,11 @@
     make_default_target_header_only = True,
     protodeps = [
         ":error_codes_proto_impl",
-        ":test_log_proto_impl",
         "//tensorflow/core/framework:protos_all",
         "//tensorflow/core/lib/core:error_codes_proto",
         "//tensorflow/core/profiler/protobuf:xplane_proto",
+        "//tensorflow/core/util:protos_all",
+        "//tensorflow/core/util:test_log_proto_impl",
     ],
     visibility = ["//visibility:private"],
 )
@@ -2526,14 +2438,9 @@
     actual = "//tensorflow/core/lib/core:error_codes_proto_cc",
 )
 
-tf_version_info_genrule(
-    name = "version_info_gen",
-    out = "util/version_info.cc",
-)
-
 cc_library(
     name = "version_lib",
-    srcs = ["util/version_info.cc"],
+    srcs = ["//tensorflow/core/util:version_info.cc"],
     hdrs = ["public/version.h"],
     copts = tf_copts(),
 )
@@ -2546,28 +2453,20 @@
     "graph/tensor_id.h",
     "//tensorflow/core/util/sparse:framework_internal_private_headers_group",
     "//tensorflow/core/framework:framework_internal_private_hdrs",
+    "//tensorflow/core/util:framework_internal_private_hdrs",
 ] + glob(
     [
         "example/**/*.h",
-        "util/**/*.h",
     ],
     exclude = [
         "**/*test*",
         "**/*main.cc",
         "example/example_parser_configuration.*",
-        "util/reporter.h",
-        "util/reporter.cc",
-        "util/port.h",
-        "util/memmapped_file_system.*",
-        "util/memmapped_file_system_writer.*",
-        "util/session_message.*",
-        "util/version_info.cc",
     ],
 ) + select({
     "//tensorflow:windows": [],
     "//conditions:default": [
-        "util/memmapped_file_system.h",
-        "util/memmapped_file_system_writer.h",
+        "//tensorflow/core/util:memmapped_file_system_hdrs",
     ],
 })
 
@@ -2583,12 +2482,7 @@
     "//tensorflow/core/framework:tracking_allocator.h",  # only needed for tests
     "//tensorflow/core/framework:unique_tensor_references.h",
     "//tensorflow/core/framework:variant.h",
-    "util/command_line_flags.h",
-    "util/equal_graph_def.h",
-    "util/presized_cuckoo_map.h",
-    "util/tensor_slice_set.h",
-    "util/tensor_slice_util.h",
-    "util/xla_config_registry.h",
+    "//tensorflow/core/util:framework_internal_public_hdrs",
 ]
 
 tf_cuda_library(
@@ -2641,10 +2535,10 @@
     srcs = FRAMEWORK_INTERNAL_PRIVATE_HEADERS + [
         "//tensorflow/core/util/sparse:framework_internal_impl_group",
         "//tensorflow/core/framework:framework_internal_impl_srcs",
+        "//tensorflow/core/util:framework_internal_impl_srcs",
     ] + glob(
         [
             "example/**/*.cc",
-            "util/**/*.cc",
             "graph/edgeset.cc",
             "graph/graph.cc",
             "graph/graph_def_builder.cc",
@@ -2658,19 +2552,11 @@
             "**/*main.cc",
             "example/example_parser_configuration.*",
             "example/feature_util.cc",
-            "util/reporter.cc",
-            "util/memmapped_file_system.*",
-            "util/memmapped_file_system_writer.*",
-            "util/stats_calculator.*",
-            "util/version_info.cc",
-            "util/env_var.cc",
-            "util/port.cc",
         ],
     ) + select({
         "//tensorflow:windows": [],
         "//conditions:default": [
-            "util/memmapped_file_system.cc",
-            "util/memmapped_file_system_writer.cc",
+            "//tensorflow/core/util:memmapped_file_system_srcs",
         ],
     }),
     hdrs = FRAMEWORK_INTERNAL_PUBLIC_HEADERS,
@@ -2690,9 +2576,7 @@
         ":lib",
         ":lib_internal",
         ":protos_all_cc",
-        ":stats_calculator_portable",
         ":version_lib",
-        ":util_port",
         "@com_google_absl//absl/base",
         "@com_google_absl//absl/container:flat_hash_map",
         "@com_google_absl//absl/container:flat_hash_set",
@@ -2705,9 +2589,11 @@
         "//tensorflow/core/framework:numeric_types",
         "//tensorflow/core/kernels:bounds_check",
         "//tensorflow/core/platform/default/build_config:platformlib",
-        "//tensorflow/core/profiler/lib:traceme",
-        "//tensorflow/core/profiler/internal:traceme_recorder_impl",
         "//tensorflow/core/profiler/internal:annotation_stack_impl",
+        "//tensorflow/core/profiler/internal:traceme_recorder_impl",
+        "//tensorflow/core/profiler/lib:traceme",
+        "//tensorflow/core/util:port",
+        "//tensorflow/core/util:stats_calculator_portable",
     ] + if_static(
         extra_deps = ["@com_google_protobuf//:protobuf"],
         otherwise = ["@com_google_protobuf//:protobuf_headers"],
@@ -2774,7 +2660,7 @@
 tf_cuda_library(
     name = "cuda_device_functions",
     hdrs = [
-        "util/gpu_device_functions.h",
+        "//tensorflow/core/util:gpu_device_functions.h",
     ],
     visibility = ["//visibility:public"],
     deps = [":framework_lite"],
@@ -3156,7 +3042,7 @@
     srcs = ["common_runtime/direct_session.cc"],
     hdrs = [
         "common_runtime/direct_session.h",
-        "util/env_var.h",
+        "//tensorflow/core/util:env_var.h",
     ],
     copts = tf_copts(),
     deps = [
@@ -3681,7 +3567,7 @@
 tf_cc_test(
     name = "util_overflow_test",
     size = "small",
-    srcs = ["util/overflow_test.cc"],
+    srcs = ["//tensorflow/core/util:overflow_test.cc"],
     deps = [
         ":framework_lite",
         ":overflow",
@@ -3693,7 +3579,7 @@
 tf_cc_test(
     name = "exec_on_stall_test",
     size = "small",
-    srcs = ["util/exec_on_stall_test.cc"],
+    srcs = ["//tensorflow/core/util:exec_on_stall_test.cc"],
     deps = [
         ":exec_on_stall",
         ":framework_lite",
@@ -3781,10 +3667,10 @@
         ":lib_internal",
         ":ops",
         ":protos_all_cc",
-        ":protos_test_cc",
         ":test",
         ":test_main",
         ":testlib",
+        "//tensorflow/core/util:protos_test_cc",
     ],
 )
 
@@ -3817,29 +3703,6 @@
         "graph/subgraph_test.cc",
         "graph/tensor_id_test.cc",
         "graph/validate_test.cc",
-        "util/bcast_test.cc",
-        "util/command_line_flags_test.cc",
-        "util/debug_events_writer_test.cc",
-        "util/device_name_utils_test.cc",
-        "util/dump_graph_test.cc",
-        "util/equal_graph_def_test.cc",
-        "util/events_writer_test.cc",
-        "util/example_proto_fast_parsing_test.cc",
-        "util/example_proto_helper_test.cc",
-        "util/matmul_bcast_test.cc",
-        "util/memmapped_file_system_test.cc",
-        "util/presized_cuckoo_map_test.cc",
-        "util/reffed_status_callback_test.cc",
-        "util/reporter_test.cc",
-        "util/saved_tensor_slice_util_test.cc",
-        "util/semver_test.cc",
-        "util/stat_summarizer_test.cc",
-        "util/tensor_format_test.cc",
-        "util/tensor_slice_reader_test.cc",
-        "util/tensor_slice_set_test.cc",
-        "util/tensor_slice_util_test.cc",
-        "util/tensor_slice_writer_test.cc",
-        "util/work_sharder_test.cc",
         "//tensorflow/core/framework:allocator_test.cc",
         "//tensorflow/core/framework:attr_value_util_test.cc",
         "//tensorflow/core/framework:bfloat16_test.cc",
@@ -3877,6 +3740,29 @@
         "//tensorflow/core/framework:unique_tensor_references_test.cc",
         "//tensorflow/core/framework:variant_op_registry_test.cc",
         "//tensorflow/core/framework:variant_test.cc",
+        "//tensorflow/core/util:bcast_test.cc",
+        "//tensorflow/core/util:command_line_flags_test.cc",
+        "//tensorflow/core/util:debug_events_writer_test.cc",
+        "//tensorflow/core/util:device_name_utils_test.cc",
+        "//tensorflow/core/util:dump_graph_test.cc",
+        "//tensorflow/core/util:equal_graph_def_test.cc",
+        "//tensorflow/core/util:events_writer_test.cc",
+        "//tensorflow/core/util:example_proto_fast_parsing_test.cc",
+        "//tensorflow/core/util:example_proto_helper_test.cc",
+        "//tensorflow/core/util:matmul_bcast_test.cc",
+        "//tensorflow/core/util:memmapped_file_system_test.cc",
+        "//tensorflow/core/util:presized_cuckoo_map_test.cc",
+        "//tensorflow/core/util:reffed_status_callback_test.cc",
+        "//tensorflow/core/util:reporter_test.cc",
+        "//tensorflow/core/util:saved_tensor_slice_util_test.cc",
+        "//tensorflow/core/util:semver_test.cc",
+        "//tensorflow/core/util:stat_summarizer_test.cc",
+        "//tensorflow/core/util:tensor_format_test.cc",
+        "//tensorflow/core/util:tensor_slice_reader_test.cc",
+        "//tensorflow/core/util:tensor_slice_set_test.cc",
+        "//tensorflow/core/util:tensor_slice_util_test.cc",
+        "//tensorflow/core/util:tensor_slice_writer_test.cc",
+        "//tensorflow/core/util:work_sharder_test.cc",
         "//tensorflow/core/util/sparse:higher_level_tests_group",
     ],
     linkopts = select({
@@ -3895,7 +3781,6 @@
         ":lib_internal",
         ":ops",
         ":protos_all_cc",
-        ":protos_test_cc",
         ":test",
         ":test_main",
         ":testlib",
@@ -3907,6 +3792,7 @@
         "//tensorflow/cc:sendrecv_ops",
         "//tensorflow/cc:while_loop",
         "//tensorflow/core/kernels:ops_util",
+        "//tensorflow/core/util:protos_test_cc",
         "//third_party/eigen3",
         "@com_google_absl//absl/base",
         "@com_google_absl//absl/memory",
@@ -3938,7 +3824,6 @@
         ":lib_internal",
         ":ops",
         ":protos_all_cc",
-        ":protos_test_cc",
         ":test",
         ":test_main",
         ":testlib",
@@ -3947,6 +3832,7 @@
         "//tensorflow/cc:scope",
         "//tensorflow/cc:sendrecv_ops",
         "//tensorflow/core/kernels:ops_util",
+        "//tensorflow/core/util:protos_test_cc",
         "//third_party/eigen3",
     ],
 )
@@ -4009,10 +3895,10 @@
         ":lib_internal",
         ":ops",
         ":protos_all_cc",
-        ":protos_test_cc",
         ":test",
         ":test_main",
         ":testlib",
+        "//tensorflow/core/util:protos_test_cc",
         "@com_google_absl//absl/memory",
     ],
 )
@@ -4038,10 +3924,10 @@
         ":lib_internal",
         ":ops",
         ":protos_all_cc",
-        ":protos_test_cc",
         ":test",
         ":test_main",
         ":testlib",
+        "//tensorflow/core/util:protos_test_cc",
         "@com_google_absl//absl/memory",
     ],
 )
@@ -4067,10 +3953,10 @@
         ":lib_internal",
         ":ops",
         ":protos_all_cc",
-        ":protos_test_cc",
         ":test",
         ":test_main",
         ":testlib",
+        "//tensorflow/core/util:protos_test_cc",
         "@com_google_absl//absl/memory",
     ],
 )
@@ -4102,7 +3988,7 @@
     srcs = [
         "graph/mkl_layout_pass_test.cc",
         "graph/mkl_tfconversion_pass_test.cc",
-        "util/mkl_util_test.cc",
+        "//tensorflow/core/util:mkl_util_test.cc",
     ],
     linkstatic = 1,
     deps = [
@@ -4258,7 +4144,7 @@
 tf_cuda_only_cc_test(
     name = "util_gpu_kernel_helper_test",
     srcs = [
-        "util/gpu_kernel_helper_test.cu.cc",
+        "//tensorflow/core/util:gpu_kernel_helper_test.cu.cc",
     ],
     deps = [
         ":test",
@@ -5246,6 +5132,7 @@
     proto_deps = [
         ":core_protos",
         "//tensorflow/core/framework:protos_all",
+        "//tensorflow/core/util:protos_all",
     ],
     visibility = ["//visibility:public"],
     deps = ["@com_google_protobuf//:protobuf"],
diff --git a/tensorflow/core/platform/default/build_refactor.bzl b/tensorflow/core/platform/default/build_refactor.bzl
index 8dda322..0fce21d 100644
--- a/tensorflow/core/platform/default/build_refactor.bzl
+++ b/tensorflow/core/platform/default/build_refactor.bzl
@@ -347,7 +347,7 @@
             "//tensorflow/core/platform:env",
             "//tensorflow/core/platform:macros",
             "//tensorflow/core/platform:types",
-            "//tensorflow/core:util_reporter",
+            "//tensorflow/core/util:reporter",
         ],
         "tags": ["no_oss", "manual"],
         "visibility": ["//visibility:private"],
diff --git a/tensorflow/core/util/BUILD b/tensorflow/core/util/BUILD
new file mode 100644
index 0000000..fefd563
--- /dev/null
+++ b/tensorflow/core/util/BUILD
@@ -0,0 +1,389 @@
+load(
+    "//tensorflow/core/platform:build_config.bzl",
+    "tf_proto_library",
+)
+load(
+    "//tensorflow:tensorflow.bzl",
+    "tf_cc_test",
+    "tf_copts",
+)
+load("//tensorflow:tensorflow.bzl", "tf_version_info_genrule")
+
+package(
+    default_visibility = [
+        "//tensorflow/core:__subpackages__",
+    ],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+# Export all files for which we do not yet provide a dedicated build rule.
+# This avoids breading all the rules in tensorflow/core/BUILD.
+exports_files(
+    srcs = [
+        "activation_mode.cc",
+        "activation_mode.h",
+        "batch_util.cc",
+        "batch_util.h",
+        "bcast.cc",
+        "bcast.h",
+        "command_line_flags.cc",
+        "command_line_flags.h",
+        "debug_events_writer.cc",
+        "debug_events_writer.h",
+        "device_name_utils.cc",
+        "device_name_utils.h",
+        "dump_graph.cc",
+        "dump_graph.h",
+        "einsum_op_util.cc",
+        "einsum_op_util.h",
+        "env_var.cc",
+        "env_var.h",
+        "equal_graph_def.cc",
+        "equal_graph_def.h",
+        "events_writer.cc",
+        "events_writer.h",
+        "example_proto_fast_parsing.cc",
+        "example_proto_fast_parsing.h",
+        "example_proto_helper.cc",
+        "example_proto_helper.h",
+        "exec_on_stall.h",
+        "gpu_cuda_alias.h",
+        "gpu_device_functions.h",
+        "gpu_kernel_helper.h",
+        "gpu_kernel_helper_test.cu.cc",
+        "gpu_launch_config.h",
+        "guarded_philox_random.cc",
+        "guarded_philox_random.h",
+        "matmul_autotune.cc",
+        "matmul_autotune.h",
+        "matmul_bcast.cc",
+        "matmul_bcast.h",
+        "memmapped_file_system.cc",
+        "memmapped_file_system.h",
+        "memmapped_file_system_writer.cc",
+        "memmapped_file_system_writer.h",
+        "mirror_pad_mode.cc",
+        "mirror_pad_mode.h",
+        "mkl_util.h",
+        "overflow.h",
+        "padding.cc",
+        "padding.h",
+        "permutation_input_iterator.h",
+        "permutation_output_iterator.h",
+        "port.cc",
+        "port.h",
+        "presized_cuckoo_map.h",
+        "ptr_util.h",
+        "reffed_status_callback.h",
+        "reporter.cc",
+        "reporter.h",
+        "saved_tensor_slice_util.cc",
+        "saved_tensor_slice_util.h",
+        "stat_summarizer.cc",
+        "stat_summarizer.h",
+        "stat_summarizer_options.h",
+        "stats_calculator.cc",
+        "stats_calculator.h",
+        "stream_executor_util.h",
+        "strided_slice_op.cc",
+        "strided_slice_op.h",
+        "tensor_format.cc",
+        "tensor_format.h",
+        "tensor_ops_util.h",
+        "tensor_slice_reader.cc",
+        "tensor_slice_reader.h",
+        "tensor_slice_reader_cache.cc",
+        "tensor_slice_reader_cache.h",
+        "tensor_slice_set.cc",
+        "tensor_slice_set.h",
+        "tensor_slice_util.h",
+        "tensor_slice_writer.cc",
+        "tensor_slice_writer.h",
+        "transform_output_iterator.h",
+        "use_cudnn.cc",
+        "use_cudnn.h",
+        "util.cc",
+        "util.h",
+        "work_sharder.cc",
+        "work_sharder.h",
+        "xla_config_registry.cc",
+        "xla_config_registry.h",
+    ],
+    visibility = ["//tensorflow/core:__pkg__"],
+)
+
+# List of exported test source files that do not yet have local build rules.
+exports_files(
+    srcs = [
+        "bcast_test.cc",
+        "command_line_flags_test.cc",
+        "debug_events_writer_test.cc",
+        "device_name_utils_test.cc",
+        "dump_graph_test.cc",
+        "equal_graph_def_test.cc",
+        "events_writer_test.cc",
+        "example_proto_fast_parsing_test.cc",
+        "example_proto_helper_test.cc",
+        "exec_on_stall_test.cc",
+        "matmul_bcast_test.cc",
+        "memmapped_file_system_test.cc",
+        "mkl_util_test.cc",
+        "overflow_test.cc",
+        "presized_cuckoo_map_test.cc",
+        "reffed_status_callback_test.cc",
+        "reporter_test.cc",
+        "saved_tensor_slice_util_test.cc",
+        "semver_test.cc",
+        "stat_summarizer_test.cc",
+        "stats_calculator_test.cc",
+        "tensor_format_test.cc",
+        "tensor_slice_reader_test.cc",
+        "tensor_slice_set_test.cc",
+        "tensor_slice_util_test.cc",
+        "tensor_slice_writer_test.cc",
+        "work_sharder_test.cc",
+    ],
+    visibility = ["//tensorflow/core:__pkg__"],
+)
+
+# List of exported proto source files.
+exports_files(
+    srcs = [
+        "event.proto",
+        "example_proto_fast_parsing_test.proto",
+        "memmapped_file_system.proto",
+        "saved_tensor_slice.proto",
+        "test_log.proto",
+    ],
+    visibility = [
+        "//tensorflow:internal",
+        "//tensorflow/core:__pkg__",
+    ],
+)
+
+# The following filegroups are needed since globbing across packages boundaries
+# will just fail silently (see 3rd caveat at
+# https://docs.bazel.build/versions/master/be/functions.html#glob).
+# Files needed for core:framework_internal_impl.
+filegroup(
+    name = "mobile_srcs_no_runtime",
+    srcs = glob(
+        [
+            "*.cc",
+            "*.h",
+        ],
+        exclude = [
+            "*_test.*",
+            "debug_events_writer.*",
+            "events_writer.*",
+            "reporter.*",
+        ],
+    ),
+)
+
+filegroup(
+    name = "lib_internal_impl_srcs",
+    srcs = ["env_var.cc"],
+)
+
+filegroup(
+    name = "framework_internal_private_hdrs",
+    srcs = glob(
+        [
+            "*.h",
+        ],
+        exclude = [
+            "reporter.h",
+            "port.h",
+            "memmapped_file_system.*",
+            "memmapped_file_system_writer.*",
+            "session_message.*",
+        ],
+    ),
+)
+
+filegroup(
+    name = "framework_internal_public_hdrs",
+    srcs = [
+        "command_line_flags.h",
+        "equal_graph_def.h",
+        "presized_cuckoo_map.h",
+        "tensor_slice_set.h",
+        "tensor_slice_util.h",
+        "xla_config_registry.h",
+    ],
+)
+
+filegroup(
+    name = "framework_internal_impl_srcs",
+    srcs = glob(
+        [
+            "*.cc",
+        ],
+        exclude = [
+            "*test*",
+            "env_var.cc",
+            "memmapped_file_system.*",
+            "memmapped_file_system_writer.*",
+            "port.cc",
+            "reporter.cc",
+            "stats_calculator.cc",
+            "version_info.cc",
+        ],
+    ),
+)
+
+filegroup(
+    name = "memmapped_file_system_hdrs",
+    srcs = [
+        "memmapped_file_system.h",
+        "memmapped_file_system_writer.h",
+    ],
+)
+
+filegroup(
+    name = "memmapped_file_system_srcs",
+    srcs = [
+        "memmapped_file_system.cc",
+        "memmapped_file_system_writer.cc",
+    ],
+)
+
+filegroup(
+    name = "port_hdrs",
+    srcs = [
+        "port.h",
+    ],
+    visibility = [
+        "//tensorflow/core:__pkg__",
+        "//tensorflow/python:__pkg__",
+    ],
+)
+
+# Version info generation needs to be generated in the same package where it
+# is written.
+tf_version_info_genrule(
+    name = "version_info_gen",
+    out = "version_info.cc",
+)
+
+cc_library(
+    name = "stats_calculator_portable",
+    srcs = [
+        "stat_summarizer_options.h",
+        "stats_calculator.cc",
+    ],
+    hdrs = [
+        "stats_calculator.h",
+    ],
+    copts = tf_copts(),
+    visibility = [
+        "//tensorflow:internal",
+    ],
+)
+
+tf_cc_test(
+    name = "stats_calculator_test",
+    srcs = ["stats_calculator_test.cc"],
+    deps = [
+        ":stats_calculator_portable",
+        "//tensorflow/core:test",
+        "//tensorflow/core:test_main",
+    ],
+)
+
+cc_library(
+    name = "reporter",
+    srcs = ["reporter.cc"],
+    hdrs = ["reporter.h"],
+    visibility = ["//tensorflow/core:__subpackages__"],
+    deps = [
+        ":test_log_proto_impl_cc",
+        "//tensorflow/core/platform:env",
+        "//tensorflow/core/platform:errors",
+        "//tensorflow/core/platform:macros",
+        "//tensorflow/core/platform:mutex",
+        "//tensorflow/core/platform:str_util",
+        "//tensorflow/core/platform:types",
+    ],
+)
+
+cc_library(
+    name = "port",
+    srcs = ["port.cc"],
+    hdrs = ["port.h"],
+    copts = tf_copts(),
+    visibility = [
+        "//tensorflow/core:__pkg__",
+        "//tensorflow/python:__pkg__",
+    ],
+    alwayslink = 1,
+)
+
+# Proto libraries.
+tf_proto_library(
+    name = "test_log_proto_impl",
+    srcs = ["test_log.proto"],
+    cc_api_version = 2,
+    make_default_target_header_only = True,
+    # Not to be used outside of tensorflow/core.
+    visibility = ["//tensorflow/core:__pkg__"],
+)
+
+tf_proto_library(
+    name = "protos_test",
+    srcs = ["example_proto_fast_parsing_test.proto"],
+    cc_api_version = 2,
+    protodeps = ["//tensorflow/core:protos_all"],
+    visibility = ["//visibility:public"],
+)
+
+tf_proto_library(
+    name = "event_proto",
+    srcs = ["event.proto"],
+    cc_api_version = 2,
+    make_default_target_header_only = True,
+    protodeps = [
+        "//tensorflow/core/framework:summary_proto",
+        "//tensorflow/core/framework:resource_handle_proto",
+        "//tensorflow/core/framework:tensor_proto",
+        "//tensorflow/core/framework:tensor_shape_proto",
+        "//tensorflow/core/framework:types_proto",
+    ],
+    visibility = ["//visibility:public"],
+)
+
+tf_proto_library(
+    name = "saved_tensor_slice_proto",
+    srcs = ["saved_tensor_slice.proto"],
+    cc_api_version = 2,
+    make_default_target_header_only = True,
+    protodeps = [
+        "//tensorflow/core/framework:resource_handle_proto",
+        "//tensorflow/core/framework:tensor_proto",
+        "//tensorflow/core/framework:tensor_shape_proto",
+        "//tensorflow/core/framework:tensor_slice_proto",
+        "//tensorflow/core/framework:types_proto",
+        "//tensorflow/core/framework:versions_proto",
+    ],
+    visibility = ["//visibility:public"],
+)
+
+tf_proto_library(
+    name = "memmapped_file_system_proto",
+    srcs = ["memmapped_file_system.proto"],
+    cc_api_version = 2,
+    make_default_target_header_only = True,
+    visibility = ["//visibility:public"],
+)
+
+tf_proto_library(
+    name = "protos_all",
+    cc_api_version = 2,
+    make_default_target_header_only = True,
+    protodeps = [
+        ":event_proto",
+        ":saved_tensor_slice_proto",
+        ":memmapped_file_system_proto",
+    ],
+)
diff --git a/tensorflow/lite/profiling/BUILD b/tensorflow/lite/profiling/BUILD
index 672de40..03dd505 100644
--- a/tensorflow/lite/profiling/BUILD
+++ b/tensorflow/lite/profiling/BUILD
@@ -95,7 +95,7 @@
     deps = [
         ":memory_info",
         ":profile_buffer",
-        "//tensorflow/core:stats_calculator_portable",
+        "//tensorflow/core/util:stats_calculator_portable",
         "//tensorflow/lite:framework",
         "//tensorflow/lite/schema:schema_fbs",
     ],
diff --git a/tensorflow/lite/tools/benchmark/BUILD b/tensorflow/lite/tools/benchmark/BUILD
index 97d021c..22fc54c 100644
--- a/tensorflow/lite/tools/benchmark/BUILD
+++ b/tensorflow/lite/tools/benchmark/BUILD
@@ -151,7 +151,7 @@
         ":benchmark_params",
         ":benchmark_utils",
         ":logging",
-        "//tensorflow/core:stats_calculator_portable",
+        "//tensorflow/core/util:stats_calculator_portable",
         "//tensorflow/lite/c:common",
         "//tensorflow/lite/nnapi:nnapi_util",
         "//tensorflow/lite/profiling:time",
@@ -185,7 +185,7 @@
         ":benchmark_params",
         ":benchmark_utils",
         ":logging",
-        "//tensorflow/core:stats_calculator_portable",
+        "//tensorflow/core/util:stats_calculator_portable",
         "//tensorflow/lite:framework",
         "//tensorflow/lite/c:common",
         "//tensorflow/lite/profiling:memory_info",
diff --git a/tensorflow/lite/tools/benchmark/experimental/c/BUILD b/tensorflow/lite/tools/benchmark/experimental/c/BUILD
index 2bd26e8..1cb1e27 100644
--- a/tensorflow/lite/tools/benchmark/experimental/c/BUILD
+++ b/tensorflow/lite/tools/benchmark/experimental/c/BUILD
@@ -29,7 +29,7 @@
         "benchmark",
     ],
     deps = [
-        "//tensorflow/core:stats_calculator_portable",
+        "//tensorflow/core/util:stats_calculator_portable",
         "//tensorflow/lite/tools/benchmark:benchmark_tflite_model_lib",
     ],
 )
diff --git a/tensorflow/lite/tools/evaluation/stages/BUILD b/tensorflow/lite/tools/evaluation/stages/BUILD
index 497b880..d0bf3a1 100644
--- a/tensorflow/lite/tools/evaluation/stages/BUILD
+++ b/tensorflow/lite/tools/evaluation/stages/BUILD
@@ -40,7 +40,7 @@
     deps = [
         "@com_google_absl//absl/base",
         "//tensorflow/core:tflite_portable_logging",
-        "//tensorflow/core:stats_calculator_portable",
+        "//tensorflow/core/util:stats_calculator_portable",
         "//tensorflow/lite/profiling:time",
         "//tensorflow/lite/tools/evaluation:evaluation_stage",
         "//tensorflow/lite/kernels/internal:reference_base",
@@ -103,8 +103,8 @@
     hdrs = ["tflite_inference_stage.h"],
     copts = tflite_copts(),
     deps = [
-        "//tensorflow/core:stats_calculator_portable",
         "//tensorflow/core:tflite_portable_logging",
+        "//tensorflow/core/util:stats_calculator_portable",
         "//tensorflow/lite:framework",
         "//tensorflow/lite/c:common",
         "//tensorflow/lite/kernels:builtin_ops",
@@ -158,8 +158,8 @@
     copts = tflite_copts(),
     deps = [
         ":tflite_inference_stage",
-        "//tensorflow/core:stats_calculator_portable",
         "//tensorflow/core:tflite_portable_logging",
+        "//tensorflow/core/util:stats_calculator_portable",
         "//tensorflow/lite/tools/evaluation:evaluation_stage",
         "//tensorflow/lite/tools/evaluation/proto:evaluation_config_cc_proto",
         "//tensorflow/lite/tools/evaluation/proto:evaluation_stages_cc_proto",
diff --git a/tensorflow/python/BUILD b/tensorflow/python/BUILD
index 41ae638..ed2a724 100644
--- a/tensorflow/python/BUILD
+++ b/tensorflow/python/BUILD
@@ -594,10 +594,10 @@
 tf_python_pybind_extension(
     name = "_pywrap_util_port",
     srcs = ["util/port_wrapper.cc"],
-    hdrs = ["//tensorflow/core:util_port_hdrs"],
+    hdrs = ["//tensorflow/core/util:port_hdrs"],
     module_name = "_pywrap_util_port",
     deps = [
-        "//tensorflow/core:util_port",
+        "//tensorflow/core/util:port",
         "//third_party/python_runtime:headers",
         "@pybind11",
     ],
@@ -5556,7 +5556,7 @@
     ":cpp_python_util",  # util
     ":py_func_lib",  # py_func
     ":model_analyzer_lib",  # model_analyzer
-    "//tensorflow/core:util_port",  # util_port
+    "//tensorflow/core/util:port",  # util_port
     "//tensorflow/stream_executor:stream_executor_pimpl",  # stat_summarizer
     "//tensorflow/core/grappler/graph_analyzer:graph_analyzer_tool",  # graph_analyzer
     "//tensorflow/core/profiler/internal:print_model_analysis",  # tfprof
diff --git a/tensorflow/tools/proto_text/BUILD b/tensorflow/tools/proto_text/BUILD
index 611deca..85fba7e 100644
--- a/tensorflow/tools/proto_text/BUILD
+++ b/tensorflow/tools/proto_text/BUILD
@@ -39,8 +39,8 @@
     deps = [
         ":gen_proto_text_functions_lib",
         "@com_google_protobuf//:protobuf",
-        "//tensorflow/core:lib_proto_parsing",
         "//tensorflow/core/platform:protobuf_compiler",
+        "//tensorflow/core:lib_proto_parsing",
     ] + if_ios(["//tensorflow/core/platform/default/build_config:logging"]),
 )