29 template <
typename AReal>
37 template <
typename AReal>
40 AReal **pointer =
new AReal *[1];
41 *pointer =
new AReal[size];
46 template <
typename AReal>
56 template <
typename AReal>
63 template <
typename AReal>
77 for (
size_t i = 0; i < batchSize; i++) {
78 size_t sampleIndex = *sampleIterator;
79 for (
size_t j = 0; j <
n; j++) {
80 size_t bufferIndex = j * batchSize + i;
81 buffer[bufferIndex] =
static_cast<Real_t>(inputMatrix(sampleIndex, j));
95 for (
size_t i = 0; i < batchSize; i++) {
96 size_t sampleIndex = *sampleIterator;
97 for (
size_t j = 0; j <
n; j++) {
98 size_t bufferIndex = j * batchSize + i;
99 buffer[bufferIndex] =
static_cast<Real_t>(outputMatrix(sampleIndex, j));
112 for (
size_t i = 0; i < batchSize; i++) {
113 size_t sampleIndex = *sampleIterator;
114 buffer[i] =
static_cast<Real_t>(outputMatrix(sampleIndex, 0));
127 for (
size_t i = 0; i < batchSize; i++) {
128 size_t sampleIndex = *sampleIterator;
129 for (
size_t j = 0; j <
n; j++) {
130 size_t bufferIndex = j * batchSize + i;
131 buffer[bufferIndex] = inputMatrix(sampleIndex, j);
145 for (
size_t i = 0; i < batchSize; i++) {
146 size_t sampleIndex = *sampleIterator;
147 for (
size_t j = 0; j <
n; j++) {
148 size_t bufferIndex = j * batchSize + i;
149 buffer[bufferIndex] = outputMatrix(sampleIndex, j);
162 for (
size_t i = 0; i < batchSize; i++) {
163 size_t sampleIndex = *sampleIterator;
164 buffer[i] =
static_cast<Double_t>(outputMatrix(sampleIndex, 0));
174 Event *
event = std::get<0>(fData)[0];
175 size_t n =
event->GetNVariables();
176 for (
size_t i = 0; i < batchSize; i++) {
177 size_t sampleIndex = * sampleIterator++;
178 event = std::get<0>(fData)[sampleIndex];
179 for (
size_t j = 0; j <
n; j++) {
180 size_t bufferIndex = j * batchSize + i;
181 buffer[bufferIndex] =
event->GetValue(j);
192 size_t n = buffer.
GetSize() / batchSize;
196 for (
size_t i = 0; i < batchSize; i++) {
197 size_t sampleIndex = *sampleIterator++;
198 Event *
event = std::get<0>(fData)[sampleIndex];
199 for (
size_t j = 0; j <
n; j++) {
201 size_t bufferIndex = j * batchSize + i;
203 if (event->GetNTargets() == 0) {
206 buffer[bufferIndex] = (info.
IsSignal(event)) ? 1.0 : 0.0;
209 buffer[bufferIndex] = 0.0;
210 if (j == event->GetClass()) {
211 buffer[bufferIndex] = 1.0;
215 buffer[bufferIndex] =
static_cast<Real_t>(
event->GetTarget(j));
226 for (
size_t i = 0; i < batchSize; i++) {
227 size_t sampleIndex = *sampleIterator++;
228 Event *
event = std::get<0>(fData)[sampleIndex];
229 buffer[i] =
event->GetWeight();
238 Event *
event = std::get<0>(fData)[0];
239 size_t n =
event->GetNVariables();
240 for (
size_t i = 0; i < batchSize; i++) {
241 size_t sampleIndex = * sampleIterator++;
242 event = std::get<0>(fData)[sampleIndex];
243 for (
size_t j = 0; j <
n; j++) {
244 size_t bufferIndex = j * batchSize + i;
245 buffer[bufferIndex] =
static_cast<Real_t>(
event->GetValue(j));
256 size_t n = buffer.
GetSize() / batchSize;
260 for (
size_t i = 0; i < batchSize; i++) {
261 size_t sampleIndex = *sampleIterator++;
262 Event *
event = std::get<0>(fData)[sampleIndex];
263 for (
size_t j = 0; j <
n; j++) {
265 size_t bufferIndex = j * batchSize + i;
267 if (event->GetNTargets() == 0) {
270 buffer[bufferIndex] = (info.
IsSignal(event)) ? 1.0 : 0.0;
273 buffer[bufferIndex] = 0.0;
274 if (j == event->GetClass()) {
275 buffer[bufferIndex] = 1.0;
279 buffer[bufferIndex] =
static_cast<Real_t>(
event->GetTarget(j));
290 for (
size_t i = 0; i < batchSize; i++) {
291 size_t sampleIndex = *sampleIterator++;
292 Event *
event = std::get<0>(fData)[sampleIndex];
293 buffer[i] =
static_cast<Real_t>(
event->GetWeight());
302 const std::vector<TMatrixT<Double_t>> &inputTensor = std::get<0>(fData);
304 if (fBatchDepth == 1) {
305 for (
size_t i = 0; i < fBatchHeight; i++) {
306 size_t sampleIndex = *sampleIterator;
307 for (
size_t j = 0; j < fBatchWidth; j++) {
308 size_t bufferIndex = j * fBatchHeight + i;
309 buffer[bufferIndex] =
static_cast<Real_t>(inputTensor[0](sampleIndex, j));
314 for (
size_t i = 0; i < fBatchDepth; i++) {
315 size_t sampleIndex = *sampleIterator;
316 for (
size_t j = 0; j < fBatchHeight; j++) {
317 for (
size_t k = 0; k < fBatchWidth; k++) {
318 size_t bufferIndex = i * fBatchHeight * fBatchWidth + k * fBatchHeight + j;
319 buffer[bufferIndex] =
static_cast<Real_t>(inputTensor[sampleIndex](j, k));
335 for (
size_t i = 0; i < fBatchSize; i++) {
336 size_t sampleIndex = *sampleIterator;
337 for (
size_t j = 0; j <
n; j++) {
338 size_t bufferIndex = j * fBatchSize + i;
339 buffer[bufferIndex] =
static_cast<Real_t>(outputMatrix(sampleIndex, j));
352 for (
size_t i = 0; i < fBatchSize; i++) {
353 size_t sampleIndex = *sampleIterator;
354 buffer[i] =
static_cast<Real_t>(outputMatrix(sampleIndex, 0));
364 const std::vector<TMatrixT<Double_t>> &inputTensor = std::get<0>(fData);
366 if (fBatchDepth == 1) {
367 for (
size_t i = 0; i < fBatchHeight; i++) {
368 size_t sampleIndex = *sampleIterator;
369 for (
size_t j = 0; j < fBatchWidth; j++) {
370 size_t bufferIndex = j * fBatchHeight + i;
371 buffer[bufferIndex] = inputTensor[0](sampleIndex, j);
376 for (
size_t i = 0; i < fBatchDepth; i++) {
377 size_t sampleIndex = *sampleIterator;
378 for (
size_t j = 0; j < fBatchHeight; j++) {
379 for (
size_t k = 0; k < fBatchWidth; k++) {
380 size_t bufferIndex = i * fBatchHeight * fBatchWidth + k * fBatchHeight + j;
381 buffer[bufferIndex] = inputTensor[sampleIndex](j, k);
397 for (
size_t i = 0; i < fBatchSize; i++) {
398 size_t sampleIndex = *sampleIterator;
399 for (
size_t j = 0; j <
n; j++) {
400 size_t bufferIndex = j * fBatchSize + i;
401 buffer[bufferIndex] = outputMatrix(sampleIndex, j);
414 for (
size_t i = 0; i < fBatchSize; i++) {
415 size_t sampleIndex = *sampleIterator;
416 buffer[i] =
static_cast<Double_t>(outputMatrix(sampleIndex, 0));
429 if (fBatchDepth == 1 && fBatchHeight == fBatchSize) {
430 for (
size_t i = 0; i < fBatchHeight; i++) {
431 size_t sampleIndex = *sampleIterator;
432 Event *
event = std::get<0>(fData)[sampleIndex];
433 for (
size_t j = 0; j < fBatchWidth; j++) {
434 size_t bufferIndex = j * fBatchHeight + i;
435 buffer[bufferIndex] =
event->GetValue(j);
439 }
else if (fBatchDepth == fBatchSize) {
441 for (
size_t i = 0; i < fBatchDepth; i++) {
442 size_t sampleIndex = *sampleIterator;
443 Event *
event = std::get<0>(fData)[sampleIndex];
444 for (
size_t j = 0; j < fBatchHeight; j++) {
445 for (
size_t k = 0; k < fBatchWidth; k++) {
447 size_t bufferIndex = i * fBatchHeight * fBatchWidth + k * fBatchHeight + j;
448 buffer[bufferIndex] =
event->GetValue(j * fBatchWidth + k);
455 Error(
"TTensorDataLoader",
"Inconsistency between batch depth and batch size");
466 size_t n = buffer.
GetSize() / fBatchSize;
470 for (
size_t i = 0; i < fBatchSize; i++) {
471 size_t sampleIndex = *sampleIterator++;
472 Event *
event = std::get<0>(fData)[sampleIndex];
473 for (
size_t j = 0; j <
n; j++) {
475 size_t bufferIndex = j * fBatchSize + i;
477 if (event->GetNTargets() == 0) {
480 buffer[bufferIndex] = (info.
IsSignal(event)) ? 1.0 : 0.0;
483 buffer[bufferIndex] = 0.0;
484 if (j == event->GetClass()) {
485 buffer[bufferIndex] = 1.0;
489 buffer[bufferIndex] =
static_cast<Real_t>(
event->GetTarget(j));
500 for (
size_t i = 0; i < fBatchSize; i++) {
501 size_t sampleIndex = *sampleIterator++;
502 Event *
event = std::get<0>(fData)[sampleIndex];
503 buffer[i] =
event->GetWeight();
515 if (fBatchDepth == 1 && fBatchHeight == fBatchSize) {
516 for (
size_t i = 0; i < fBatchHeight; i++) {
517 size_t sampleIndex = *sampleIterator;
518 Event *
event = std::get<0>(fData)[sampleIndex];
519 for (
size_t j = 0; j < fBatchWidth; j++) {
520 size_t bufferIndex = j * fBatchHeight + i;
521 buffer[bufferIndex] =
event->GetValue(j);
525 }
else if (fBatchDepth == fBatchSize) {
527 for (
size_t i = 0; i < fBatchDepth; i++) {
528 size_t sampleIndex = *sampleIterator;
529 Event *
event = std::get<0>(fData)[sampleIndex];
530 for (
size_t j = 0; j < fBatchHeight; j++) {
531 for (
size_t k = 0; k < fBatchWidth; k++) {
533 size_t bufferIndex = i * fBatchHeight * fBatchWidth + k * fBatchHeight + j;
534 buffer[bufferIndex] =
event->GetValue(j * fBatchWidth + k);
541 Error(
"TTensorDataLoader",
"Inconsistency between batch depth and batch size");
552 size_t n = buffer.
GetSize() / fBatchSize;
556 for (
size_t i = 0; i < fBatchSize; i++) {
557 size_t sampleIndex = *sampleIterator++;
558 Event *
event = std::get<0>(fData)[sampleIndex];
559 for (
size_t j = 0; j <
n; j++) {
561 size_t bufferIndex = j * fBatchSize + i;
563 if (event->GetNTargets() == 0) {
566 buffer[bufferIndex] = (info.
IsSignal(event)) ? 1.0 : 0.0;
569 buffer[bufferIndex] = 0.0;
570 if (j == event->GetClass()) {
571 buffer[bufferIndex] = 1.0;
575 buffer[bufferIndex] =
static_cast<Real_t>(
event->GetTarget(j));
586 for (
size_t i = 0; i < fBatchSize; i++) {
587 size_t sampleIndex = *sampleIterator++;
588 Event *
event = std::get<0>(fData)[sampleIndex];
589 buffer[i] =
event->GetWeight();
void swap(TDirectoryEntry &e1, TDirectoryEntry &e2) noexcept
void CopyTo(TCpuBuffer &)
Copy data to another buffer.
std::shared_ptr< AFloat * > fBuffer
void operator()(AFloat **pointer)
Class that contains all the data information.
typename std::vector< size_t >::iterator IndexIterator_t
TCpuBuffer(size_t size)
Construct buffer to hold size numbers of type AFloat.
void Error(const char *location, const char *msgfmt,...)
Abstract ClassifierFactory template that handles arbitrary types.
void CopyFrom(TCpuBuffer &)
Copy data from another buffer.
Bool_t IsSignal(const Event *ev) const
TCpuBuffer GetSubBuffer(size_t offset, size_t start)
Return subbuffer of siez start starting at element offset.
struct TMVA::DNN::TCpuBuffer::TDestructor fDestructor