aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/util/tensor_slice_set.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2016-08-15 19:34:13 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-08-16 09:56:16 -0700
commit0f7c3b0a886300c332fa66df58b4d4a5d477a4d9 (patch)
tree1480644be31cbbca7d64e44dba12a018948c330a /tensorflow/core/util/tensor_slice_set.cc
parent2c5718c133d36440f3dfd005a5d199db342faab8 (diff)
Update generated Python Op docs.
Change: 130356783
Diffstat (limited to 'tensorflow/core/util/tensor_slice_set.cc')
-rw-r--r--tensorflow/core/util/tensor_slice_set.cc29
1 files changed, 29 insertions, 0 deletions
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<string, TensorSliceSet*>* 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