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

Method BuildTensorSlice

tensorflow/core/framework/tensor_slice.cc:50–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50Status TensorSlice::BuildTensorSlice(const TensorSliceProto& proto,
51 TensorSlice* output) {
52 output->Clear();
53 output->starts_.reserve(proto.extent_size());
54 output->lengths_.reserve(proto.extent_size());
55 for (const auto& e : proto.extent()) {
56 int64_t l = GetExtentLength(e);
57 if (e.start() != 0 || l != kFullExtent) {
58 if (e.start() < 0 || l <= 0) {
59 return errors::InvalidArgument(
60 "Expected non-negative start and positive length but got start = ",
61 e.start(), ", length = ", l, ": extent = ", e.ShortDebugString());
62 }
63 // Calculating the extent end must not cause signed integer overflow.
64 if (static_cast<uint64_t>(e.start()) + static_cast<uint64_t>(e.length()) >
65 std::numeric_limits<int64_t>::max()) {
66 return errors::InvalidArgument(
67 "Extent end exceeds the maximum possible size: extent = ",
68 e.ShortDebugString());
69 }
70 }
71 output->starts_.push_back(e.start());
72 output->lengths_.push_back(l);
73 }
74
75 return Status::OK();
76}
77
78Status TensorSlice::Parse(const string& str, TensorSlice* slice) {
79 std::vector<string> items = str_util::Split(str, ':', str_util::SkipEmpty());

Callers

nothing calls this directly

Calls 8

InvalidArgumentFunction · 0.85
maxFunction · 0.50
ClearMethod · 0.45
reserveMethod · 0.45
startMethod · 0.45
ShortDebugStringMethod · 0.45
lengthMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected