aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/framework/resource_mgr.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <nobody@tensorflow.org>2016-04-28 21:38:44 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-04-28 22:41:52 -0700
commit8a3defed8412791faa4a48bfbe063119d38485b9 (patch)
treef8a92f6261cd8b9e2c4b66e0d1b5868b0e8d8912 /tensorflow/core/framework/resource_mgr.cc
parentc2c4bd08613465a40653860f4fc98c6fa04d21f0 (diff)
DebugString() for all resources owned by devices.
Change: 121089711
Diffstat (limited to 'tensorflow/core/framework/resource_mgr.cc')
-rw-r--r--tensorflow/core/framework/resource_mgr.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/tensorflow/core/framework/resource_mgr.cc b/tensorflow/core/framework/resource_mgr.cc
index 60425eedb0..daa1075a3d 100644
--- a/tensorflow/core/framework/resource_mgr.cc
+++ b/tensorflow/core/framework/resource_mgr.cc
@@ -20,6 +20,8 @@ limitations under the License.
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/gtl/map_util.h"
#include "tensorflow/core/lib/strings/scanner.h"
+#include "tensorflow/core/lib/strings/stringprintf.h"
+#include "tensorflow/core/platform/demangle.h"
namespace tensorflow {
@@ -41,6 +43,36 @@ void ResourceMgr::Clear() {
containers_.clear();
}
+string ResourceMgr::DebugString() const {
+ mutex_lock l(mu_);
+ struct Line {
+ const string* container;
+ const string type;
+ const string* resource;
+ const string detail;
+ };
+ std::vector<Line> lines;
+ for (const auto& p : containers_) {
+ const string& container = p.first;
+ for (const auto& q : *p.second) {
+ const Key& key = q.first;
+ const char* type = key.first.name();
+ const string& resource = key.second;
+ Line l{&container, port::Demangle(type), &resource,
+ q.second->DebugString()};
+ lines.push_back(l);
+ }
+ }
+ std::vector<string> text;
+ for (const Line& line : lines) {
+ text.push_back(strings::Printf(
+ "%-20s | %-40s | %-40s | %-s", line.container->c_str(),
+ line.type.c_str(), line.resource->c_str(), line.detail.c_str()));
+ }
+ std::sort(text.begin(), text.end());
+ return str_util::Join(text, "\n");
+}
+
Status ResourceMgr::DoCreate(const string& container, TypeIndex type,
const string& name, ResourceBase* resource) {
{