From b39b1ed24b4814db27d2f748dc85c10730ae851d Mon Sep 17 00:00:00 2001 From: Brian Atkinson Date: Mon, 18 Nov 2019 18:32:58 -0800 Subject: [PATCH] Require a dependency tree that fully resolves, through all select statements. This should help prevent cases where things are committed to the codebase with dangling references to things that don't exist. PiperOrigin-RevId: 281200606 Change-Id: Ic298a1e051687099d9aa696cacb0dc2de062b600 --- tensorflow/BUILD | 21 --------------------- tensorflow/cc/saved_model/BUILD | 13 +------------ tensorflow/compiler/aot/tests/BUILD | 2 +- tensorflow/compiler/aot/tfcompile.bzl | 4 ++-- tensorflow/examples/tf2_showcase/BUILD | 4 ++-- tensorflow/tools/ci_build/ci_sanity.sh | 20 ++++++++++++++++++-- tensorflow/tools/test/BUILD | 2 +- third_party/ngraph/ngraph_tf.BUILD | 1 - 8 files changed, 25 insertions(+), 42 deletions(-) diff --git a/tensorflow/BUILD b/tensorflow/BUILD index de15b3c668d..31e18e4e8f9 100644 --- a/tensorflow/BUILD +++ b/tensorflow/BUILD @@ -111,27 +111,6 @@ config_setting( visibility = ["//visibility:public"], ) -config_setting( - name = "chromiumos_x86_64", - flag_values = {"//tools/cpp:cc_target_os": "chromiumos"}, - values = {"cpu": "k8"}, - visibility = ["//visibility:public"], -) - -config_setting( - name = "chromiumos_arm64", - flag_values = {"//tools/cpp:cc_target_os": "chromiumos"}, - values = {"cpu": "arm"}, - visibility = ["//visibility:public"], -) - -config_setting( - name = "chromiumos_armv7", - flag_values = {"//tools/cpp:cc_target_os": "chromiumos"}, - values = {"cpu": "armeabi-v7a"}, - visibility = ["//visibility:public"], -) - config_setting( name = "emscripten", values = {"crosstool_top": "//external:android/emscripten"}, diff --git a/tensorflow/cc/saved_model/BUILD b/tensorflow/cc/saved_model/BUILD index 1fdb96af024..dad518d423f 100644 --- a/tensorflow/cc/saved_model/BUILD +++ b/tensorflow/cc/saved_model/BUILD @@ -41,21 +41,12 @@ cc_library( name = "reader", srcs = ["reader.cc"], hdrs = ["reader.h"], - deps = [ - ":constants", - ] + if_not_mobile([ + deps = [":constants"] + if_not_mobile([ # TODO(b/111634734): :lib and :protos_all contain dependencies that # cannot be built on mobile platforms. Instead, include the appropriate # tf_lib depending on the build platform. "//tensorflow/core:lib", "//tensorflow/core:protos_all_cc", - ]) + if_mobile([ - # Mobile-friendly SavedModel proto. See go/portable-proto for more info. - "//tensorflow/core:saved_model_portable_proto", - ]) + if_android([ - "//tensorflow/core:android_tensorflow_lib", - ]) + if_ios([ - "//tensorflow/core:ios_tensorflow_lib", ]), ) @@ -103,7 +94,6 @@ cc_library( "//tensorflow/core:core_cpu", "//tensorflow/core:lib", "//tensorflow/core:protos_all_cc", - # mobile not supported yet ]), ) @@ -121,7 +111,6 @@ cc_library( "//tensorflow/core:lib_internal", "//tensorflow/core:protos_all_cc", "//tensorflow/core/util/tensor_bundle:naming", - # mobile not supported yet ]), alwayslink = 1, ) diff --git a/tensorflow/compiler/aot/tests/BUILD b/tensorflow/compiler/aot/tests/BUILD index a3a8a8d06e2..7fcf1db6464 100644 --- a/tensorflow/compiler/aot/tests/BUILD +++ b/tensorflow/compiler/aot/tests/BUILD @@ -377,7 +377,7 @@ tf_cc_test( ":test_graph_tfmatmulandadd_with_profiling_mlir_bridge", "//tensorflow/compiler/xla:shape_util", "//tensorflow/compiler/xla:test", - "//tensorflow/compiler/xla:xla_data_proto", + "//tensorflow/compiler/xla:xla_data_proto_cc", "//tensorflow/compiler/xla/service:hlo_profile_printer", "//tensorflow/core:lib", "//tensorflow/core:regexp_internal", diff --git a/tensorflow/compiler/aot/tfcompile.bzl b/tensorflow/compiler/aot/tfcompile.bzl index 8591aff27cb..f274b030933 100644 --- a/tensorflow/compiler/aot/tfcompile.bzl +++ b/tensorflow/compiler/aot/tfcompile.bzl @@ -282,9 +282,9 @@ def tf_library( ] + (need_xla_data_proto and [ # If we're generating the program shape, we must depend on the # proto. - "//tensorflow/compiler/xla:xla_data_proto", + "//tensorflow/compiler/xla:xla_data_proto_cc", ] or []) + (enable_xla_hlo_profiling and [ - "//tensorflow/compiler/xla/service:hlo_profile_printer_data", + "//tensorflow/compiler/xla/service:hlo_profile_printer_data_cc", ] or []) + (include_standard_runtime_deps and [ # TODO(cwhipkey): only depend on kernel code that the model actually # needed. diff --git a/tensorflow/examples/tf2_showcase/BUILD b/tensorflow/examples/tf2_showcase/BUILD index eceeaf6363d..5e612ae2f6f 100644 --- a/tensorflow/examples/tf2_showcase/BUILD +++ b/tensorflow/examples/tf2_showcase/BUILD @@ -26,7 +26,7 @@ py_test( ], deps = [ "//tensorflow:tensorflow_py", - "//third_party/py/absl:app", - "//third_party/py/absl/flags", + "@absl_py//absl:app", + "@absl_py//absl/flags", ], ) diff --git a/tensorflow/tools/ci_build/ci_sanity.sh b/tensorflow/tools/ci_build/ci_sanity.sh index db111d88e02..664ba8463a4 100755 --- a/tensorflow/tools/ci_build/ci_sanity.sh +++ b/tensorflow/tools/ci_build/ci_sanity.sh @@ -458,6 +458,22 @@ do_bazel_nobuild() { "This is due to invalid BUILD files." } +do_bazel_deps_query() { + local BUILD_TARGET='//tensorflow/...' + # Android targets tend to depend on an Android runtime being available. + # Exclude until the sanity test has such a runtime available. + # + # TODO(mikecase): Remove TF Lite exclusion from this list. Exclusion is + # necessary since the @androidsdk WORKSPACE dependency is commented out by + # default in TF WORKSPACE file. + local BUILD_TARGET="${BUILD_TARGET}"' - kind("android_*", //tensorflow/...)' + + bazel query ${BAZEL_FLAGS} -- "deps($BUILD_TARGET)" > /dev/null + + cmd_status \ + "This is due to invalid BUILD files." +} + do_pip_smoke_test() { cd "$ROOT_DIR/tensorflow/tools/pip_package" python pip_smoke_test.py @@ -615,8 +631,8 @@ do_configure_test() { } # Supply all sanity step commands and descriptions -SANITY_STEPS=("do_configure_test" "do_pylint PYTHON2" "do_pylint PYTHON3" "do_check_futures_test" "do_buildifier" "do_bazel_nobuild" "do_pip_package_licenses_check" "do_lib_package_licenses_check" "do_java_package_licenses_check" "do_pip_smoke_test" "do_check_load_py_test" "do_code_link_check" "do_check_file_name_test" "do_pip_no_cuda_deps_check_ubuntu" "do_pip_no_cuda_deps_check_windows") -SANITY_STEPS_DESC=("Run ./configure" "Python 2 pylint" "Python 3 pylint" "Check that python files have certain __future__ imports" "buildifier check" "bazel nobuild" "pip: license check for external dependencies" "C library: license check for external dependencies" "Java Native Library: license check for external dependencies" "Pip Smoke Test: Checking py_test dependencies exist in pip package" "Check load py_test: Check that BUILD files with py_test target properly load py_test" "Code Link Check: Check there are no broken links" "Check file names for cases" "Check Ubuntu gpu pip package does not depend on cuda shared libraries" "Check Windows gpu pip package does not depend on cuda shared libraries") +SANITY_STEPS=("do_configure_test" "do_pylint PYTHON2" "do_pylint PYTHON3" "do_check_futures_test" "do_buildifier" "do_bazel_nobuild" "do_bazel_deps_query" "do_pip_package_licenses_check" "do_lib_package_licenses_check" "do_java_package_licenses_check" "do_pip_smoke_test" "do_check_load_py_test" "do_code_link_check" "do_check_file_name_test" "do_pip_no_cuda_deps_check_ubuntu" "do_pip_no_cuda_deps_check_windows") +SANITY_STEPS_DESC=("Run ./configure" "Python 2 pylint" "Python 3 pylint" "Check that python files have certain __future__ imports" "buildifier check" "bazel nobuild" "bazel query" "pip: license check for external dependencies" "C library: license check for external dependencies" "Java Native Library: license check for external dependencies" "Pip Smoke Test: Checking py_test dependencies exist in pip package" "Check load py_test: Check that BUILD files with py_test target properly load py_test" "Code Link Check: Check there are no broken links" "Check file names for cases" "Check Ubuntu gpu pip package does not depend on cuda shared libraries" "Check Windows gpu pip package does not depend on cuda shared libraries") INCREMENTAL_FLAG="" DEFAULT_BAZEL_CONFIGS="" diff --git a/tensorflow/tools/test/BUILD b/tensorflow/tools/test/BUILD index b09acad5036..b21f3742c23 100644 --- a/tensorflow/tools/test/BUILD +++ b/tensorflow/tools/test/BUILD @@ -112,5 +112,5 @@ tf_py_logged_benchmark( tf_py_logged_benchmark( name = "sparse_csr_matrix_ops_benchmark", - target = "//tensorflow/python/kernel_tests:sparse_csr_matrix_ops_test_py", + target = "//tensorflow/python/kernel_tests/linalg/sparse:csr_sparse_matrix_ops_test", ) diff --git a/third_party/ngraph/ngraph_tf.BUILD b/third_party/ngraph/ngraph_tf.BUILD index 6397e19e36a..b4b2511e6b1 100644 --- a/third_party/ngraph/ngraph_tf.BUILD +++ b/third_party/ngraph/ngraph_tf.BUILD @@ -61,7 +61,6 @@ cc_library( "@ngraph//:ngraph_core", "@org_tensorflow//tensorflow/core:core_cpu_headers_lib", "@org_tensorflow//tensorflow/core:framework_headers_lib", - "@org_tensorflow//tensorflow/core:protos_all_proto_text", ], alwayslink = 1, )