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

Method SliceTensorShape

tensorflow/core/framework/tensor_slice.cc:270–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270Status TensorSlice::SliceTensorShape(const TensorShape& shape,
271 TensorShape* result_shape) const {
272 result_shape->Clear();
273 // Mismatching ranks: we can't apply the slice at all.
274 if (shape.dims() != dims()) {
275 return errors::Internal("Mismatching ranks: shape = ", shape.DebugString(),
276 ", slice = ", DebugString());
277 }
278 for (int d = 0; d < dims(); ++d) {
279 if (IsFullAt(d)) {
280 result_shape->AddDim(shape.dim_size(d));
281 } else {
282 // Check if the extent applies to the dimension
283 if (end(d) <= shape.dim_size(d)) {
284 // Yes: the end is within the range of the dim -- we adjust the result
285 // shape so that its size along this dimension is the length of the
286 // slice.
287 result_shape->AddDim(length(d));
288 } else {
289 // The extent doesn't apply to the dimension
290 result_shape->Clear();
291 return errors::Internal("Extent in dimension ", d,
292 " out of bounds: shape = ", shape.DebugString(),
293 ", slice = ", DebugString());
294 }
295 }
296 }
297 // If we are here, we have successfully applied the shape.
298 return Status::OK();
299}
300
301const int64 TensorSlice::kFullExtent = -1;
302

Callers 9

TESTFunction · 0.80
ComputeMethod · 0.80
CopySliceDataMethod · 0.80
ParseShapeAndSliceFunction · 0.80
RegisterMethod · 0.80
QueryMetaMethod · 0.80
AddMethod · 0.80
IsFullSliceFunction · 0.80

Calls 8

dimsFunction · 0.85
InternalFunction · 0.85
DebugStringFunction · 0.70
ClearMethod · 0.45
dimsMethod · 0.45
DebugStringMethod · 0.45
AddDimMethod · 0.45
dim_sizeMethod · 0.45

Tested by 1

TESTFunction · 0.64