From 69feb7e97d87286690e4e9684577fe03d48bc1d4 Mon Sep 17 00:00:00 2001
From: "A. Unique TensorFlower" <gardener@tensorflow.org>
Date: Fri, 7 Jun 2019 10:18:23 -0700
Subject: [PATCH] Adjust structure of all BUILD files to recommended style
 (https://docs.bazel.build/versions/master/skylark/build-style.html#file-structure),
 moving loads to top.

PiperOrigin-RevId: 252072215
---
 tensorflow/BUILD                              | 37 +++++++++----------
 tensorflow/c/eager/BUILD                      |  8 ++--
 tensorflow/compiler/tests/BUILD               | 20 +++++-----
 tensorflow/compiler/xrt/cc/BUILD              | 10 ++---
 tensorflow/core/api_def/BUILD                 | 10 ++---
 tensorflow/core/kernels/fuzzing/BUILD         |  8 ++--
 tensorflow/core/kernels/hexagon/BUILD         | 10 ++---
 tensorflow/core/platform/cloud/BUILD          | 10 ++---
 tensorflow/examples/adding_an_op/BUILD        | 10 ++---
 tensorflow/js/BUILD                           | 10 ++---
 tensorflow/lite/delegates/flex/BUILD          |  4 +-
 .../lite/experimental/examples/lstm/BUILD     |  4 +-
 tensorflow/lite/kernels/BUILD                 |  8 ++--
 .../toco/graph_transformations/tests/BUILD    | 10 ++---
 .../lite/toco/tensorflow_graph_matching/BUILD | 10 ++---
 .../kernel_tests/optimization/BUILD           |  4 +-
 tensorflow/python/kernel_tests/proto/BUILD    | 14 +++----
 tensorflow/python/training/saving/BUILD       |  4 +-
 tensorflow/tools/common/BUILD                 |  4 +-
 tensorflow/tools/proto_text/BUILD             | 20 +++++-----
 20 files changed, 107 insertions(+), 108 deletions(-)

diff --git a/tensorflow/BUILD b/tensorflow/BUILD
index beb9cd9ebae..6ee04deca87 100644
--- a/tensorflow/BUILD
+++ b/tensorflow/BUILD
@@ -2,20 +2,6 @@
 # TensorFlow is a computational framework, primarily for use in machine
 # learning applications.
 
-package(
-    default_visibility = [":internal"],
-    licenses = ["notice"],  # Apache 2.0
-)
-
-exports_files([
-    "LICENSE",
-    "ACKNOWLEDGMENTS",
-    # The leakr files are used by //third_party/cloud_tpu.
-    "leakr_badwords.dic",
-    "leakr_badfiles.dic",
-    "leakr_file_type_recipe.ftrcp",
-])
-
 load("//tensorflow:tensorflow.bzl", "VERSION")
 load("//tensorflow:tensorflow.bzl", "tf_cc_shared_object")
 load("//tensorflow:tensorflow.bzl", "tf_custom_op_library_additional_deps_impl")
@@ -41,6 +27,24 @@ load(
     "//third_party/ngraph:build_defs.bzl",
     "if_ngraph",
 )
+load(
+    "//third_party/mkl:build_defs.bzl",
+    "if_mkl_ml",
+)
+
+package(
+    default_visibility = [":internal"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+exports_files([
+    "LICENSE",
+    "ACKNOWLEDGMENTS",
+    # The leakr files are used by //third_party/cloud_tpu.
+    "leakr_badwords.dic",
+    "leakr_badfiles.dic",
+    "leakr_file_type_recipe.ftrcp",
+])
 
 # @unused
 TENSORFLOW_API_INIT_FILES_V2 = (
@@ -438,11 +442,6 @@ package_group(
     ],
 )
 
-load(
-    "//third_party/mkl:build_defs.bzl",
-    "if_mkl_ml",
-)
-
 filegroup(
     name = "intel_binary_blob",
     data = if_mkl_ml(
diff --git a/tensorflow/c/eager/BUILD b/tensorflow/c/eager/BUILD
index 0db85a17802..608655df439 100644
--- a/tensorflow/c/eager/BUILD
+++ b/tensorflow/c/eager/BUILD
@@ -1,9 +1,5 @@
 # Experimental extensions to the C API for eager execution of kernels.
 
-package(
-    licenses = ["notice"],  # Apache 2.0
-)
-
 load(
     "//tensorflow:tensorflow.bzl",
     "tf_copts",
@@ -21,6 +17,10 @@ load(
     "tf_cuda_tests_tags",
 )
 
+package(
+    licenses = ["notice"],  # Apache 2.0
+)
+
 tf_cuda_library(
     name = "c_api",
     srcs = [
diff --git a/tensorflow/compiler/tests/BUILD b/tensorflow/compiler/tests/BUILD
index d31ee80169c..c847d51e2a1 100644
--- a/tensorflow/compiler/tests/BUILD
+++ b/tensorflow/compiler/tests/BUILD
@@ -1,3 +1,13 @@
+load("//tensorflow:tensorflow.bzl", "tf_cuda_cc_test")
+load("//tensorflow:tensorflow.bzl", "cuda_py_test")
+load("//tensorflow/compiler/aot:tfcompile.bzl", "tf_library")
+load("//tensorflow/compiler/tests:build_defs.bzl", "tf_xla_py_test")
+load("//tensorflow/compiler/tests:build_defs.bzl", "generate_backend_suites")
+load(
+    "//tensorflow/core:platform/default/build_config_root.bzl",
+    "tf_cuda_tests_tags",
+)
+
 package(
     default_visibility = [":internal"],
     licenses = ["notice"],  # Apache 2.0
@@ -17,16 +27,6 @@ package_group(
     ],
 )
 
-load("//tensorflow:tensorflow.bzl", "tf_cuda_cc_test")
-load("//tensorflow:tensorflow.bzl", "cuda_py_test")
-load("//tensorflow/compiler/aot:tfcompile.bzl", "tf_library")
-load("//tensorflow/compiler/tests:build_defs.bzl", "tf_xla_py_test")
-load("//tensorflow/compiler/tests:build_defs.bzl", "generate_backend_suites")
-load(
-    "//tensorflow/core:platform/default/build_config_root.bzl",
-    "tf_cuda_tests_tags",
-)
-
 generate_backend_suites()
 
 py_library(
diff --git a/tensorflow/compiler/xrt/cc/BUILD b/tensorflow/compiler/xrt/cc/BUILD
index 59a965945ad..99ab50c8a8d 100644
--- a/tensorflow/compiler/xrt/cc/BUILD
+++ b/tensorflow/compiler/xrt/cc/BUILD
@@ -1,13 +1,13 @@
-package(
-    default_visibility = ["//visibility:public"],
-    licenses = ["notice"],  # Apache 2.0
-)
-
 load(
     "//tensorflow:tensorflow.bzl",
     "tf_gen_op_wrappers_cc",
 )
 
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
 tf_gen_op_wrappers_cc(
     name = "xrt_ops",
     op_lib_names = [
diff --git a/tensorflow/core/api_def/BUILD b/tensorflow/core/api_def/BUILD
index 1d8cfa063d4..d94387044e9 100644
--- a/tensorflow/core/api_def/BUILD
+++ b/tensorflow/core/api_def/BUILD
@@ -6,11 +6,6 @@
 #   :python_api_def
 #   :java_api_def
 
-package(
-    default_visibility = ["//visibility:private"],
-    licenses = ["notice"],  # Apache 2.0
-)
-
 load(
     "//tensorflow:tensorflow.bzl",
     "tf_cc_binary",
@@ -21,6 +16,11 @@ load(
     "if_mkl",
 )
 
+package(
+    default_visibility = ["//visibility:private"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
 filegroup(
     name = "base_api_def",
     srcs = glob(["base_api/*"]),
diff --git a/tensorflow/core/kernels/fuzzing/BUILD b/tensorflow/core/kernels/fuzzing/BUILD
index 28c1be5dbad..c719061b76c 100644
--- a/tensorflow/core/kernels/fuzzing/BUILD
+++ b/tensorflow/core/kernels/fuzzing/BUILD
@@ -1,3 +1,7 @@
+load("//tensorflow/core/kernels/fuzzing:tf_ops_fuzz_target_lib.bzl", "tf_ops_fuzz_target_lib")
+load("//tensorflow/core/kernels/fuzzing:tf_ops_fuzz_target_lib.bzl", "tf_oss_fuzz_corpus")
+load("//tensorflow/core/kernels/fuzzing:tf_ops_fuzz_target_lib.bzl", "tf_oss_fuzz_dict")
+
 package(
     default_visibility = ["//visibility:public"],
     licenses = ["notice"],  # Apache 2.0
@@ -13,10 +17,6 @@ cc_library(
     ],
 )
 
-load("//tensorflow/core/kernels/fuzzing:tf_ops_fuzz_target_lib.bzl", "tf_ops_fuzz_target_lib")
-load("//tensorflow/core/kernels/fuzzing:tf_ops_fuzz_target_lib.bzl", "tf_oss_fuzz_corpus")
-load("//tensorflow/core/kernels/fuzzing:tf_ops_fuzz_target_lib.bzl", "tf_oss_fuzz_dict")
-
 tf_ops_fuzz_target_lib("identity")
 
 tf_ops_fuzz_target_lib("string_to_number")
diff --git a/tensorflow/core/kernels/hexagon/BUILD b/tensorflow/core/kernels/hexagon/BUILD
index f2fdbb990c1..103e93fb67a 100644
--- a/tensorflow/core/kernels/hexagon/BUILD
+++ b/tensorflow/core/kernels/hexagon/BUILD
@@ -1,17 +1,17 @@
 # Description:
 #   quantization-specific OpKernels for hexagon
 
-package(
-    default_visibility = ["//visibility:public"],
-    licenses = ["notice"],  # Apache 2.0
-)
-
 load(
     "//tensorflow:tensorflow.bzl",
     "tf_cc_test",
     "tf_kernel_library",
 )
 
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
 tf_cc_test(
     name = "graph_transferer_test",
     size = "small",
diff --git a/tensorflow/core/platform/cloud/BUILD b/tensorflow/core/platform/cloud/BUILD
index 3b3bd306f77..7d61c8f78b6 100644
--- a/tensorflow/core/platform/cloud/BUILD
+++ b/tensorflow/core/platform/cloud/BUILD
@@ -1,11 +1,6 @@
 # Description:
 # Cloud file system implementation.
 
-package(
-    default_visibility = ["//visibility:private"],
-    licenses = ["notice"],  # Apache 2.0
-)
-
 load(
     "//tensorflow:tensorflow.bzl",
     "if_windows",
@@ -13,6 +8,11 @@ load(
     "tf_copts",
 )
 
+package(
+    default_visibility = ["//visibility:private"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
 cc_library(
     name = "expiring_lru_cache",
     hdrs = ["expiring_lru_cache.h"],
diff --git a/tensorflow/examples/adding_an_op/BUILD b/tensorflow/examples/adding_an_op/BUILD
index 39cd7072c0c..9feb6eb0ffd 100644
--- a/tensorflow/examples/adding_an_op/BUILD
+++ b/tensorflow/examples/adding_an_op/BUILD
@@ -1,11 +1,6 @@
 # Description:
 # Code examples referenced by adding_an_op
 
-package(
-    default_visibility = ["//tensorflow:internal"],
-    licenses = ["notice"],  # Apache 2.0
-)
-
 load(
     "//tensorflow/core:platform/default/build_config_root.bzl",
     "tf_cuda_tests_tags",
@@ -14,6 +9,11 @@ load(
 load("//tensorflow:tensorflow.bzl", "tf_custom_op_library")
 load("//tensorflow:tensorflow.bzl", "tf_cc_binary")
 
+package(
+    default_visibility = ["//tensorflow:internal"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
 exports_files(["LICENSE"])
 
 tf_custom_op_library(
diff --git a/tensorflow/js/BUILD b/tensorflow/js/BUILD
index 16a2b4af8f0..cf9025e33e9 100644
--- a/tensorflow/js/BUILD
+++ b/tensorflow/js/BUILD
@@ -5,16 +5,16 @@ visibility = [
     "//tensorflow:internal",
 ]
 
-package(
-    default_visibility = visibility,
-    licenses = ["notice"],  # Apache 2.0
-)
-
 load(
     "//tensorflow:tensorflow.bzl",
     "tf_cc_test",
 )
 
+package(
+    default_visibility = visibility,
+    licenses = ["notice"],  # Apache 2.0
+)
+
 cc_library(
     name = "ts_op_gen",
     srcs = [
diff --git a/tensorflow/lite/delegates/flex/BUILD b/tensorflow/lite/delegates/flex/BUILD
index bf8790d381a..a8d0ad8f0df 100644
--- a/tensorflow/lite/delegates/flex/BUILD
+++ b/tensorflow/lite/delegates/flex/BUILD
@@ -1,3 +1,5 @@
+load("//tensorflow:tensorflow.bzl", "tf_cc_test")
+
 #
 # This is a TF Lite delegate that is powered by TensorFlow's Eager.
 #
@@ -9,8 +11,6 @@ package(
     licenses = ["notice"],  # Apache 2.0
 )
 
-load("//tensorflow:tensorflow.bzl", "tf_cc_test")
-
 cc_library(
     name = "buffer_map",
     srcs = ["buffer_map.cc"],
diff --git a/tensorflow/lite/experimental/examples/lstm/BUILD b/tensorflow/lite/experimental/examples/lstm/BUILD
index 64aa5c5413a..be0479674e8 100644
--- a/tensorflow/lite/experimental/examples/lstm/BUILD
+++ b/tensorflow/lite/experimental/examples/lstm/BUILD
@@ -1,10 +1,10 @@
+load("//tensorflow:tensorflow.bzl", "py_test")
+
 package(
     default_visibility = ["//tensorflow:internal"],
     licenses = ["notice"],  # Apache 2.0
 )
 
-load("//tensorflow:tensorflow.bzl", "py_test")
-
 py_library(
     name = "rnn",
     srcs = ["rnn.py"],
diff --git a/tensorflow/lite/kernels/BUILD b/tensorflow/lite/kernels/BUILD
index d6f7c187909..0f255dea490 100644
--- a/tensorflow/lite/kernels/BUILD
+++ b/tensorflow/lite/kernels/BUILD
@@ -1,3 +1,7 @@
+load("//tensorflow/lite:build_def.bzl", "tflite_copts")
+load("//tensorflow/lite:special_rules.bzl", "tflite_portable_test_suite")
+load("//tensorflow:tensorflow.bzl", "tf_opts_nortti_if_android")
+
 package(
     default_visibility = [
         "//visibility:public",
@@ -5,10 +9,6 @@ package(
     licenses = ["notice"],  # Apache 2.0
 )
 
-load("//tensorflow/lite:build_def.bzl", "tflite_copts")
-load("//tensorflow/lite:special_rules.bzl", "tflite_portable_test_suite")
-load("//tensorflow:tensorflow.bzl", "tf_opts_nortti_if_android")
-
 # Enables usage of ruy in TFLite kernels.
 # WARNING: This build flag is experimental and subject to change.
 config_setting(
diff --git a/tensorflow/lite/toco/graph_transformations/tests/BUILD b/tensorflow/lite/toco/graph_transformations/tests/BUILD
index 9688c9adb39..49924292e70 100644
--- a/tensorflow/lite/toco/graph_transformations/tests/BUILD
+++ b/tensorflow/lite/toco/graph_transformations/tests/BUILD
@@ -1,13 +1,13 @@
-package(
-    default_visibility = ["//visibility:public"],
-    licenses = ["notice"],  # Apache 2.0
-)
-
 load(
     "//tensorflow:tensorflow.bzl",
     "tf_cc_test",
 )
 
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
 tf_cc_test(
     name = "lstm_utils_test",
     srcs = ["lstm_utils_test.cc"],
diff --git a/tensorflow/lite/toco/tensorflow_graph_matching/BUILD b/tensorflow/lite/toco/tensorflow_graph_matching/BUILD
index 2aa67574ad2..3aa262c6892 100644
--- a/tensorflow/lite/toco/tensorflow_graph_matching/BUILD
+++ b/tensorflow/lite/toco/tensorflow_graph_matching/BUILD
@@ -1,13 +1,13 @@
-package(
-    default_visibility = ["//visibility:public"],
-    licenses = ["notice"],  # Apache 2.0
-)
-
 load(
     "//tensorflow:tensorflow.bzl",
     "tf_cc_test",
 )
 
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
 cc_library(
     name = "cluster_utils",
     srcs = [
diff --git a/tensorflow/python/data/experimental/kernel_tests/optimization/BUILD b/tensorflow/python/data/experimental/kernel_tests/optimization/BUILD
index d0dfbad4f65..d45e7e07122 100644
--- a/tensorflow/python/data/experimental/kernel_tests/optimization/BUILD
+++ b/tensorflow/python/data/experimental/kernel_tests/optimization/BUILD
@@ -1,3 +1,5 @@
+load("//tensorflow:tensorflow.bzl", "py_test")
+
 package(
     default_visibility = ["//tensorflow:internal"],
     licenses = ["notice"],  # Apache 2.0
@@ -5,8 +7,6 @@ package(
 
 exports_files(["LICENSE"])
 
-load("//tensorflow:tensorflow.bzl", "py_test")
-
 py_test(
     name = "assert_next_dataset_test",
     size = "medium",
diff --git a/tensorflow/python/kernel_tests/proto/BUILD b/tensorflow/python/kernel_tests/proto/BUILD
index 15b98d3d68e..21d961b7a7a 100644
--- a/tensorflow/python/kernel_tests/proto/BUILD
+++ b/tensorflow/python/kernel_tests/proto/BUILD
@@ -1,12 +1,5 @@
 # Tests of tf.io.*proto.
 
-package(
-    default_visibility = ["//visibility:public"],
-    licenses = ["notice"],  # Apache 2.0
-)
-
-exports_files(["LICENSE"])
-
 load("//tensorflow:tensorflow.bzl", "tf_py_test")
 load("//tensorflow:tensorflow.bzl", "tf_cc_shared_object")
 load("//tensorflow/core:platform/default/build_config_root.bzl", "if_static")
@@ -14,6 +7,13 @@ load("//tensorflow/core:platform/default/build_config.bzl", "tf_additional_all_p
 load("//tensorflow/core:platform/default/build_config.bzl", "tf_proto_library")
 # Placeholder for Google-internal load statements.
 
+package(
+    default_visibility = ["//visibility:public"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+exports_files(["LICENSE"])
+
 tf_py_test(
     name = "decode_proto_op_test",
     size = "small",
diff --git a/tensorflow/python/training/saving/BUILD b/tensorflow/python/training/saving/BUILD
index 469a2d82ca7..7af5863e9c5 100644
--- a/tensorflow/python/training/saving/BUILD
+++ b/tensorflow/python/training/saving/BUILD
@@ -1,6 +1,8 @@
 # Description:
 #   Low-level utilities for reading and writing checkpoints.
 
+load("//tensorflow:tensorflow.bzl", "cuda_py_test")
+
 package(
     default_visibility = [
         "//tensorflow:internal",
@@ -10,8 +12,6 @@ package(
 
 exports_files(["LICENSE"])
 
-load("//tensorflow:tensorflow.bzl", "cuda_py_test")
-
 py_library(
     name = "functional_saver",
     srcs = ["functional_saver.py"],
diff --git a/tensorflow/tools/common/BUILD b/tensorflow/tools/common/BUILD
index c438c89be2d..dc21877f060 100644
--- a/tensorflow/tools/common/BUILD
+++ b/tensorflow/tools/common/BUILD
@@ -1,6 +1,8 @@
 # Description:
 #   Common functionality for TensorFlow tooling
 
+load("//tensorflow:tensorflow.bzl", "py_test")
+
 package(
     default_visibility = ["//tensorflow:__subpackages__"],
     licenses = ["notice"],  # Apache 2.0
@@ -8,8 +10,6 @@ package(
 
 exports_files(["LICENSE"])
 
-load("//tensorflow:tensorflow.bzl", "py_test")
-
 py_library(
     name = "public_api",
     srcs = ["public_api.py"],
diff --git a/tensorflow/tools/proto_text/BUILD b/tensorflow/tools/proto_text/BUILD
index d41ece78692..c3bbed5e595 100644
--- a/tensorflow/tools/proto_text/BUILD
+++ b/tensorflow/tools/proto_text/BUILD
@@ -8,16 +8,6 @@
 # Note that proto3 well-known types (e.g. Any) are not handled in a special way
 # by the generated code.
 
-package(
-    default_visibility = ["//visibility:private"],
-    licenses = ["notice"],  # Apache 2.0
-)
-
-exports_files([
-    "LICENSE",
-    "placeholder.txt",
-])
-
 load(
     "//tensorflow:tensorflow.bzl",
     "if_ios",
@@ -31,6 +21,16 @@ load(
     "tf_proto_library_cc",
 )
 
+package(
+    default_visibility = ["//visibility:private"],
+    licenses = ["notice"],  # Apache 2.0
+)
+
+exports_files([
+    "LICENSE",
+    "placeholder.txt",
+])
+
 cc_binary(
     name = "gen_proto_text_functions",
     srcs = ["gen_proto_text_functions.cc"],