diff options
author | Derek Murray <mrry@google.com> | 2018-09-12 09:29:45 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-09-12 09:33:33 -0700 |
commit | 1c4fceab7dc09cab18c0def098320d6c52d2e514 (patch) | |
tree | 7d38e14e61c952abaf1f286ddadd7d6302b517f5 /tensorflow/core/framework | |
parent | 6b507a6de855a6f988100904229b7f46a5652b88 (diff) |
Change HandleFromInput() to return a `const ResourceHandle&` and avoid copying that type.
This avoids unnecessary string copies and deallocations in the ReadVariableOp, and similar ops.
PiperOrigin-RevId: 212652588
Diffstat (limited to 'tensorflow/core/framework')
-rw-r--r-- | tensorflow/core/framework/resource_mgr.cc | 2 | ||||
-rw-r--r-- | tensorflow/core/framework/resource_mgr.h | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/tensorflow/core/framework/resource_mgr.cc b/tensorflow/core/framework/resource_mgr.cc index 0a19861efd..ebdaaec153 100644 --- a/tensorflow/core/framework/resource_mgr.cc +++ b/tensorflow/core/framework/resource_mgr.cc @@ -271,7 +271,7 @@ string ContainerInfo::DebugString() const { "]"); } -ResourceHandle HandleFromInput(OpKernelContext* ctx, int input) { +const ResourceHandle& HandleFromInput(OpKernelContext* ctx, int input) { return ctx->input(input).flat<ResourceHandle>()(0); } diff --git a/tensorflow/core/framework/resource_mgr.h b/tensorflow/core/framework/resource_mgr.h index f8a587c9b5..f87dc1e39d 100644 --- a/tensorflow/core/framework/resource_mgr.h +++ b/tensorflow/core/framework/resource_mgr.h @@ -79,7 +79,7 @@ class ResourceBase : public core::RefCounted { virtual string DebugString() = 0; // Returns memory used by this resource. - virtual int64 MemoryUsed() const { return 0; }; + virtual int64 MemoryUsed() const { return 0; } }; // Container used for per-step resources. @@ -234,7 +234,7 @@ ResourceHandle MakePerStepResourceHandle(OpKernelContext* ctx, const string& name); // Returns a resource handle from a numbered op input. -ResourceHandle HandleFromInput(OpKernelContext* ctx, int input); +const ResourceHandle& HandleFromInput(OpKernelContext* ctx, int input); Status HandleFromInput(OpKernelContext* ctx, StringPiece input, ResourceHandle* handle); |