Populate TF_TENSORRT_VERSION during configuration process.

PiperOrigin-RevId: 254059615
This commit is contained in:
Guangda Lai 2019-06-19 13:33:42 -07:00 committed by TensorFlower Gardener
parent c3f3aa8c9a
commit f9c8169d8f
17 changed files with 132 additions and 8 deletions

View File

@ -202,6 +202,7 @@ tensorflow/third_party/tensorrt/BUILD
tensorflow/third_party/tensorrt/build_defs.bzl.tpl tensorflow/third_party/tensorrt/build_defs.bzl.tpl
tensorflow/third_party/tensorrt/BUILD.tpl tensorflow/third_party/tensorrt/BUILD.tpl
tensorflow/third_party/tensorrt/tensorrt_configure.bzl tensorflow/third_party/tensorrt/tensorrt_configure.bzl
tensorflow/third_party/tensorrt/tensorrt/include/tensorrt_config.h.tpl
tensorflow/third_party/kafka/config.patch tensorflow/third_party/kafka/config.patch
tensorflow/third_party/kafka/BUILD tensorflow/third_party/kafka/BUILD
tensorflow/third_party/android/BUILD tensorflow/third_party/android/BUILD

View File

@ -27,5 +27,6 @@ cc_library(
"//tensorflow/stream_executor/platform", "//tensorflow/stream_executor/platform",
"@com_google_absl//absl/strings", "@com_google_absl//absl/strings",
"@local_config_cuda//cuda:cuda_headers", "@local_config_cuda//cuda:cuda_headers",
"@local_config_tensorrt//:tensorrt_headers",
], ],
) )

View File

