From 287a60c12a4a83e0ebf8b027b21b31e6a09727e8 Mon Sep 17 00:00:00 2001
From: Jiho Choi <jihochoi@google.com>
Date: Fri, 12 Jun 2020 13:29:55 -0700
Subject: [PATCH] Change the prefix of xprof arguments from "$" to "_".

PiperOrigin-RevId: 316166741
Change-Id: I3a83f550755e6c34a179781d61ab6c24b03cca13
---
 tensorflow/core/common_runtime/direct_session.cc     |  4 ++--
 .../core/common_runtime/eager/kernel_and_device.cc   |  2 +-
 tensorflow/core/distributed_runtime/graph_mgr.cc     |  2 +-
 tensorflow/core/profiler/lib/connected_traceme.h     |  6 ++----
 tensorflow/core/profiler/utils/xplane_schema.cc      | 12 ++++++------
 5 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/tensorflow/core/common_runtime/direct_session.cc b/tensorflow/core/common_runtime/direct_session.cc
index 2c4e4c40e95..8ad6ae19afc 100644
--- a/tensorflow/core/common_runtime/direct_session.cc
+++ b/tensorflow/core/common_runtime/direct_session.cc
@@ -511,11 +511,11 @@ Status DirectSession::RunInternal(
                                             model_metadata.version());
           return profiler::TraceMeEncode("SessionRun",
                                          {{"id", step_id},
-                                          {"$r", 1} /*root_event*/,
+                                          {"_r", 1} /*root_event*/,
                                           {"model_id", model_id}});
         } else {
           return profiler::TraceMeEncode(
-              "SessionRun", {{"id", step_id}, {"$r", 1} /*root_event*/});
+              "SessionRun", {{"id", step_id}, {"_r", 1} /*root_event*/});
         }
       },
       profiler::ContextType::kTfExecutor, step_id,
diff --git a/tensorflow/core/common_runtime/eager/kernel_and_device.cc b/tensorflow/core/common_runtime/eager/kernel_and_device.cc
index c3d3d76fac5..1a56cc30510 100644
--- a/tensorflow/core/common_runtime/eager/kernel_and_device.cc
+++ b/tensorflow/core/common_runtime/eager/kernel_and_device.cc
@@ -387,7 +387,7 @@ void KernelAndDeviceFunc::RunAsync(
       // To TraceMeConsumers in ExecutorState::Process/Finish.
       [&] {
         return profiler::TraceMeEncode(
-            "FunctionRun", {{"id", opts->step_id}, {"$r", 1} /*root_event*/});
+            "FunctionRun", {{"id", opts->step_id}, {"_r", 1} /*root_event*/});
       },
       profiler::ContextType::kTfExecutor, opts->step_id,
       profiler::TraceMeLevel::kInfo);
diff --git a/tensorflow/core/distributed_runtime/graph_mgr.cc b/tensorflow/core/distributed_runtime/graph_mgr.cc
index de26990e0e5..dd9633676f6 100644
--- a/tensorflow/core/distributed_runtime/graph_mgr.cc
+++ b/tensorflow/core/distributed_runtime/graph_mgr.cc
@@ -424,7 +424,7 @@ void GraphMgr::ExecuteAsync(const string& handle, const int64 step_id,
       // To TraceMeConsumers in ExecutorState::Process/Finish or RunGraphDone.
       [step_id] {
         return profiler::TraceMeEncode(
-            "RunGraph", {{"id", step_id}, {"$r", 1} /*root_event*/});
+            "RunGraph", {{"id", step_id}, {"_r", 1} /*root_event*/});
       },
       profiler::ContextType::kTfExecutor, step_id,
       profiler::TraceMeLevel::kInfo);
diff --git a/tensorflow/core/profiler/lib/connected_traceme.h b/tensorflow/core/profiler/lib/connected_traceme.h
index 3bb02f25d5b..cbc610af407 100644
--- a/tensorflow/core/profiler/lib/connected_traceme.h
+++ b/tensorflow/core/profiler/lib/connected_traceme.h
@@ -88,8 +88,7 @@ class TraceMeProducer {
     trace_me_.AppendMetadata([&] {
       context_id_ =
           context_id.has_value() ? *context_id : TraceMe::NewActivityId();
-      return TraceMeEncode(
-          {{"$pt", static_cast<int>(context_type)}, {"$p", context_id_}});
+      return TraceMeEncode({{"_pt", context_type}, {"_p", context_id_}});
     });
   }
 
@@ -107,8 +106,7 @@ class TraceMeConsumer {
                   int level = 2)
       : trace_me_(name, level) {
     trace_me_.AppendMetadata([&] {
-      return TraceMeEncode(
-          {{"$ct", static_cast<int>(context_type)}, {"$c", context_id}});
+      return TraceMeEncode({{"_ct", context_type}, {"_c", context_id}});
     });
   }
 
diff --git a/tensorflow/core/profiler/utils/xplane_schema.cc b/tensorflow/core/profiler/utils/xplane_schema.cc
index 9aebcdedd29..c7a2cb6e37e 100644
--- a/tensorflow/core/profiler/utils/xplane_schema.cc
+++ b/tensorflow/core/profiler/utils/xplane_schema.cc
@@ -148,12 +148,12 @@ const StatTypeMap& GetStatTypeMap() {
       {"kpi_name", kKpiName},
       {"kpi_value", kKpiValue},
       // XPlane semantics related.
-      {"$pt", kProducerType},
-      {"$ct", kConsumerType},
-      {"$p", kProducerId},
-      {"$c", kConsumerId},
-      {"$r", kIsRoot},
-      {"$a", kIsAsync},
+      {"_pt", kProducerType},
+      {"_ct", kConsumerType},
+      {"_p", kProducerId},
+      {"_c", kConsumerId},
+      {"_r", kIsRoot},
+      {"_a", kIsAsync},
       // Device trace arguments.
       {"device_id", kDeviceId},
       {"context_id", kContextId},