Bounds are inclusive. Trailing axes the region does not name span their full extent.
252{
253 const size_t named = region.start_coordinates.size();
254 if (named == 0 || named != region.end_coordinates.size() || named >
shape.size())
255 return std::nullopt;
256
257 std::vector<uint64_t> origin(
shape.size(), 0);
258 std::vector<uint64_t> extent =
shape;
259 for (size_t axis = 0; axis < named; ++axis) {
260 const uint64_t first = region.start_coordinates[axis];
261 const uint64_t last = region.end_coordinates[axis];
262 if (first > last || last >=
shape[axis])
263 return std::nullopt;
264 origin[axis] = first;
265 extent[axis] = last - first + 1;
266 }
267 return window(origin, extent);
268}
std::optional< TensorSpec > window(std::span< const uint64_t > origin, std::span< const uint64_t > extent) const
Spec of the box that starts at origin and spans extent elements per axis.
std::vector< uint64_t > shape