mirror of
https://github.com/zebrajr/tensorflow.git
synced 2025-12-07 00:20:20 +01:00
Resolve //tensorflow relative to tensorflow repo so that tfcompile.bzl can be correctly loaded from another Bazel project (#14103)
This commit is contained in:
parent
e64bc92d29
commit
c37ebf0d53
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
To use from your BUILD file, add the following line to load the macro:
|
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:
|
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,
|
def tf_library(name, graph, config,
|
||||||
freeze_checkpoint=None, freeze_saver=None,
|
freeze_checkpoint=None, freeze_saver=None,
|
||||||
cpp_class=None, gen_test=True, gen_benchmark=True,
|
cpp_class=None, gen_test=True, gen_benchmark=True,
|
||||||
visibility=None, testonly=None,
|
visibility=None, testonly=None,
|
||||||
tfcompile_flags=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):
|
include_standard_runtime_deps=True, deps=None, tags=None):
|
||||||
"""Runs tfcompile to compile a TensorFlow graph into executable code.
|
"""Runs tfcompile to compile a TensorFlow graph into executable code.
|
||||||
|
|
||||||
|
|
@ -119,9 +119,9 @@ def tf_library(name, graph, config,
|
||||||
out_nodes_file,
|
out_nodes_file,
|
||||||
] + freeze_saver_srcs,
|
] + freeze_saver_srcs,
|
||||||
outs=[freeze_file],
|
outs=[freeze_file],
|
||||||
cmd=("$(location //tensorflow/python/tools:freeze_graph)" +
|
cmd=("$(location @org_tensorflow//tensorflow/python/tools:freeze_graph)" +
|
||||||
freeze_args),
|
freeze_args),
|
||||||
tools=["//tensorflow/python/tools:freeze_graph"],
|
tools=["@org_tensorflow//tensorflow/python/tools:freeze_graph"],
|
||||||
tags=tags,
|
tags=tags,
|
||||||
)
|
)
|
||||||
tfcompile_graph = freeze_file
|
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
|
# These deps are required by all tf_library targets even if
|
||||||
# include_standard_runtime_deps is False. Without them, the
|
# include_standard_runtime_deps is False. Without them, the
|
||||||
# generated code will fail to compile.
|
# generated code will fail to compile.
|
||||||
"//tensorflow/compiler/tf2xla:xla_compiled_cpu_function",
|
"@org_tensorflow//tensorflow/compiler/tf2xla:xla_compiled_cpu_function",
|
||||||
"//tensorflow/core:framework_lite",
|
"@org_tensorflow//tensorflow/core:framework_lite",
|
||||||
] + (need_xla_data_proto and [
|
] + (need_xla_data_proto and [
|
||||||
# If we're generating the program shape, we must depend on the proto.
|
# 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 [
|
] or []) + (include_standard_runtime_deps and [
|
||||||
# TODO(cwhipkey): only depend on kernel code that the model actually needed.
|
# TODO(cwhipkey): only depend on kernel code that the model actually needed.
|
||||||
"//tensorflow/compiler/tf2xla/kernels:index_ops_kernel_argmax_float_1d",
|
"@org_tensorflow//tensorflow/compiler/tf2xla/kernels:index_ops_kernel_argmax_float_1d",
|
||||||
"//tensorflow/compiler/tf2xla/kernels:index_ops_kernel_argmax_float_2d",
|
"@org_tensorflow//tensorflow/compiler/tf2xla/kernels:index_ops_kernel_argmax_float_2d",
|
||||||
"//tensorflow/compiler/xla/service/cpu:cpu_runtime_avx",
|
"@org_tensorflow//tensorflow/compiler/xla/service/cpu:cpu_runtime_avx",
|
||||||
"//tensorflow/compiler/xla/service/cpu:cpu_runtime_neon",
|
"@org_tensorflow//tensorflow/compiler/xla/service/cpu:cpu_runtime_neon",
|
||||||
"//tensorflow/compiler/xla/service/cpu:cpu_runtime_sse4_1",
|
"@org_tensorflow//tensorflow/compiler/xla/service/cpu:cpu_runtime_sse4_1",
|
||||||
"//tensorflow/compiler/xla/service/cpu:runtime_conv2d",
|
"@org_tensorflow//tensorflow/compiler/xla/service/cpu:runtime_conv2d",
|
||||||
"//tensorflow/compiler/xla/service/cpu:runtime_matmul",
|
"@org_tensorflow//tensorflow/compiler/xla/service/cpu:runtime_matmul",
|
||||||
"//tensorflow/compiler/xla/service/cpu:runtime_single_threaded_conv2d",
|
"@org_tensorflow//tensorflow/compiler/xla/service/cpu:runtime_single_threaded_conv2d",
|
||||||
"//tensorflow/compiler/xla/service/cpu:runtime_single_threaded_matmul",
|
"@org_tensorflow//tensorflow/compiler/xla/service/cpu:runtime_single_threaded_matmul",
|
||||||
"//third_party/eigen3",
|
"//third_party/eigen3",
|
||||||
] or []) + (deps or []),
|
] or []) + (deps or []),
|
||||||
tags=tags,
|
tags=tags,
|
||||||
|
|
@ -248,12 +248,12 @@ def tf_library(name, graph, config,
|
||||||
name=("gen_" + test_name),
|
name=("gen_" + test_name),
|
||||||
testonly=1,
|
testonly=1,
|
||||||
srcs=[
|
srcs=[
|
||||||
"//tensorflow/compiler/aot:test.cc",
|
"@org_tensorflow//tensorflow/compiler/aot:test.cc",
|
||||||
header_file,
|
header_file,
|
||||||
],
|
],
|
||||||
outs=[test_file],
|
outs=[test_file],
|
||||||
cmd=("sed " + sed_replace +
|
cmd=("sed " + sed_replace +
|
||||||
" $(location //tensorflow/compiler/aot:test.cc) " +
|
" $(location @org_tensorflow//tensorflow/compiler/aot:test.cc) " +
|
||||||
"> $(OUTS)"),
|
"> $(OUTS)"),
|
||||||
tags=tags,
|
tags=tags,
|
||||||
)
|
)
|
||||||
|
|
@ -264,13 +264,13 @@ def tf_library(name, graph, config,
|
||||||
srcs=[test_file],
|
srcs=[test_file],
|
||||||
deps=[
|
deps=[
|
||||||
":" + name,
|
":" + name,
|
||||||
"//tensorflow/compiler/tf2xla:xla_local_runtime_context",
|
"@org_tensorflow//tensorflow/compiler/tf2xla:xla_local_runtime_context",
|
||||||
"//tensorflow/compiler/aot:runtime",
|
"@org_tensorflow//tensorflow/compiler/aot:runtime",
|
||||||
"//tensorflow/compiler/aot:tf_library_test_main",
|
"@org_tensorflow//tensorflow/compiler/aot:tf_library_test_main",
|
||||||
"//tensorflow/compiler/xla:executable_run_options",
|
"@org_tensorflow//tensorflow/compiler/xla:executable_run_options",
|
||||||
"//third_party/eigen3",
|
"//third_party/eigen3",
|
||||||
"//tensorflow/core:lib",
|
"@org_tensorflow//tensorflow/core:lib",
|
||||||
"//tensorflow/core:test",
|
"@org_tensorflow//tensorflow/core:test",
|
||||||
],
|
],
|
||||||
tags=tags,
|
tags=tags,
|
||||||
)
|
)
|
||||||
|
|
@ -278,7 +278,7 @@ def tf_library(name, graph, config,
|
||||||
if gen_benchmark:
|
if gen_benchmark:
|
||||||
benchmark_name = name + "_benchmark"
|
benchmark_name = name + "_benchmark"
|
||||||
benchmark_file = benchmark_name + ".cc"
|
benchmark_file = benchmark_name + ".cc"
|
||||||
benchmark_main = ("//tensorflow/compiler/aot:" +
|
benchmark_main = ("@org_tensorflow//tensorflow/compiler/aot:" +
|
||||||
"benchmark_main.template")
|
"benchmark_main.template")
|
||||||
|
|
||||||
# Rule to rewrite benchmark.cc to produce the benchmark_file.
|
# 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"]),
|
linkopts = if_android(["-pie", "-s"]),
|
||||||
deps=[
|
deps=[
|
||||||
":" + name,
|
":" + name,
|
||||||
"//tensorflow/compiler/tf2xla:xla_local_runtime_context",
|
"@org_tensorflow//tensorflow/compiler/tf2xla:xla_local_runtime_context",
|
||||||
"//tensorflow/compiler/aot:benchmark",
|
"@org_tensorflow//tensorflow/compiler/aot:benchmark",
|
||||||
"//tensorflow/compiler/aot:runtime",
|
"@org_tensorflow//tensorflow/compiler/aot:runtime",
|
||||||
"//tensorflow/compiler/xla:executable_run_options",
|
"@org_tensorflow//tensorflow/compiler/xla:executable_run_options",
|
||||||
"//third_party/eigen3",
|
"//third_party/eigen3",
|
||||||
] + if_android([
|
] + if_android([
|
||||||
"//tensorflow/compiler/aot:benchmark_extra_android",
|
"@org_tensorflow//tensorflow/compiler/aot:benchmark_extra_android",
|
||||||
]),
|
]),
|
||||||
tags=tags,
|
tags=tags,
|
||||||
)
|
)
|
||||||
|
|
@ -326,11 +326,11 @@ def target_llvm_triple():
|
||||||
# TODO(toddw): Add target_triple for other targets. For details see:
|
# TODO(toddw): Add target_triple for other targets. For details see:
|
||||||
# http://llvm.org/docs/doxygen/html/Triple_8h_source.html
|
# http://llvm.org/docs/doxygen/html/Triple_8h_source.html
|
||||||
return select({
|
return select({
|
||||||
"//tensorflow:android_armeabi": "armv5-none-android",
|
"@org_tensorflow//tensorflow:android_armeabi": "armv5-none-android",
|
||||||
"//tensorflow:android_arm": "armv7-none-android",
|
"@org_tensorflow//tensorflow:android_arm": "armv7-none-android",
|
||||||
"//tensorflow:android_arm64": "aarch64-none-android",
|
"@org_tensorflow//tensorflow:android_arm64": "aarch64-none-android",
|
||||||
"//tensorflow:android_x86": "i686-none-android",
|
"@org_tensorflow//tensorflow:android_x86": "i686-none-android",
|
||||||
"//tensorflow:linux_ppc64le": "ppc64le-ibm-linux-gnu",
|
"@org_tensorflow//tensorflow:linux_ppc64le": "ppc64le-ibm-linux-gnu",
|
||||||
"//tensorflow:darwin": "x86_64-none-darwin",
|
"@org_tensorflow//tensorflow:darwin": "x86_64-none-darwin",
|
||||||
"//conditions:default": "x86_64-pc-linux",
|
"//conditions:default": "x86_64-pc-linux",
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user