Minibatch container holding pinned host/device buffers and views into a Dataset. More...
#include <batch.h>
Public Member Functions | |
| Batch (const Index=0, const Dataset *=nullptr) | |
Constructs a batch sized for samples_number samples drawn from dataset. | |
| ~Batch () | |
| Batch (const Batch &)=delete | |
| Batch & | operator= (const Batch &)=delete |
| Batch (Batch &&)=delete | |
| Batch & | operator= (Batch &&)=delete |
| void | set (const Index=0, const Dataset *=nullptr) |
| Reconfigures the batch for a new size or dataset; reuses allocations when possible. | |
| void | fill (const vector< Index > &, const vector< Index > &, const vector< Index > &, const vector< Index > &, bool is_training=true, bool parallelize_samples=true) |
| Loads the indicated samples from the dataset into the batch buffers. | |
| const vector< TensorView > & | get_inputs () const |
| Returns the tensor views over the input buffer (device on GPU mode, host on CPU mode). | |
| const TensorView & | get_targets () const |
| Returns the tensor view over the target buffer (device on GPU mode, host on CPU mode). | |
| Index | get_samples_number () const |
| Returns the current sample count (set by fill(); may be < samples_number). | |
| void | print () const |
| Prints a human-readable summary of the batch shapes and contents. | |
| bool | is_empty () const |
| Returns true when the batch is uninitialized or holds zero samples. | |
| Index | get_input_elements () const |
Public Attributes | |
| Index | samples_number = 0 |
| Index | current_sample_count = 0 |
| const Dataset * | dataset = nullptr |
| Buffer | input |
| Shape | input_shape |
| Buffer | decoder |
| Shape | decoder_shape |
| Buffer | target |
| Shape | target_shape |
| int | input_contiguous = -1 |
| int | decoder_contiguous = -1 |
| int | target_contiguous = -1 |
| vector< TensorView > | input_views_host_cache |
| TensorView | target_view_host_cache |
| vector< TensorView > | input_views_cache |
| TensorView | target_view_cache |
| Index | input_features_number = 0 |
| Index | decoder_features_number = 0 |
| Index | target_features_number = 0 |
| float * | inputs_host = nullptr |
| float * | decoder_host = nullptr |
| float * | targets_host = nullptr |
| Index | inputs_host_allocated_size = 0 |
| Index | decoder_host_allocated_size = 0 |
| Index | targets_host_allocated_size = 0 |
| bool | needs_fp32_staging = false |
Detailed Description
Minibatch container holding pinned host/device buffers and views into a Dataset.
Constructor & Destructor Documentation
◆ Batch() [1/3]
| opennn::Batch::Batch | ( | const Index | = 0, |
| const Dataset * | = nullptr ) |
Constructs a batch sized for samples_number samples drawn from dataset.
- Parameters
-
samples_number Maximum number of samples this batch can hold. dataset Source dataset used to discover variable shapes (non-owning).
◆ ~Batch()
| opennn::Batch::~Batch | ( | ) |
◆ Batch() [2/3]
|
delete |
◆ Batch() [3/3]
|
delete |
Member Function Documentation
◆ fill()
| void opennn::Batch::fill | ( | const vector< Index > & | , |
| const vector< Index > & | , | ||
| const vector< Index > & | , | ||
| const vector< Index > & | , | ||
| bool | is_training = true, | ||
| bool | parallelize_samples = true ) |
Loads the indicated samples from the dataset into the batch buffers.
- Parameters
-
sample_indices Indices of the dataset rows to load. input_indices Indices of input variables in the dataset. decoder_indices Indices of decoder-side input variables (may be empty). target_indices Indices of target variables in the dataset. is_training Marks the batch as training (controls augmentation/dropout caches). parallelize_samples If true, copies samples in parallel.
◆ get_input_elements()
|
inline |
◆ get_inputs()
|
inline |
Returns the tensor views over the input buffer (device on GPU mode, host on CPU mode).
◆ get_samples_number()
| Index opennn::Batch::get_samples_number | ( | ) | const |
Returns the current sample count (set by fill(); may be < samples_number).
◆ get_targets()
|
inline |
Returns the tensor view over the target buffer (device on GPU mode, host on CPU mode).
◆ is_empty()
| bool opennn::Batch::is_empty | ( | ) | const |
Returns true when the batch is uninitialized or holds zero samples.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ print()
| void opennn::Batch::print | ( | ) | const |
Prints a human-readable summary of the batch shapes and contents.
◆ set()
| void opennn::Batch::set | ( | const Index | = 0, |
| const Dataset * | = nullptr ) |
Reconfigures the batch for a new size or dataset; reuses allocations when possible.
- Parameters
-
samples_number Maximum number of samples this batch can hold. dataset Source dataset used to discover variable shapes (non-owning).
Member Data Documentation
◆ current_sample_count
| Index opennn::Batch::current_sample_count = 0 |
◆ dataset
| const Dataset* opennn::Batch::dataset = nullptr |
◆ decoder
| Buffer opennn::Batch::decoder |
◆ decoder_contiguous
| int opennn::Batch::decoder_contiguous = -1 |
◆ decoder_features_number
| Index opennn::Batch::decoder_features_number = 0 |
◆ decoder_host
| float* opennn::Batch::decoder_host = nullptr |
◆ decoder_host_allocated_size
| Index opennn::Batch::decoder_host_allocated_size = 0 |
◆ decoder_shape
| Shape opennn::Batch::decoder_shape |
◆ input
| Buffer opennn::Batch::input |
◆ input_contiguous
| int opennn::Batch::input_contiguous = -1 |
◆ input_features_number
| Index opennn::Batch::input_features_number = 0 |
◆ input_shape
| Shape opennn::Batch::input_shape |
◆ input_views_cache
| vector<TensorView> opennn::Batch::input_views_cache |
◆ input_views_host_cache
| vector<TensorView> opennn::Batch::input_views_host_cache |
◆ inputs_host
| float* opennn::Batch::inputs_host = nullptr |
◆ inputs_host_allocated_size
| Index opennn::Batch::inputs_host_allocated_size = 0 |
◆ needs_fp32_staging
| bool opennn::Batch::needs_fp32_staging = false |
◆ samples_number
| Index opennn::Batch::samples_number = 0 |
◆ target
| Buffer opennn::Batch::target |
◆ target_contiguous
| int opennn::Batch::target_contiguous = -1 |
◆ target_features_number
| Index opennn::Batch::target_features_number = 0 |
◆ target_shape
| Shape opennn::Batch::target_shape |
◆ target_view_cache
| TensorView opennn::Batch::target_view_cache |
◆ target_view_host_cache
| TensorView opennn::Batch::target_view_host_cache |
◆ targets_host
| float* opennn::Batch::targets_host = nullptr |
◆ targets_host_allocated_size
| Index opennn::Batch::targets_host_allocated_size = 0 |