Cleanup profiler deps

PiperOrigin-RevId: 280771005
Change-Id: I4e5021169c50ce8f261ffeada7c7d653d45d37b3
diff --git a/tensorflow/core/profiler/internal/BUILD b/tensorflow/core/profiler/internal/BUILD
index cd6de97..b1e610e 100644
--- a/tensorflow/core/profiler/internal/BUILD
+++ b/tensorflow/core/profiler/internal/BUILD
@@ -384,6 +384,7 @@
     deps = [
         ":traceme_recorder",
         "//tensorflow/core:lib",
+        "@com_google_absl//absl/synchronization",
         "@com_google_googletest//:gtest_main",
     ],
 )
@@ -393,9 +394,10 @@
     srcs = ["profiler_interface.cc"],
     hdrs = ["profiler_interface.h"],
     deps = [
-        "//tensorflow/core:lib",
         "//tensorflow/core:protos_all_cc",
+        "//tensorflow/core/lib/core:status",
         "//tensorflow/core/profiler/protobuf:xplane_proto_cc",
+        "@com_google_absl//absl/synchronization",
     ],
 )
 
diff --git a/tensorflow/core/profiler/internal/gpu/BUILD b/tensorflow/core/profiler/internal/gpu/BUILD
index 2e886ef..14a307c 100644
--- a/tensorflow/core/profiler/internal/gpu/BUILD
+++ b/tensorflow/core/profiler/internal/gpu/BUILD
@@ -39,6 +39,7 @@
         "//tensorflow/core/profiler/internal:profiler_interface",
         "//tensorflow/core/profiler/lib:traceme",
         "//tensorflow/core/profiler/protobuf:xplane_proto_cc",
+        "@com_google_absl//absl/flags:flag",
     ],
     alwayslink = 1,
 )
@@ -78,9 +79,9 @@
     copts = tf_copts(),
     visibility = ["//visibility:public"],
     deps = [
-        "//tensorflow/core:lib",
         "//tensorflow/core:platform_base",
         "//tensorflow/stream_executor/cuda:cupti_stub",
+        "@com_google_absl//absl/base:core_headers",
     ],
 )
 
diff --git a/tensorflow/core/profiler/internal/gpu/cupti_tracer.cc b/tensorflow/core/profiler/internal/gpu/cupti_tracer.cc
index 68d2444..1eab7fc 100644
--- a/tensorflow/core/profiler/internal/gpu/cupti_tracer.cc
+++ b/tensorflow/core/profiler/internal/gpu/cupti_tracer.cc
@@ -22,7 +22,6 @@
 #include "tensorflow/core/lib/hash/hash.h"
 #include "tensorflow/core/platform/env.h"
 #include "tensorflow/core/platform/logging.h"
-#include "tensorflow/core/platform/macros.h"
 #include "tensorflow/core/platform/mem.h"
 #include "tensorflow/core/profiler/internal/annotation_stack.h"
 
@@ -524,7 +523,7 @@
       break;
     case CUPTI_ACTIVITY_OBJECT_STREAM:
       event.stream_id = overhead->objectId.dcs.streamId;
-      TF_FALLTHROUGH_INTENDED;
+      ABSL_FALLTHROUGH_INTENDED;
     case CUPTI_ACTIVITY_OBJECT_DEVICE:
     case CUPTI_ACTIVITY_OBJECT_CONTEXT:
       event.device_id = overhead->objectId.dcs.deviceId;
diff --git a/tensorflow/core/profiler/internal/profiler_interface.cc b/tensorflow/core/profiler/internal/profiler_interface.cc
index bd3163f..e442aa6 100644
--- a/tensorflow/core/profiler/internal/profiler_interface.cc
+++ b/tensorflow/core/profiler/internal/profiler_interface.cc
@@ -14,30 +14,29 @@
 ==============================================================================*/
 #include "tensorflow/core/profiler/internal/profiler_interface.h"
 