@ -24,6 +24,7 @@ limitations under the License.
#include "tensorflow/stream_executor/lib/path.h" #include "tensorflow/stream_executor/lib/path.h"
#include "tensorflow/stream_executor/platform/logging.h" #include "tensorflow/stream_executor/platform/logging.h"
#include "tensorflow/stream_executor/platform/port.h" #include "tensorflow/stream_executor/platform/port.h"
#include "third_party/tensorrt/tensorrt_config.h"
namespace stream_executor { namespace stream_executor {
namespace internal { namespace internal {
@ -32,10 +33,6 @@ namespace {
string GetCudaVersion() { return TF_CUDA_VERSION; } string GetCudaVersion() { return TF_CUDA_VERSION; }
string GetCudaLibVersion() { return TF_CUDA_LIB_VERSION; } string GetCudaLibVersion() { return TF_CUDA_LIB_VERSION; }
string GetCudnnVersion() { return TF_CUDNN_VERSION; } string GetCudnnVersion() { return TF_CUDNN_VERSION; }
// TODO(laigd): populate the version string during configuration process. For
// now hardcoded version 5 since 4.0 is not supported anyway.
#define TF_TENSORRT_VERSION "5"
string GetTensorRTVersion() { return TF_TENSORRT_VERSION; } string GetTensorRTVersion() { return TF_TENSORRT_VERSION; }
port::StatusOr<void*> GetDsoHandle(const string& name, const string& version) { port::StatusOr<void*> GetDsoHandle(const string& name, const string& version) {

View File

@ -157,6 +157,7 @@ genrule(
"@jpeg//:LICENSE.md", "@jpeg//:LICENSE.md",
"@lmdb//:LICENSE", "@lmdb//:LICENSE",
"@local_config_sycl//sycl:LICENSE.text", "@local_config_sycl//sycl:LICENSE.text",
"@local_config_tensorrt//:LICENSE",
"@nasm//:LICENSE", "@nasm//:LICENSE",
"@nsync//:LICENSE", "@nsync//:LICENSE",
"@png_archive//:LICENSE", "@png_archive//:LICENSE",
@ -228,6 +229,7 @@ genrule(
"@jpeg//:LICENSE.md", "@jpeg//:LICENSE.md",
"@lmdb//:LICENSE", "@lmdb//:LICENSE",
"@local_config_sycl//sycl:LICENSE.text", "@local_config_sycl//sycl:LICENSE.text",
"@local_config_tensorrt//:LICENSE",
"@nasm//:LICENSE", "@nasm//:LICENSE",
"@nsync//:LICENSE", "@nsync//:LICENSE",
"@png_archive//:LICENSE", "@png_archive//:LICENSE",

View File

@ -181,6 +181,7 @@ filegroup(
"@keras_applications_archive//:LICENSE", "@keras_applications_archive//:LICENSE",
"@lmdb//:LICENSE", "@lmdb//:LICENSE",
"@local_config_sycl//sycl:LICENSE.text", "@local_config_sycl//sycl:LICENSE.text",
"@local_config_tensorrt//:LICENSE",
"@nasm//:LICENSE", "@nasm//:LICENSE",
"@nsync//:LICENSE", "@nsync//:LICENSE",
"@pasta//:LICENSE", "@pasta//:LICENSE",

View File

@ -11,7 +11,10 @@ exports_files(["LICENSE"])
cc_library( cc_library(
name = "tensorrt_headers", name = "tensorrt_headers",
hdrs = [":tensorrt_include"], hdrs = [
"tensorrt/include/tensorrt_config.h",
":tensorrt_include"
],
include_prefix = "third_party/tensorrt", include_prefix = "third_party/tensorrt",
strip_include_prefix = "tensorrt/include", strip_include_prefix = "tensorrt/include",
) )

View File

@ -0,0 +1,21 @@
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORRT_TENSORRT_INCLUDE_CONFIG_H_
#define TENSORRT_TENSORRT_INCLUDE_CONFIG_H_
#define TF_TENSORRT_VERSION "%{tensorrt_version}"
#endif // TENSORRT_TENSORRT_INCLUDE_CONFIG_H_

View File

@ -61,6 +61,9 @@ def _create_dummy_repository(repository_ctx):
"\":tensorrt_include\"": "", "\":tensorrt_include\"": "",
"\":tensorrt_lib\"": "", "\":tensorrt_lib\"": "",
}) })
_tpl(repository_ctx, "tensorrt/include/tensorrt_config.h", {
"%{tensorrt_version}": "",
})
def enable_tensorrt(repository_ctx): def enable_tensorrt(repository_ctx):
"""Returns whether to build with TensorRT support.""" """Returns whether to build with TensorRT support."""
@ -77,8 +80,25 @@ def _tensorrt_configure_impl(repository_ctx):
Label(remote_config_repo + ":build_defs.bzl"), Label(remote_config_repo + ":build_defs.bzl"),
{}, {},
) )
repository_ctx.template(
"tensorrt/include/tensorrt_config.h",
Label(remote_config_repo + ":tensorrt/include/tensorrt_config.h"),
{},
)
repository_ctx.template(
"LICENSE",
Label(remote_config_repo + ":LICENSE"),
{},
)
return return
# Copy license file in non-remote build.
repository_ctx.template(
"LICENSE",
Label("//third_party/tensorrt:LICENSE"),
{},
)
if not enable_tensorrt(repository_ctx): if not enable_tensorrt(repository_ctx):
_create_dummy_repository(repository_ctx) _create_dummy_repository(repository_ctx)
return return
@ -115,6 +135,12 @@ def _tensorrt_configure_impl(repository_ctx):
"%{copy_rules}": "\n".join(copy_rules), "%{copy_rules}": "\n".join(copy_rules),
}) })
# Set up tensorrt_config.h, which is used by
# tensorflow/stream_executor/dso_loader.cc.
_tpl(repository_ctx, "tensorrt/include/tensorrt_config.h", {
"%{tensorrt_version}": trt_version,
})
tensorrt_configure = repository_rule( tensorrt_configure = repository_rule(
implementation = _tensorrt_configure_impl, implementation = _tensorrt_configure_impl,
environ = [ environ = [

View File

@ -11,7 +11,10 @@ exports_files(["LICENSE"])
cc_library( cc_library(
name = "tensorrt_headers", name = "tensorrt_headers",
hdrs = [":tensorrt_include"], hdrs = [
"tensorrt/include/tensorrt_config.h",
":tensorrt_include",
],
include_prefix = "third_party/tensorrt", include_prefix = "third_party/tensorrt",
strip_include_prefix = "tensorrt/include", strip_include_prefix = "tensorrt/include",
) )

View File

@ -0,0 +1,21 @@
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORRT_TENSORRT_INCLUDE_CONFIG_H_
#define TENSORRT_TENSORRT_INCLUDE_CONFIG_H_
#define TF_TENSORRT_VERSION "5"
#endif // TENSORRT_TENSORRT_INCLUDE_CONFIG_H_

View File

@ -11,7 +11,10 @@ exports_files(["LICENSE"])
cc_library( cc_library(
name = "tensorrt_headers", name = "tensorrt_headers",
hdrs = [":tensorrt_include"], hdrs = [
"tensorrt/include/tensorrt_config.h",
":tensorrt_include",
],
include_prefix = "third_party/tensorrt", include_prefix = "third_party/tensorrt",
strip_include_prefix = "tensorrt/include", strip_include_prefix = "tensorrt/include",
) )

View File

@ -0,0 +1,21 @@
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORRT_TENSORRT_INCLUDE_CONFIG_H_
#define TENSORRT_TENSORRT_INCLUDE_CONFIG_H_
#define TF_TENSORRT_VERSION "5"
#endif // TENSORRT_TENSORRT_INCLUDE_CONFIG_H_

View File

@ -11,7 +11,10 @@ exports_files(["LICENSE"])
cc_library( cc_library(
name = "tensorrt_headers", name = "tensorrt_headers",
hdrs = [":tensorrt_include"], hdrs = [
"tensorrt/include/tensorrt_config.h",
":tensorrt_include",
],
include_prefix = "third_party/tensorrt", include_prefix = "third_party/tensorrt",
strip_include_prefix = "tensorrt/include", strip_include_prefix = "tensorrt/include",
) )

View File

@ -0,0 +1,21 @@
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORRT_TENSORRT_INCLUDE_CONFIG_H_
#define TENSORRT_TENSORRT_INCLUDE_CONFIG_H_
#define TF_TENSORRT_VERSION "5"
#endif // TENSORRT_TENSORRT_INCLUDE_CONFIG_H_