13 std::condition_variable &sharedCV,
const std::vector<std::size_t> &vecSizes,
14 std::size_t numEntries,
bool dropRemainder)
15 : fBatchSize(batchSize),
20 fNumEntries(numEntries),
21 fDropRemainder(dropRemainder)
35 std::lock_guard<std::mutex> lock(
fLock);
50 std::lock_guard<std::mutex> lock(
fLock);
63 std::lock_guard<std::mutex> lock(
fLock);
90 const std::vector<std::size_t> &permutation,
93 auto batch = std::make_unique<RFlat2DMatrix>();
104 std::unique_lock<std::mutex> lock(
fLock);
134 std::size_t beginRow, std::size_t endRow,
bool isLastBatch)
136 std::size_t chunkSize = endRow - beginRow;
137 std::size_t numBatches = chunkSize /
fBatchSize;
140 std::vector<std::unique_ptr<RFlat2DMatrix>> batches;
143 for (std::size_t i = 0; i < numBatches; i++) {
148 for (std::size_t row = beginRow + numBatches *
fBatchSize; row < endRow;) {
171 std::lock_guard<std::mutex> lock(
fLock);
172 for (
auto &batch : batches) {
RFlat2DMatrix GetBatch()
Loading the batch from the queue.
std::size_t fNumFullBatches
std::queue< std::unique_ptr< RFlat2DMatrix > > fBatchQueue
std::unique_ptr< RFlat2DMatrix > CreateBatch(const RFlat2DMatrix &chunkTensor, const std::vector< std::size_t > &permutation, std::size_t firstRow)
Return a batch of data as a unique pointer.
void CreateBatches(const RFlat2DMatrix &chunkTensor, const std::vector< std::size_t > &permutation, std::size_t beginRow, std::size_t endRow, bool isLastBatch)
Creating the batches from a chunk and add them to the queue.
void RecalculateBatchCounts(std::size_t numEntries)
Recalculate batch counts from the given number of entries.
void Reset()
Reset the batchloader state.
std::size_t fLeftoverBatchSize
void Activate()
Activate the batchloader. This means that batches can be created and loaded.
void MarkProducerDone()
Signal that the producer has finished pushing all batches for this epoch.
void DeActivate()
DeActivate the batchloader.
std::unique_ptr< RFlat2DMatrix > fPrimaryLeftoverBatch
std::vector< std::size_t > fVecSizes
std::vector< std::string > fCols
std::unique_ptr< RFlat2DMatrix > fCurrentBatch
RBatchLoader(std::size_t batchSize, const std::vector< std::string > &cols, std::mutex &sharedMutex, std::condition_variable &sharedCV, const std::vector< std::size_t > &vecSizes={}, std::size_t numEntries=0, bool dropRemainder=false)
std::condition_variable & fCV
static void AppendRows(RFlat2DMatrix &Dest, const RFlat2DMatrix &Tensor, const std::vector< std::size_t > &permutation, std::size_t begin, std::size_t end)
Wrapper around ROOT::RVec<float> representing a 2D matrix.