| 50 | } |
| 51 | |
| 52 | Sample Batch::get(int64_t idx) const { |
| 53 | if (idx < 0 || idx >= size_) { |
| 54 | throw std::runtime_error("Batch: index out of range"); |
| 55 | } |
| 56 | auto batch_size = |
| 57 | (batchSize_ ? std::min(batchSize_, op_->size() - idx * batchSize_) |
| 58 | : batchSizes_[idx]); |
| 59 | auto batch_offset = (batchSize_ ? idx * batchSize_ : batchOffsets_[idx]); |
| 60 | std::vector<Sample> samples(batch_size); |
| 61 | for (int64_t i = 0; i < batch_size; i++) { |
| 62 | samples[i] = op_->get(batch_offset + i); |
| 63 | } |
| 64 | return core::merge_batch(samples, padValues_, batchDims_); |
| 65 | } |
| 66 | |
| 67 | int64_t Batch::size() const { |
| 68 | return size_; |
nothing calls this directly
no test coverage detected