CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
tfaot::BatchRule Class Reference

#include <Batching.h>

Public Member Functions

 BatchRule (size_t batchSize, const std::vector< size_t > &sizes, size_t lastPadding=0)
 
size_t getBatchSize () const
 
size_t getLastPadding () const
 
size_t getSize (size_t i) const
 
const std::vector< size_t > & getSizes () const
 
size_t nSizes () const
 
 ~BatchRule ()=default
 

Private Attributes

size_t batchSize_
 
size_t lastPadding_
 
std::vector< size_t > sizes_
 

Detailed Description

Definition at line 19 of file Batching.h.

Constructor & Destructor Documentation

◆ BatchRule()

tfaot::BatchRule::BatchRule ( size_t  batchSize,
const std::vector< size_t > &  sizes,
size_t  lastPadding = 0 
)
explicit

Definition at line 16 of file Batching.cc.

References HLT_FULL_cff::batchSize, Exception, alignCSCRings::s, and sizes_.

17  : batchSize_(batchSize), sizes_(sizes), lastPadding_(lastPadding) {
18  // sizes must not be empty
19  if (sizes.size() == 0) {
20  throw cms::Exception("EmptySizes") << "no batch sizes provided for stitching";
21  }
22 
23  // the padding must be smaller than the last size
24  size_t lastSize = sizes[sizes.size() - 1];
25  if (lastPadding >= lastSize) {
26  throw cms::Exception("WrongPadding")
27  << "padding " << lastPadding << " must be smaller than last size " << lastSize;
28  }
29 
30  // compute the covered batch size
31  size_t sizeSum = 0;
32  for (const size_t& s : sizes_) {
33  sizeSum += s;
34  }
35  if (lastPadding > sizeSum) {
36  throw cms::Exception("WrongPadding")
37  << "padding " << lastPadding << " must not be larger than sum of sizes " << sizeSum;
38  }
39  sizeSum -= lastPadding;
40 
41  // compare to given batch size
42  if (batchSize != sizeSum) {
43  throw cms::Exception("WrongBatchSize")
44  << "batch size " << batchSize << " does not match sum of sizes - padding " << sizeSum;
45  }
46  }
size_t lastPadding_
Definition: Batching.h:45
std::vector< size_t > sizes_
Definition: Batching.h:44
size_t batchSize_
Definition: Batching.h:43

◆ ~BatchRule()

tfaot::BatchRule::~BatchRule ( )
default

Member Function Documentation

◆ getBatchSize()

size_t tfaot::BatchRule::getBatchSize ( ) const
inline

Definition at line 28 of file Batching.h.

References batchSize_.

Referenced by tfaot::operator<<(), and tfaot::BatchStrategy::setRule().

28 { return batchSize_; }
size_t batchSize_
Definition: Batching.h:43

◆ getLastPadding()

size_t tfaot::BatchRule::getLastPadding ( ) const
inline

Definition at line 34 of file Batching.h.

References lastPadding_.

Referenced by tfaot::operator<<(), and tfaot::Model< W >::run().

34 { return lastPadding_; }
size_t lastPadding_
Definition: Batching.h:45

◆ getSize()

size_t tfaot::BatchRule::getSize ( size_t  i) const
inline

Definition at line 40 of file Batching.h.

References mps_fire::i, and sizes_.

Referenced by tfaot::Model< W >::run().

40 { return sizes_[i]; }
std::vector< size_t > sizes_
Definition: Batching.h:44

◆ getSizes()

const std::vector<size_t>& tfaot::BatchRule::getSizes ( ) const
inline

Definition at line 31 of file Batching.h.

References sizes_.

Referenced by tfaot::operator<<().

31 { return sizes_; }
std::vector< size_t > sizes_
Definition: Batching.h:44

◆ nSizes()

size_t tfaot::BatchRule::nSizes ( ) const
inline

Definition at line 37 of file Batching.h.

References sizes_.

Referenced by tfaot::operator<<(), and tfaot::Model< W >::run().

37 { return sizes_.size(); }
std::vector< size_t > sizes_
Definition: Batching.h:44

Member Data Documentation

◆ batchSize_

size_t tfaot::BatchRule::batchSize_
private

Definition at line 43 of file Batching.h.

Referenced by getBatchSize().

◆ lastPadding_

size_t tfaot::BatchRule::lastPadding_
private

Definition at line 45 of file Batching.h.

Referenced by getLastPadding().

◆ sizes_

std::vector<size_t> tfaot::BatchRule::sizes_
private

Definition at line 44 of file Batching.h.

Referenced by BatchRule(), getSize(), getSizes(), and nSizes().