aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/framework/log_memory.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <nobody@tensorflow.org>2016-04-21 10:08:01 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-04-21 11:13:27 -0700
commit3883578ebff0e8f901386d6f2b5870de517de4a1 (patch)
treef40fff6794ad2ddcb0e891b9965a53201feacc4c /tensorflow/core/framework/log_memory.cc
parent52500e395d526ac932a6de46ecec1ad45082f43c (diff)
Change tensorflow code to use proto_text for DebugString and ShortDebugString
calls, for call sites that are needed on android. Also changed protobuf.h to use MessageLite. Change: 120464266
Diffstat (limited to 'tensorflow/core/framework/log_memory.cc')
-rw-r--r--tensorflow/core/framework/log_memory.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/tensorflow/core/framework/log_memory.cc b/tensorflow/core/framework/log_memory.cc
index 43756bf8dd..b5dfbaa257 100644
--- a/tensorflow/core/framework/log_memory.cc
+++ b/tensorflow/core/framework/log_memory.cc
@@ -16,6 +16,7 @@ limitations under the License.
#include "tensorflow/core/framework/log_memory.h"
#include "tensorflow/core/framework/log_memory.pb.h"
+#include "tensorflow/core/framework/log_memory.pb_text.h"
namespace tensorflow {
@@ -23,17 +24,20 @@ const string LogMemory::kLogMemoryLabel = "__LOG_MEMORY__";
bool LogMemory::IsEnabled() { return VLOG_IS_ON(1); }
-void LogMemory::OutputToLog(const protobuf::Message& proto) {
- protobuf::TextFormat::Printer printer;
- printer.SetExpandAny(true);
- printer.SetSingleLineMode(true);
- string contents_string;
- printer.PrintToString(proto, &contents_string);
+namespace {
- LOG(INFO) << kLogMemoryLabel << " " << proto.GetDescriptor()->name() << " { "
- << contents_string << " }";
+// Write the proto entry to LOG(INFO).
+template <typename T>
+void OutputToLog(const T& proto) {
+ string type_name = proto.GetTypeName();
+ const int index = type_name.find_last_of(".");
+ if (index != string::npos) type_name = type_name.substr(index + 1);
+ LOG(INFO) << LogMemory::kLogMemoryLabel << " " << type_name << " { "
+ << ProtoShortDebugString(proto) << " }";
}
+} // namespace
+
void LogMemory::RecordStep(const int64 step_id, const string& handle) {
MemoryLogStep step;
step.set_step_id(step_id);