diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index 7fe076552b9..3b38d31386e 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -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", diff --git a/tensorflow/core/platform/BUILD b/tensorflow/core/platform/BUILD index c50fc306097..647efc8de18 100644 --- a/tensorflow/core/platform/BUILD +++ b/tensorflow/core/platform/BUILD @@ -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", diff --git a/tensorflow/core/platform/annotation.cc b/tensorflow/core/platform/annotation.cc new file mode 100644 index 00000000000..f80d29113a3 --- /dev/null +++ b/tensorflow/core/platform/annotation.cc @@ -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 diff --git a/tensorflow/core/platform/annotation.h b/tensorflow/core/platform/annotation.h index 3648a7e9ee2..6d8a2e2bef5 100644 --- a/tensorflow/core/platform/annotation.h +++ b/tensorflow/core/platform/annotation.h @@ -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 { diff --git a/tensorflow/core/profiler/internal/BUILD b/tensorflow/core/profiler/internal/BUILD index 7439a7f3988..281a6e4089f 100644 --- a/tensorflow/core/profiler/internal/BUILD +++ b/tensorflow/core/profiler/internal/BUILD @@ -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", ], )