-#include "tensorflow/core/platform/mutex.h"
-#include "tensorflow/core/platform/thread_annotations.h"
+#include "absl/synchronization/mutex.h"
 
 namespace tensorflow {
 namespace {
-
-mutex mu(LINKER_INITIALIZED);
-
-std::vector<ProfilerFactory>* GetFactories() EXCLUSIVE_LOCKS_REQUIRED(mu) {
+std::vector<ProfilerFactory>* GetFactories() {
   static auto factories = new std::vector<ProfilerFactory>();
   return factories;
 }
-
+absl::Mutex* GetMutex() {
+  static auto mutex = new absl::Mutex;
+  return mutex;
+}
 }  // namespace
 
 void RegisterProfilerFactory(ProfilerFactory factory) {
-  mutex_lock lock(mu);
+  absl::MutexLock lock(GetMutex());
   GetFactories()->push_back(factory);
 }
 
 void CreateProfilers(
     const profiler::ProfilerOptions& options,
     std::vector<std::unique_ptr<profiler::ProfilerInterface>>* result) {
-  mutex_lock lock(mu);
+  absl::MutexLock lock(GetMutex());
   for (auto factory : *GetFactories()) {
     if (auto profiler = factory(options)) {
       result->push_back(std::move(profiler));
diff --git a/tensorflow/core/profiler/internal/traceme_recorder.cc b/tensorflow/core/profiler/internal/traceme_recorder.cc
index 7d03d2f..20afbee 100644
--- a/tensorflow/core/profiler/internal/traceme_recorder.cc
+++ b/tensorflow/core/profiler/internal/traceme_recorder.cc
@@ -18,7 +18,6 @@
 
 #include "tensorflow/core/platform/env.h"
 #include "tensorflow/core/platform/logging.h"
-#include "tensorflow/core/platform/macros.h"
 
 namespace tensorflow {
 namespace profiler {
@@ -81,7 +80,7 @@
     size_t end = end_.load(std::memory_order_relaxed);
     new (&end_block_->events[end++ - end_block_->start].event)
         TraceMeRecorder::Event(std::move(event));
-    if (TF_PREDICT_FALSE(end - end_block_->start == Block::kNumSlots)) {
+    if (ABSL_PREDICT_FALSE(end - end_block_->start == Block::kNumSlots)) {
       auto* new_block = new Block{end, nullptr};
       end_block_->next = new_block;
       end_block_ = new_block;
@@ -119,7 +118,7 @@
     event.~Event();  // Events must be individually destroyed.
     // If we reach the end of a block, we own it and should delete it.
     // The next block is present: end always points to something.
-    if (TF_PREDICT_FALSE(start_ - start_block_->start == Block::kNumSlots)) {
+    if (ABSL_PREDICT_FALSE(start_ - start_block_->start == Block::kNumSlots)) {
       auto* next_block = start_block_->next;
       delete start_block_;
       start_block_ = next_block;
diff --git a/tensorflow/core/profiler/internal/traceme_recorder_test.cc b/tensorflow/core/profiler/internal/traceme_recorder_test.cc
index fc723fa..6899658 100644
--- a/tensorflow/core/profiler/internal/traceme_recorder_test.cc
+++ b/tensorflow/core/profiler/internal/traceme_recorder_test.cc
@@ -15,12 +15,11 @@
 #include "tensorflow/core/profiler/internal/traceme_recorder.h"
 
 #include <atomic>
-
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
+#include "absl/synchronization/notification.h"
 #include "tensorflow/core/lib/core/threadpool.h"
 #include "tensorflow/core/platform/env_time.h"
-#include "tensorflow/core/platform/notification.h"
 #include "tensorflow/core/platform/types.h"
 
 namespace tensorflow {
@@ -69,8 +68,8 @@
   constexpr static int kNumThreads = 4;
 
   // Start several threads writing events.
-  tensorflow::Notification start;
-  tensorflow::Notification stop;
+  absl::Notification start;
+  absl::Notification stop;
   thread::ThreadPool pool(Env::Default(), "testpool", kNumThreads);
   std::atomic<int> thread_count = {0};
   for (int i = 0; i < kNumThreads; i++) {
diff --git a/tensorflow/core/profiler/utils/BUILD b/tensorflow/core/profiler/utils/BUILD
index 189dfb1..b8fd44c 100644
--- a/tensorflow/core/profiler/utils/BUILD
+++ b/tensorflow/core/profiler/utils/BUILD
@@ -86,6 +86,7 @@
         ":time_utils",
         "//tensorflow/core:lib",
         "//tensorflow/core/profiler/protobuf:xplane_proto_cc",
+        "@com_google_absl//absl/container:flat_hash_map",
         "@com_google_absl//absl/strings",
     ],
 )
diff --git a/tensorflow/core/profiler/utils/xplane_builder.h b/tensorflow/core/profiler/utils/xplane_builder.h
index f51577b..1170328 100644
--- a/tensorflow/core/profiler/utils/xplane_builder.h
+++ b/tensorflow/core/profiler/utils/xplane_builder.h
@@ -15,6 +15,7 @@
 #ifndef TENSORFLOW_CORE_PROFILER_UTILS_XPLANE_BUILDER_H_
 #define TENSORFLOW_CORE_PROFILER_UTILS_XPLANE_BUILDER_H_
 
+#include "absl/container/flat_hash_map.h"
 #include "absl/strings/string_view.h"
 #include "tensorflow/core/platform/logging.h"
 #include "tensorflow/core/platform/types.h"