27#ifndef TMVA_DNN_TENSORDATALOADER
28#define TMVA_DNN_TENSORDATALOADER
58template <
typename Architecture_t>
61 using Matrix_t =
typename Architecture_t::Matrix_t;
62 using Tensor_t =
typename Architecture_t::Tensor_t;
84template <
typename Data_t,
typename Architecture_t>
95template <
typename Data_t,
typename Architecture_t>
132template <
typename Data_t,
typename Architecture_t>
137 using Matrix_t =
typename Architecture_t::Matrix_t;
138 using Tensor_t =
typename Architecture_t::Tensor_t;
139 using Shape_t =
typename Architecture_t::Tensor_t::Shape_t;
162 const Shape_t & batchLayout,
size_t nOutputFeatures,
size_t nStreams = 1);
185 template<
typename RNG>
197template <
typename Architecture_t>
208template <
typename Data_t,
typename Architecture_t>
211 size_t nOutputFeatures,
size_t nStreams)
232template <
typename Data_t,
typename Architecture_t>
245 HostBuffer_t inputHostBuffer = hostBuffer.GetSubBuffer(0, inputTensorSize);
246 HostBuffer_t outputHostBuffer = hostBuffer.GetSubBuffer(inputTensorSize, outputMatrixSize);
247 HostBuffer_t weightHostBuffer = hostBuffer.GetSubBuffer(inputTensorSize + outputMatrixSize, weightMatrixSize);
249 DeviceBuffer_t inputDeviceBuffer = deviceBuffer.GetSubBuffer(0, inputTensorSize);
250 DeviceBuffer_t outputDeviceBuffer = deviceBuffer.GetSubBuffer(inputTensorSize, outputMatrixSize);
251 DeviceBuffer_t weightDeviceBuffer = deviceBuffer.GetSubBuffer(inputTensorSize + outputMatrixSize, weightMatrixSize);
264 deviceBuffer.CopyFrom(hostBuffer);
283template <
typename Data_t,
typename Architecture_t>
284template <
typename RNG>
TTensorBatchIterator(TTensorDataLoader< Data_t, Architecture_t > &tensorDataLoader, size_t index=0)
TTensorBatch< Architecture_t > operator*()
bool operator!=(const TTensorBatchIterator &other)
TTensorDataLoader< AData, TReference< AReal > > & fTensorDataLoader
TTensorBatchIterator operator++()
TTensorBatch & operator=(const TTensorBatch &)=default
Tensor_t fInputTensor
The input tensor batch, one matrix one input.
TTensorBatch(TTensorBatch &&)=default
TTensorBatch(Tensor_t &, Matrix_t &, Matrix_t &)
Matrix_t fWeightMatrix
The event/example weights.
TTensorBatch & operator=(TTensorBatch &&)=default
typename Architecture_t::Tensor_t Tensor_t
Matrix_t & GetWeights()
Return the matrix holding the event weights.
Matrix_t & GetOutput()
Return the matrix representing the output data.
TTensorBatch(const TTensorBatch &)=default
Matrix_t fOutputMatrix
The output matrix representing the ground truth.
Tensor_t & GetInput()
Return the tensor representing the input data.
typename Architecture_t::Matrix_t Matrix_t
typename Architecture_t::Tensor_t::Shape_t Shape_t
TTensorDataLoader(const TTensorDataLoader &)=default
TTensorBatchIterator< Data_t, Architecture_t > BatchIterator_t
void Shuffle(RNG &rng)
Shuffle the order of the samples in the batch.
size_t fNOutputFeatures
The number of outputs from the classifier/regressor.
std::vector< size_t > fSampleIndices
Ordering of the samples in the epoch.
std::vector< DeviceBuffer_t > fDeviceBuffers
The device buffers used to keep the input, output and weight data.
TTensorBatch< Architecture_t > GetTensorBatch()
Return the next batch from the training set.
TTensorDataLoader & operator=(const TTensorDataLoader &)=default
typename Architecture_t::DeviceBuffer_t DeviceBuffer_t
size_t fBatchWidth
The number of columns in each matrix.
void CopyTensorOutput(HostBuffer_t &buffer, IndexIterator_t begin)
Copy output matrix into the given host buffer.
size_t fBatchIndex
The index of the batch when there are multiple batches in parallel.
size_t fBatchHeight
The number od rows in each matrix.
std::vector< HostBuffer_t > fHostBuffers
The host buffers used to load the input, output and weight data.
TTensorDataLoader(const Data_t &data, size_t nSamples, size_t batchSize, const Shape_t &inputLayout, const Shape_t &batchLayout, size_t nOutputFeatures, size_t nStreams=1)
Constructor.
TTensorDataLoader(TTensorDataLoader &&)=default
size_t fBatchSize
The size of a batch.
Shape_t fInputLayout
The input data layout (does not include batch size).
void CopyTensorWeights(HostBuffer_t &buffer, IndexIterator_t begin)
Copy weight matrix into the given host buffer.
typename Architecture_t::Matrix_t Matrix_t
typename Architecture_t::HostBuffer_t HostBuffer_t
size_t fBatchDepth
The number of matrices in the tensor.
size_t fNStreams
Number of buffer pairs.
const Data_t & fData
The data that should be loaded in the batches.
TTensorDataLoader & operator=(TTensorDataLoader &&)=default
typename Architecture_t::Tensor_t Tensor_t
size_t fNSamples
The total number of samples in the dataset.
void CopyTensorInput(HostBuffer_t &buffer, IndexIterator_t begin)
Copy input tensor into the given host buffer.
Class that contains all the data information.
std::tuple< const std::vector< Event * > &, const DataSetInfo & > TMVAInput_t
typename std::vector< size_t >::iterator IndexIterator_t
std::tuple< const std::vector< TMatrixT< Double_t > > &, const TMatrixT< Double_t > &, const TMatrixT< Double_t > & > TensorInput
create variable transformations