aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/framework/resource_mgr.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/core/framework/resource_mgr.cc')
-rw-r--r--tensorflow/core/framework/resource_mgr.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/tensorflow/core/framework/resource_mgr.cc b/tensorflow/core/framework/resource_mgr.cc
index c3666f7ab9..4365a861e5 100644
--- a/tensorflow/core/framework/resource_mgr.cc
+++ b/tensorflow/core/framework/resource_mgr.cc
@@ -24,6 +24,34 @@ limitations under the License.
#include "tensorflow/core/platform/demangle.h"
namespace tensorflow {
+ResourceHandle MakeResourceHandle(OpKernelContext* ctx, const string& container,
+ const string& name,
+ const TypeIndex& type_index) {
+ ResourceHandle result;
+ result.set_device(ctx->device()->attributes().name());
+ string actual_container;
+ if (!container.empty()) {
+ actual_container = container;
+ } else {
+ actual_container = ctx->resource_manager()->default_container();
+ }
+ result.set_container(actual_container);
+ result.set_name(name);
+ result.set_hash_code(type_index.hash_code());
+ result.set_maybe_type_name(type_index.name());
+ return result;
+}
+
+Status MakeResourceHandleToOutput(OpKernelContext* context, int output_index,
+ const string& container, const string& name,
+ const TypeIndex& type_index) {
+ Tensor* handle;
+ TF_RETURN_IF_ERROR(
+ context->allocate_output(output_index, TensorShape({}), &handle));
+ handle->scalar<ResourceHandle>()() =
+ MakeResourceHandle(context, container, name, type_index);
+ return Status::OK();
+}
namespace internal {