Copy segments into separate tensors.
A segment is the box that starts at offset_in_region inside its source region and spans segment_size per axis. A cached segment returns its cached tensor, stored under tensor_cache().
118{
119 std::vector<TensorData> result;
120 result.reserve(segments.size());
121
122 for (const auto& segment : segments) {
123 if (segment.is_cached) {
124 if (
const TensorData* held = segment.cache.get(
tensor_cache())) {
125 result.push_back(*held);
126 continue;
127 }
128 }
129
130 const auto& region = segment.source_region;
131 const size_t rank = region.start_coordinates.size();
132 if (rank == 0 || region.end_coordinates.size() != rank
133 || segment.offset_in_region.size() != rank || segment.segment_size.size() != rank)
134 continue;
135
136 Region box;
137 box.start_coordinates.resize(rank);
138 box.end_coordinates.resize(rank);
139 bool valid = true;
140 for (size_t axis = 0; axis < rank && valid; ++axis) {
141 const uint64_t source_start = region.start_coordinates[axis];
142 const uint64_t source_end = region.end_coordinates[axis];
143 const uint64_t offset = segment.offset_in_region[axis];
144 const uint64_t
count = segment.segment_size[axis];
145
146 valid = source_start <= source_end && offset <= source_end - source_start &&
count != 0;
147 if (!valid)
148 break;
149 const uint64_t start = source_start + offset;
150 valid =
count - 1 <= source_end - start;
151 box.start_coordinates[axis] = start;
152 box.end_coordinates[axis] = start +
count - 1;
153 }
154 if (!valid)
155 continue;
156
158 if (!copied.empty())
159 result.push_back(std::move(copied.front()));
160 }
161 return result;
162}
std::vector< TensorData > get_region_data(const Region ®ion) const override
Copy the box a Region selects into an owning dense tensor.
const Facet< TensorData > & tensor_cache()
Key for a cached TensorData held by a RegionSegment.
std::vector< double > count(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Sample count per window (as double for pipeline uniformity).