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

Function ConsecutiveSegments

tensorflow/compiler/xla/shape_util.cc:1487–1495  ·  view source on GitHub ↗

Returns the indices of the first elements of all consecutive subarrays of the given array. For example: ConsecutiveSegments({m, m+1, m+2, n, k, k+1}) = {0, 3, 4}

Source from the content-addressed store, hash-verified

1485// given array. For example:
1486// ConsecutiveSegments({m, m+1, m+2, n, k, k+1}) = {0, 3, 4}
1487static std::vector<size_t> ConsecutiveSegments(absl::Span<const int64> xs) {
1488 std::vector<size_t> is = {0};
1489 for (size_t i = 1; i < xs.size(); ++i) {
1490 if (1 != xs[i] - xs[i - 1]) {
1491 is.push_back(i);
1492 }
1493 }
1494 return is;
1495}
1496
1497// Merges the sequences of dimensions of the given shape which start at the
1498// given indices `segs`.

Callers 1

FindTranspose021Method · 0.85

Calls 2

sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected