Logo ROOT   6.08/07
Reference Guide
List of all members | Public Member Functions | Private Types | Private Attributes | List of all members
TMVA::DNN::TDataLoader< Data_t, AArchitecture > Class Template Reference

template<typename Data_t, typename AArchitecture>
class TMVA::DNN::TDataLoader< Data_t, AArchitecture >

TDataLoader.

Service class managing the streaming of the training data from the input data type to the accelerator device or the CPU. A TDataLoader object manages a number of host and device buffer pairs that are used in a round-robin manner for the transfer of batches to the device.

Each TDataLoader object has an associated batch size and a number of total samples in the dataset. One epoch is the number of buffers required to transfer the complete training set. Using the begin() and end() member functions allows the user to iterate over the batches in one epoch.

Template Parameters
ADataThe input data type.
AArchitectureThe achitecture class of the underlying architecture.

Definition at line 72 of file DataLoader.h.

Public Member Functions

 TDataLoader (const Data_t &data, size_t nSamples, size_t batchSize, size_t nInputFeatures, size_t nOutputFeatures, size_t nStreams=1)
 
 TDataLoader (const TDataLoader &)=default
 
 TDataLoader (TDataLoader &&)=default
 
BatchIterator_t begin ()
 
template<>
void CopyInput (TCpuBuffer< Real_t > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
template<>
void CopyInput (TCpuBuffer< Double_t > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
template<>
void CopyInput (TCudaHostBuffer< float > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
template<>
void CopyInput (TCpuBuffer< Double_t > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
void CopyInput (HostBuffer_t &buffer, IndexIterator_t begin, size_t batchSize)
 Copy input matrix into the given host buffer. More...
 
template<>
void CopyInput (TCudaHostBuffer< float > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
template<>
void CopyInput (TCpuBuffer< Real_t > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
template<>
void CopyInput (TCudaHostBuffer< double > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
template<>
void CopyInput (TCudaHostBuffer< double > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
template<>
void CopyOutput (TCpuBuffer< Real_t > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
template<>
void CopyOutput (TCpuBuffer< Double_t > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
void CopyOutput (HostBuffer_t &buffer, IndexIterator_t begin, size_t batchSize)
 Copy output matrix into the given host buffer. More...
 
template<>
void CopyOutput (TCudaHostBuffer< float > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
template<>
void CopyOutput (TCpuBuffer< Double_t > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
template<>
void CopyOutput (TCudaHostBuffer< float > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
template<>
void CopyOutput (TCpuBuffer< Real_t > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
template<>
void CopyOutput (TCudaHostBuffer< double > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
template<>
void CopyOutput (TCudaHostBuffer< double > &buffer, IndexIterator_t sampleIterator, size_t batchSize)
 
BatchIterator_t end ()
 
TBatch< AArchitecture > GetBatch ()
 Return the next batch from the training set. More...
 
TDataLoaderoperator= (const TDataLoader &)=default
 
TDataLoaderoperator= (TDataLoader &&)=default
 
void Shuffle ()
 Shuffle the order of the samples in the batch. More...
 

Private Types

using BatchIterator_t = TBatchIterator< Data_t, AArchitecture >
 
using DeviceBuffer_t = typename AArchitecture::DeviceBuffer_t
 
using HostBuffer_t = typename AArchitecture::HostBuffer_t
 
using Matrix_t = typename AArchitecture::Matrix_t
 

Private Attributes

size_t fBatchIndex
 
size_t fBatchSize
 
const Data_t & fData
 
std::vector< DeviceBuffer_tfDeviceBuffers
 
std::vector< HostBuffer_tfHostBuffers
 
size_t fNInputFeatures
 
size_t fNOutputFeatures
 
size_t fNSamples
 
size_t fNStreams
 Number of buffer pairs. More...
 
std::vector< size_t > fSampleIndices
 Ordering of the samples in the epoch. More...
 

#include <TMVA/DNN/DataLoader.h>

Member Typedef Documentation

◆ BatchIterator_t

template<typename Data_t, typename AArchitecture>
using TMVA::DNN::TDataLoader< Data_t, AArchitecture >::BatchIterator_t = TBatchIterator<Data_t, AArchitecture>
private

Definition at line 128 of file DataLoader.h.

◆ DeviceBuffer_t

template<typename Data_t, typename AArchitecture>
using TMVA::DNN::TDataLoader< Data_t, AArchitecture >::DeviceBuffer_t = typename AArchitecture::DeviceBuffer_t
private

Definition at line 126 of file DataLoader.h.

◆ HostBuffer_t

template<typename Data_t, typename AArchitecture>
using TMVA::DNN::TDataLoader< Data_t, AArchitecture >::HostBuffer_t = typename AArchitecture::HostBuffer_t
private

Definition at line 125 of file DataLoader.h.

◆ Matrix_t

template<typename Data_t, typename AArchitecture>
using TMVA::DNN::TDataLoader< Data_t, AArchitecture >::Matrix_t = typename AArchitecture::Matrix_t
private

Definition at line 127 of file DataLoader.h.

Constructor & Destructor Documentation

◆ TDataLoader() [1/3]

template<typename Data_t , typename AArchitecture >
TMVA::DNN::TDataLoader< Data_t, AArchitecture >::TDataLoader ( const Data_t &  data,
size_t  nSamples,
size_t  batchSize,
size_t  nInputFeatures,
size_t  nOutputFeatures,
size_t  nStreams = 1 
)

Definition at line 192 of file DataLoader.h.

◆ TDataLoader() [2/3]

template<typename Data_t, typename AArchitecture>
TMVA::DNN::TDataLoader< Data_t, AArchitecture >::TDataLoader ( const TDataLoader< Data_t, AArchitecture > &  )
default

◆ TDataLoader() [3/3]

template<typename Data_t, typename AArchitecture>
TMVA::DNN::TDataLoader< Data_t, AArchitecture >::TDataLoader ( TDataLoader< Data_t, AArchitecture > &&  )
default

Member Function Documentation

◆ begin()

template<typename Data_t, typename AArchitecture>
BatchIterator_t TMVA::DNN::TDataLoader< Data_t, AArchitecture >::begin ( )
inline

Definition at line 160 of file DataLoader.h.

◆ CopyInput() [1/9]

template<>
void TMVA::DNN::TDataLoader< MatrixInput_t, TCpu< Real_t > >::CopyInput ( TCpuBuffer< Real_t > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 72 of file CpuBuffer.cxx.

◆ CopyInput() [2/9]

template<>
void TMVA::DNN::TDataLoader< MatrixInput_t, TCpu< Double_t > >::CopyInput ( TCpuBuffer< Double_t > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 112 of file CpuBuffer.cxx.

◆ CopyInput() [3/9]

template<>
void TMVA::DNN::TDataLoader< MatrixInput_t, TCuda< float > >::CopyInput ( TCudaHostBuffer< float > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 145 of file CudaBuffers.cxx.

◆ CopyInput() [4/9]

template<>
void TMVA::DNN::TDataLoader< TMVAInput_t, TCpu< Double_t > >::CopyInput ( TCpuBuffer< Double_t > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 152 of file CpuBuffer.cxx.

◆ CopyInput() [5/9]

template<typename Data_t, typename AArchitecture>
void TMVA::DNN::TDataLoader< Data_t, AArchitecture >::CopyInput ( HostBuffer_t buffer,
IndexIterator_t  begin,
size_t  batchSize 
)

Copy input matrix into the given host buffer.

Function to be specialized by the architecture-specific backend.

◆ CopyInput() [6/9]

template<>
void TMVA::DNN::TDataLoader< TMVAInput_t, TCuda< float > >::CopyInput ( TCudaHostBuffer< float > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 185 of file CudaBuffers.cxx.

◆ CopyInput() [7/9]

template<>
void TMVA::DNN::TDataLoader< TMVAInput_t, TCpu< Real_t > >::CopyInput ( TCpuBuffer< Real_t > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 211 of file CpuBuffer.cxx.

◆ CopyInput() [8/9]

template<>
void TMVA::DNN::TDataLoader< MatrixInput_t, TCuda< double > >::CopyInput ( TCudaHostBuffer< double > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 244 of file CudaBuffers.cxx.

◆ CopyInput() [9/9]

template<>
void TMVA::DNN::TDataLoader< TMVAInput_t, TCuda< double > >::CopyInput ( TCudaHostBuffer< double > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 284 of file CudaBuffers.cxx.

◆ CopyOutput() [1/9]

template<>
void TMVA::DNN::TDataLoader< MatrixInput_t, TCpu< Real_t > >::CopyOutput ( TCpuBuffer< Real_t > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 92 of file CpuBuffer.cxx.

◆ CopyOutput() [2/9]

template<>
void TMVA::DNN::TDataLoader< MatrixInput_t, TCpu< Double_t > >::CopyOutput ( TCpuBuffer< Double_t > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 132 of file CpuBuffer.cxx.

◆ CopyOutput() [3/9]

template<typename Data_t, typename AArchitecture>
void TMVA::DNN::TDataLoader< Data_t, AArchitecture >::CopyOutput ( HostBuffer_t buffer,
IndexIterator_t  begin,
size_t  batchSize 
)

Copy output matrix into the given host buffer.

Function to be specialized by the architecture-spcific backend.

◆ CopyOutput() [4/9]

template<>
void TMVA::DNN::TDataLoader< MatrixInput_t, TCuda< float > >::CopyOutput ( TCudaHostBuffer< float > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 165 of file CudaBuffers.cxx.

◆ CopyOutput() [5/9]

template<>
void TMVA::DNN::TDataLoader< TMVAInput_t, TCpu< Double_t > >::CopyOutput ( TCpuBuffer< Double_t > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 174 of file CpuBuffer.cxx.

◆ CopyOutput() [6/9]

template<>
void TMVA::DNN::TDataLoader< TMVAInput_t, TCuda< float > >::CopyOutput ( TCudaHostBuffer< float > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 207 of file CudaBuffers.cxx.

◆ CopyOutput() [7/9]

template<>
void TMVA::DNN::TDataLoader< TMVAInput_t, TCpu< Real_t > >::CopyOutput ( TCpuBuffer< Real_t > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 233 of file CpuBuffer.cxx.

◆ CopyOutput() [8/9]

template<>
void TMVA::DNN::TDataLoader< MatrixInput_t, TCuda< double > >::CopyOutput ( TCudaHostBuffer< double > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 264 of file CudaBuffers.cxx.

◆ CopyOutput() [9/9]

template<>
void TMVA::DNN::TDataLoader< TMVAInput_t, TCuda< double > >::CopyOutput ( TCudaHostBuffer< double > &  buffer,
IndexIterator_t  sampleIterator,
size_t  batchSize 
)

Definition at line 306 of file CudaBuffers.cxx.

◆ end()

template<typename Data_t, typename AArchitecture>
BatchIterator_t TMVA::DNN::TDataLoader< Data_t, AArchitecture >::end ( )
inline

Definition at line 161 of file DataLoader.h.

◆ GetBatch()

template<typename Data_t , typename AArchitecture >
TBatch< AArchitecture > TMVA::DNN::TDataLoader< Data_t, AArchitecture >::GetBatch ( )

Return the next batch from the training set.

The TDataLoader object keeps an internal counter that cycles over the batches in the training set.

Definition at line 217 of file DataLoader.h.

◆ operator=() [1/2]

template<typename Data_t, typename AArchitecture>
TDataLoader& TMVA::DNN::TDataLoader< Data_t, AArchitecture >::operator= ( const TDataLoader< Data_t, AArchitecture > &  )
default

◆ operator=() [2/2]

template<typename Data_t, typename AArchitecture>
TDataLoader& TMVA::DNN::TDataLoader< Data_t, AArchitecture >::operator= ( TDataLoader< Data_t, AArchitecture > &&  )
default

◆ Shuffle()

template<typename Data_t , typename AArchitecture >
void TMVA::DNN::TDataLoader< Data_t, AArchitecture >::Shuffle ( )

Shuffle the order of the samples in the batch.

The shuffling is indirect, i.e. only the indices are shuffled. No input data is moved by this routine.

Definition at line 252 of file DataLoader.h.

Member Data Documentation

◆ fBatchIndex

template<typename Data_t, typename AArchitecture>
size_t TMVA::DNN::TDataLoader< Data_t, AArchitecture >::fBatchIndex
private

Definition at line 136 of file DataLoader.h.

◆ fBatchSize

template<typename Data_t, typename AArchitecture>
size_t TMVA::DNN::TDataLoader< Data_t, AArchitecture >::fBatchSize
private

Definition at line 133 of file DataLoader.h.

◆ fData

template<typename Data_t, typename AArchitecture>
const Data_t& TMVA::DNN::TDataLoader< Data_t, AArchitecture >::fData
private

Definition at line 130 of file DataLoader.h.

◆ fDeviceBuffers

template<typename Data_t, typename AArchitecture>
std::vector<DeviceBuffer_t> TMVA::DNN::TDataLoader< Data_t, AArchitecture >::fDeviceBuffers
private

Definition at line 139 of file DataLoader.h.

◆ fHostBuffers

template<typename Data_t, typename AArchitecture>
std::vector<HostBuffer_t> TMVA::DNN::TDataLoader< Data_t, AArchitecture >::fHostBuffers
private

Definition at line 140 of file DataLoader.h.

◆ fNInputFeatures

template<typename Data_t, typename AArchitecture>
size_t TMVA::DNN::TDataLoader< Data_t, AArchitecture >::fNInputFeatures
private

Definition at line 134 of file DataLoader.h.

◆ fNOutputFeatures

template<typename Data_t, typename AArchitecture>
size_t TMVA::DNN::TDataLoader< Data_t, AArchitecture >::fNOutputFeatures
private

Definition at line 135 of file DataLoader.h.

◆ fNSamples

template<typename Data_t, typename AArchitecture>
size_t TMVA::DNN::TDataLoader< Data_t, AArchitecture >::fNSamples
private

Definition at line 132 of file DataLoader.h.

◆ fNStreams

template<typename Data_t, typename AArchitecture>
size_t TMVA::DNN::TDataLoader< Data_t, AArchitecture >::fNStreams
private

Number of buffer pairs.

Definition at line 138 of file DataLoader.h.

◆ fSampleIndices

template<typename Data_t, typename AArchitecture>
std::vector<size_t> TMVA::DNN::TDataLoader< Data_t, AArchitecture >::fSampleIndices
private

Ordering of the samples in the epoch.

Definition at line 142 of file DataLoader.h.


The documentation for this class was generated from the following file: