diff options
author | Mingsheng Hong <hongm@google.com> | 2018-03-21 17:38:04 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-03-21 17:41:09 -0700 |
commit | 8e4e9f7ceaa78f76b7f0aaa7a607e80e67f0d912 (patch) | |
tree | 2c6990449eda2f6e13b7ff7dc140ec360dac0b5e /tensorflow/c/c_api_experimental.cc | |
parent | 637b090ea0a5029805ba5e1dcf41c3b57d944ae4 (diff) |
Added an experimental C API to dump TF_Graph in a human-readable format, for
debugging purposes.
PiperOrigin-RevId: 189997099
Diffstat (limited to 'tensorflow/c/c_api_experimental.cc')
-rw-r--r-- | tensorflow/c/c_api_experimental.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tensorflow/c/c_api_experimental.cc b/tensorflow/c/c_api_experimental.cc index eb17e16d3e..34b9dec3ee 100644 --- a/tensorflow/c/c_api_experimental.cc +++ b/tensorflow/c/c_api_experimental.cc @@ -483,3 +483,13 @@ void TF_ShutdownTPUExecution(TF_Session* session, TF_Output shutdown_node, /*targets*/ &shutdown_node.oper, /*ntargets*/ 1, /*run_metadata*/ nullptr, status); } + +TF_CAPI_EXPORT extern const char* TF_GraphDebugString(TF_Graph* graph, + size_t* len) { + tensorflow::mutex_lock c(graph->mu); + const auto& debug_str = graph->graph.ToGraphDefDebug().DebugString(); + *len = debug_str.size(); + char* ret = static_cast<char*>(malloc(*len + 1)); + memcpy(ret, debug_str.c_str(), *len + 1); + return ret; +} |