Resolve //tensorflow relative to tensorflow repo so that tfcompile.bzl can be correctly loaded from another Bazel project (#14103)

This commit is contained in:
Thomas Deegan 2017-10-31 10:13:16 -07:00 committed by gunan
parent e64bc92d29
commit c37ebf0d53

View File

@ -4,7 +4,7 @@
To use from your BUILD file, add the following line to load the macro:
load("//tensorflow/compiler/aot:tfcompile.bzl", "tf_library")
load("@org_tensorflow//tensorflow/compiler/aot:tfcompile.bzl", "tf_library")
Then call the macro like this:
@ -16,14 +16,14 @@ tf_library(
)
"""
load("//tensorflow:tensorflow.bzl", "if_android", "tf_copts")
load("@org_tensorflow//tensorflow:tensorflow.bzl", "if_android", "tf_copts")
def tf_library(name, graph, config,
freeze_checkpoint=None, freeze_saver=None,
cpp_class=None, gen_test=True, gen_benchmark=True,
visibility=None, testonly=None,
tfcompile_flags=None,
tfcompile_tool="//tensorflow/compiler/aot:tfcompile",
tfcompile_tool="@org_tensorflow//tensorflow/compiler/aot:tfcompile",
include_standard_runtime_deps=True, deps=None, tags=None):
"""Runs tfcompile to compile a TensorFlow graph into executable code.
@ -119,9 +119,9 @@ def tf_library(name, graph, config,
out_nodes_file,
] + freeze_saver_srcs,
outs=[freeze_file],
cmd=("$(location //tensorflow/python/tools:freeze_graph)" +
cmd=("$(location @org_tensorflow//tensorflow/python/tools:freeze_graph)" +
freeze_args),
tools=["//tensorflow/python/tools:freeze_graph"],
tools=["@org_tensorflow//tensorflow/python/tools:freeze_graph"],
tags=tags,
)
tfcompile_graph = freeze_file
@ -207,22 +207,22 @@ def tf_library(name, graph, config,
# These deps are required by all tf_library targets even if
# include_standard_runtime_deps is False. Without them, the
# generated code will fail to compile.
"//tensorflow/compiler/tf2xla:xla_compiled_cpu_function",
"//tensorflow/core:framework_lite",
"@org_tensorflow//tensorflow/compiler/tf2xla:xla_compiled_cpu_function",
"@org_tensorflow//tensorflow/core:framework_lite",
] + (need_xla_data_proto and [
# If we're generating the program shape, we must depend on the proto.
"//tensorflow/compiler/xla:xla_data_proto",
"@org_tensorflow//tensorflow/compiler/xla:xla_data_proto",
] or []) + (include_standard_runtime_deps and [
# TODO(cwhipkey): only depend on kernel code that the model actually needed.
"//tensorflow/compiler/tf2xla/kernels:index_ops_kernel_argmax_float_1d",
"//tensorflow/compiler/tf2xla/kernels:index_ops_kernel_argmax_float_2d",
"//tensorflow/compiler/xla/service/cpu:cpu_runtime_avx",
"//tensorflow/compiler/xla/service/cpu:cpu_runtime_neon",
"//tensorflow/compiler/xla/service/cpu:cpu_runtime_sse4_1",
"//tensorflow/compiler/xla/service/cpu:runtime_conv2d",
"//tensorflow/compiler/xla/service/cpu:runtime_matmul",
"//tensorflow/compiler/xla/service/cpu:runtime_single_threaded_conv2d",
"//tensorflow/compiler/xla/service/cpu:runtime_single_threaded_matmul",
"@org_tensorflow//tensorflow/compiler/tf2xla/kernels:index_ops_kernel_argmax_float_1d",
"@org_tensorflow//tensorflow/compiler/tf2xla/kernels:index_ops_kernel_argmax_float_2d",
"@org_tensorflow//tensorflow/compiler/xla/service/cpu:cpu_runtime_avx",
"@org_tensorflow//tensorflow/compiler/xla/service/cpu:cpu_runtime_neon",
"@org_tensorflow//tensorflow/compiler/xla/service/cpu:cpu_runtime_sse4_1",
"@org_tensorflow//tensorflow/compiler/xla/service/cpu:runtime_conv2d",
"@org_tensorflow//tensorflow/compiler/xla/service/cpu:runtime_matmul",
"@org_tensorflow//tensorflow/compiler/xla/service/cpu:runtime_single_threaded_conv2d",
"@org_tensorflow//tensorflow/compiler/xla/service/cpu:runtime_single_threaded_matmul",
"//third_party/eigen3",
] or []) + (deps or []),
tags=tags,
@ -248,12 +248,12 @@ def tf_library(name, graph, config,
name=("gen_" + test_name),
testonly=1,
srcs=[
"//tensorflow/compiler/aot:test.cc",
"@org_tensorflow//tensorflow/compiler/aot:test.cc",
header_file,
],
outs=[test_file],
cmd=("sed " + sed_replace +
" $(location //tensorflow/compiler/aot:test.cc) " +
" $(location @org_tensorflow//tensorflow/compiler/aot:test.cc) " +
"> $(OUTS)"),
tags=tags,
)
@ -264,13 +264,13 @@ def tf_library(name, graph, config,
srcs=[test_file],
deps=[
":" + name,
"//tensorflow/compiler/tf2xla:xla_local_runtime_context",
"//tensorflow/compiler/aot:runtime",
"//tensorflow/compiler/aot:tf_library_test_main",
"//tensorflow/compiler/xla:executable_run_options",
"@org_tensorflow//tensorflow/compiler/tf2xla:xla_local_runtime_context",
"@org_tensorflow//tensorflow/compiler/aot:runtime",
"@org_tensorflow//tensorflow/compiler/aot:tf_library_test_main",
"@org_tensorflow//tensorflow/compiler/xla:executable_run_options",
"//third_party/eigen3",
"//tensorflow/core:lib",
"//tensorflow/core:test",
"@org_tensorflow//tensorflow/core:lib",
"@org_tensorflow//tensorflow/core:test",
],
tags=tags,
)
@ -278,7 +278,7 @@ def tf_library(name, graph, config,
if gen_benchmark:
benchmark_name = name + "_benchmark"
benchmark_file = benchmark_name + ".cc"
benchmark_main = ("//tensorflow/compiler/aot:" +
benchmark_main = ("@org_tensorflow//tensorflow/compiler/aot:" +
"benchmark_main.template")
# Rule to rewrite benchmark.cc to produce the benchmark_file.
@ -310,13 +310,13 @@ def tf_library(name, graph, config,
linkopts = if_android(["-pie", "-s"]),
deps=[
":" + name,
"//tensorflow/compiler/tf2xla:xla_local_runtime_context",
"//tensorflow/compiler/aot:benchmark",
"//tensorflow/compiler/aot:runtime",
"//tensorflow/compiler/xla:executable_run_options",
"@org_tensorflow//tensorflow/compiler/tf2xla:xla_local_runtime_context",
"@org_tensorflow//tensorflow/compiler/aot:benchmark",
"@org_tensorflow//tensorflow/compiler/aot:runtime",
"@org_tensorflow//tensorflow/compiler/xla:executable_run_options",
"//third_party/eigen3",
] + if_android([
"//tensorflow/compiler/aot:benchmark_extra_android",
"@org_tensorflow//tensorflow/compiler/aot:benchmark_extra_android",
]),
tags=tags,
)
@ -326,11 +326,11 @@ def target_llvm_triple():
# TODO(toddw): Add target_triple for other targets. For details see:
# http://llvm.org/docs/doxygen/html/Triple_8h_source.html
return select({
"//tensorflow:android_armeabi": "armv5-none-android",
"//tensorflow:android_arm": "armv7-none-android",
"//tensorflow:android_arm64": "aarch64-none-android",
"//tensorflow:android_x86": "i686-none-android",
"//tensorflow:linux_ppc64le": "ppc64le-ibm-linux-gnu",
"//tensorflow:darwin": "x86_64-none-darwin",
"@org_tensorflow//tensorflow:android_armeabi": "armv5-none-android",
"@org_tensorflow//tensorflow:android_arm": "armv7-none-android",
"@org_tensorflow//tensorflow:android_arm64": "aarch64-none-android",
"@org_tensorflow//tensorflow:android_x86": "i686-none-android",
"@org_tensorflow//tensorflow:linux_ppc64le": "ppc64le-ibm-linux-gnu",
"@org_tensorflow//tensorflow:darwin": "x86_64-none-darwin",
"//conditions:default": "x86_64-pc-linux",
})