MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / RegisterTensorSlice

Function RegisterTensorSlice

tensorflow/core/util/tensor_slice_set.cc:112–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112Status RegisterTensorSlice(
113 const string& name, const TensorShape& shape, DataType type,
114 const string& tag, const TensorSlice& slice,
115 std::unordered_map<string, TensorSliceSet*>* tensor_slices) {
116 DCHECK_NE(tensor_slices, nullptr);
117 TensorSliceSet* tss = gtl::FindPtrOrNull(*tensor_slices, name);
118 // Create a tensor slice set if needed
119 if (!tss) {
120 tss = new TensorSliceSet(shape, type);
121 tensor_slices->insert(std::make_pair(name, tss));
122 } else {
123 // Check if the shapes match
124 const TensorShape& tss_shape(tss->shape());
125 if (!shape.IsSameSize(tss_shape)) {
126 return errors::Internal("Incompatible tensor shapes detected for tensor ",
127 name, ": existing = ", tss_shape.DebugString(),
128 ", new = ", shape.DebugString());
129 }
130 if (type != tss->type()) {
131 return errors::Internal("Incompatible tensor types detected for tensor ",
132 name,
133 ": existing = ", DataTypeString(tss->type()),
134 ", new = ", DataTypeString(type));
135 }
136 }
137 // Register the tensor slices without the actual data.
138 return tss->Register(slice, tag);
139}
140
141} // namespace checkpoint
142

Callers 2

LoadShardMethod · 0.85
GetSliceValueMethod · 0.85

Calls 8

FindPtrOrNullFunction · 0.85
InternalFunction · 0.85
typeMethod · 0.65
DataTypeStringFunction · 0.50
insertMethod · 0.45
IsSameSizeMethod · 0.45
DebugStringMethod · 0.45
RegisterMethod · 0.45

Tested by

no test coverage detected