From 0f7c3b0a886300c332fa66df58b4d4a5d477a4d9 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 15 Aug 2016 19:34:13 -0800 Subject: Update generated Python Op docs. Change: 130356783 --- tensorflow/core/util/tensor_slice_set.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tensorflow/core/util/tensor_slice_set.cc') diff --git a/tensorflow/core/util/tensor_slice_set.cc b/tensorflow/core/util/tensor_slice_set.cc index 0408d261f5..d4b9a4087c 100644 --- a/tensorflow/core/util/tensor_slice_set.cc +++ b/tensorflow/core/util/tensor_slice_set.cc @@ -168,6 +168,35 @@ bool TensorSliceSet::QueryMeta( } } +Status RegisterTensorSlice( + const string& name, const TensorShape& shape, DataType type, + const string& tag, const TensorSlice& slice, + std::unordered_map* tensor_slices) { + DCHECK_NE(tensor_slices, nullptr); + TensorSliceSet* tss = gtl::FindPtrOrNull(*tensor_slices, name); + // Create a tensor slice set if needed + if (!tss) { + tss = new TensorSliceSet(shape, type); + tensor_slices->insert(std::make_pair(name, tss)); + } else { + // Check if the shapes match + TensorShape tss_shape(tss->shape()); + if (!shape.IsSameSize(tss_shape)) { + return errors::Internal("Incompatible tensor shapes detected for tensor ", + name, ": existing = ", tss_shape.DebugString(), + ", new = ", shape.DebugString()); + } + if (type != tss->type()) { + return errors::Internal("Incompatible tensor types detected for tensor ", + name, ": existing = ", + DataTypeString(tss->type()), ", new = ", + DataTypeString(type)); + } + } + // Register the tensor slices without the actual data. + return tss->Register(slice, tag, nullptr); +} + } // namespace checkpoint } // namespace tensorflow -- cgit v1.2.3