Move annotation's thread_local storage to .cc file and clean up dependencies to avoid a duplicate symbol error.

PiperOrigin-RevId: 262733487
This commit is contained in:
A. Unique TensorFlower 2019-08-10 10:20:20 -07:00 committed by TensorFlower Gardener
parent 90169feba2
commit 5e307a0fbb
5 changed files with 35 additions and 19 deletions

View File

@ -643,6 +643,7 @@ cc_library(
":platform_protobuf",
"//tensorflow/core/platform",
"//tensorflow/core/platform:abi",
"//tensorflow/core/platform:annotation",
"//tensorflow/core/platform:stacktrace",
"//tensorflow/core/platform/default/build_config:other",
"//tensorflow/core/platform/default/build_config:platformlib",
@ -2420,7 +2421,6 @@ LIB_INTERNAL_PUBLIC_HEADERS = [
"lib/strings/proto_serialization.h",
"lib/strings/scanner.h",
"lib/wav/wav_io.h",
"//tensorflow/core/platform:annotation.h",
"//tensorflow/core/platform:demangle.h",
"//tensorflow/core/platform:denormal.h",
"//tensorflow/core/platform:host_info.h",
@ -2436,20 +2436,6 @@ LIB_INTERNAL_PUBLIC_HEADERS = [
"util/env_var.h",
]
cc_library(
name = "annotation",
srcs = [],
hdrs = [
"//tensorflow/core/platform:annotation.h",
],
copts = tf_copts(),
visibility = ["//visibility:public"],
deps = [
"//tensorflow/core/platform:macros",
"@com_google_absl//absl/strings",
],
)
# Replicated for lib_internal and lib_internal_impl.
LIB_INTERNAL_DEFINES = (
tf_additional_lib_defines() + [
@ -2476,6 +2462,7 @@ cc_library(
],
}),
deps = tf_additional_lib_deps() + [
"//tensorflow/core/platform:annotation",
"@com_google_absl//absl/meta:type_traits",
"@com_google_absl//absl/strings",
"//third_party/eigen3",
@ -2517,6 +2504,7 @@ cc_library(
"//third_party/eigen3",
"//tensorflow/core/lib/bfloat16",
"//tensorflow/core/platform:abi",
"//tensorflow/core/platform:annotation",
"//tensorflow/core/platform:cpu_info",
"//tensorflow/core/platform:stringprintf",
"//tensorflow/core/platform/default/build_config:platformlib",

View File

@ -46,7 +46,12 @@ cc_library(
cc_library(
name = "annotation",
srcs = ["annotation.cc"],
hdrs = ["annotation.h"],
visibility = [
"//perftools/accelerators/xprof:__subpackages__",
"//tensorflow:__subpackages__",
],
deps = [
":macros",
"@com_google_absl//absl/strings",
@ -306,6 +311,7 @@ filegroup(
"profile_utils/**/*.h",
],
exclude = [
"annotation.h",
"gif.h",
"jpeg.h",
"png.h",
@ -337,6 +343,7 @@ filegroup(
"**/human_readable_json.cc",
"**/rocm_rocdl_path.cc",
"abi.cc",
"annotation.cc",
"cpu_info.cc",
"platform_strings.cc",
"protobuf.cc",

View File

@ -0,0 +1,23 @@
/* 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.
==============================================================================*/
#include "tensorflow/core/platform/annotation.h"
namespace tensorflow {
/*static*/ std::string* Annotation::ThreadAnnotation() {
static thread_local std::string annotation;
return &annotation;
}
} // namespace tensorflow

View File

@ -68,10 +68,7 @@ class Annotation {
Annotation(const Annotation&) = delete; // Unconstructible.
// Returns a reference to the annotation for the current thread.
static std::string* ThreadAnnotation() {
static thread_local std::string annotation;
return &annotation;
}
static std::string* ThreadAnnotation();
};
namespace tracing {

View File

@ -434,6 +434,7 @@ tf_cc_test(
"//tensorflow/core:test",
"//tensorflow/core:test_main",
"//tensorflow/core:testlib",
"//tensorflow/core/platform:annotation",
"@com_google_absl//absl/strings",
],
)