|
LBANN
0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
|
#include <sample_list.hpp>
Public Types | |
| using | name_t = sample_name_t |
| using | sample_file_id_t = std::size_t |
| The type for the index assigned to each sample file. More... | |
| using | sample_t = std::template pair< sample_file_id_t, sample_name_t > |
| using | samples_t = std::template vector< sample_t > |
| Type for the list of samples. More... | |
| using | sample_idx_t = typename samples_t::size_type |
| Type for the index into the sample list. More... | |
| using | sample_map_t = std::unordered_map< sample_name_t, sample_idx_t > |
| Type for the map from sample name to the sample list index. More... | |
| using | file_id_stats_v_t = std::vector< std::string > |
| Mapping of the file index to the filename. More... | |
Public Member Functions | |
| sample_list () | |
| virtual | ~sample_list () |
| sample_list (const sample_list &rhs) | |
| sample_list & | operator= (const sample_list &rhs) |
| sample_list & | copy (const sample_list &rhs) |
| void | copy_members (const sample_list &rhs) |
| void | load (std::istream &istrm, size_t stride=1, size_t offset=0) |
| void | load (const std::string &samplelist_file, const lbann_comm &comm, bool interleave) |
| void | load (std::istream &istrm, const lbann_comm &comm, bool interleave) |
| void | load (const sample_list_header &header, std::istream &istrm, const lbann_comm &comm, bool interleave) |
| void | load_from_string (const std::string &samplelist, const lbann_comm &comm, bool interleave) |
| Restore a sample list from a serialized string. More... | |
| virtual size_t | size () const |
| Tells how many samples in the list. More... | |
| virtual size_t | get_num_files () const |
| Tells how many sample files are there. More... | |
| bool | empty () const |
| Tells if the internal list is empty. More... | |
| template<class Archive > | |
| void | serialize (Archive &ar) |
| Serialize to and from an archive using the cereal library. More... | |
| virtual bool | to_string (std::string &sstr) const |
| Serialize sample list. More... | |
| void | write (const std::string filename) const |
| Write the sample list. More... | |
| const samples_t & | get_list () const |
| Allow read-only access to the internal list data. More... | |
| const sample_list_header & | get_header () const |
| Allow the read-only access to the list header. More... | |
| const sample_t & | operator[] (size_t idx) const |
| Allow read-only access to the metadata of the idx-th sample in the list. More... | |
| virtual const std::string & | get_samples_filename (sample_file_id_t id) const |
| const std::string & | get_samples_dirname () const |
| const std::string & | get_label_filename () const |
| void | all_gather_archive (const std::string &archive, std::vector< std::string > &gathered_archive, lbann_comm &comm) |
| void | all_gather_archive_new (const std::string &archive, std::vector< std::string > &gathered_archive, lbann_comm &comm) |
| template<typename T > | |
| size_t | all_gather_field (T data, std::vector< T > &gathered_data, lbann_comm &comm) |
| virtual void | all_gather_packed_lists (lbann_comm &comm) |
| void | keep_sample_order (bool keep) |
| Set to maintain the original sample order as listed in the file. More... | |
| void | set_sample_list_name (const std::string &n) |
| void | set_data_file_check () |
| Set to check the existence of data file in the list. More... | |
| void | unset_data_file_check () |
| Set not to check the existence of data file in the list. More... | |
| void | build_sample_map_from_name_to_index () |
| Build map from sample names to indices for sample list. More... | |
| void | clear_sample_map_from_name_to_index () |
| Clear the map from sample names to indices. More... | |
| sample_idx_t | get_sample_index (const sample_name_t &sn) |
| Return the index of the sample with the specified name. More... | |
Protected Member Functions | |
| std::string | read_header_line (std::istream &ifs, const std::string &listname, const std::string &info) |
| void | read_header (std::istream &istrm) |
| Reads the header of a sample list. More... | |
| virtual void | read_sample_list (std::istream &istrm, size_t stride=1, size_t offset=0) |
| virtual void | assign_samples_name () |
| size_t | get_samples_per_file (std::istream &istrm, size_t stride=1, size_t offset=0) |
| Reads a sample list and populates the internal list. More... | |
| void | write_header (std::string &sstr, size_t num_files) const |
| Add the header info to the given string. More... | |
| virtual void | get_num_samples (size_t &total, size_t &included, size_t &excluded) const |
| Get the number of total/included/excluded samples. More... | |
| virtual void | set_samples_filename (sample_file_id_t id, const std::string &filename) |
| virtual void | reorder () |
| Reorder the sample list to its initial order. More... | |
| template<> | |
| void | assign_samples_name () |
| template<> | |
| void | assign_samples_name () |
Protected Attributes | |
| sample_list_header | m_header |
| header info of sample list More... | |
| size_t | m_stride |
| The stride used in loading sample list file. More... | |
| bool | m_keep_order |
| maintain the original sample order as listed in the file More... | |
| bool | m_check_data_file |
| Whether to check the existence of data file. More... | |
| samples_t | m_sample_list |
| List of all samples with a file identifier and sample name for each sample. More... | |
| sample_map_t | m_map_name_to_idx |
| Map from sample name to the corresponding index into the sample list. More... | |
Private Attributes | |
| file_id_stats_v_t | m_file_id_stats_map |
| Maps sample's file id to file names, file descriptors, and use counts. More... | |
Definition at line 93 of file sample_list.hpp.
| using lbann::sample_list< sample_name_t >::file_id_stats_v_t = std::vector<std::string> |
Mapping of the file index to the filename.
Definition at line 109 of file sample_list.hpp.
| using lbann::sample_list< sample_name_t >::name_t = sample_name_t |
Definition at line 96 of file sample_list.hpp.
| using lbann::sample_list< sample_name_t >::sample_file_id_t = std::size_t |
The type for the index assigned to each sample file.
Definition at line 98 of file sample_list.hpp.
| using lbann::sample_list< sample_name_t >::sample_idx_t = typename samples_t::size_type |
Type for the index into the sample list.
Definition at line 105 of file sample_list.hpp.
| using lbann::sample_list< sample_name_t >::sample_map_t = std::unordered_map<sample_name_t, sample_idx_t> |
Type for the map from sample name to the sample list index.
Definition at line 107 of file sample_list.hpp.
| using lbann::sample_list< sample_name_t >::sample_t = std::template pair<sample_file_id_t, sample_name_t> |
To describe a sample as the id of the file to which it belongs. Each file contains only one sample.
Definition at line 101 of file sample_list.hpp.
| using lbann::sample_list< sample_name_t >::samples_t = std::template vector<sample_t> |
Type for the list of samples.
Definition at line 103 of file sample_list.hpp.
| lbann::sample_list< sample_name_t >::sample_list | ( | ) |
Definition at line 293 of file sample_list_impl.hpp.
|
virtual |
Definition at line 298 of file sample_list_impl.hpp.
| lbann::sample_list< sample_name_t >::sample_list | ( | const sample_list< sample_name_t > & | rhs | ) |
Definition at line 302 of file sample_list_impl.hpp.
|
inline |
Definition at line 560 of file sample_list_impl.hpp.
| void lbann::sample_list< sample_name_t >::all_gather_archive_new | ( | const std::string & | archive, |
| std::vector< std::string > & | gathered_archive, | ||
| lbann_comm & | comm | ||
| ) |
|
inline |
Definition at line 642 of file sample_list_impl.hpp.
|
inlinevirtual |
Reimplemented in lbann::sample_list_open_files< sample_name_t, file_handle_t >, lbann::sample_list_open_files< long long, std::ifstream *>, lbann::sample_list_open_files< std::string, hid_t >, lbann::sample_list_open_files< sample_name_t, hid_t >, lbann::sample_list_open_files< sample_name_t, conduit::relay::io::IOHandle *>, and lbann::sample_list_open_files< sample_name_t, std::ifstream *>.
Definition at line 946 of file sample_list_impl.hpp.
|
inlineprotectedvirtual |
Assign names to samples when there is only one sample per file without a name.
Reimplemented in lbann::sample_list_open_files< sample_name_t, file_handle_t >, lbann::sample_list_open_files< long long, std::ifstream *>, lbann::sample_list_open_files< std::string, hid_t >, lbann::sample_list_open_files< sample_name_t, hid_t >, lbann::sample_list_open_files< sample_name_t, conduit::relay::io::IOHandle *>, and lbann::sample_list_open_files< sample_name_t, std::ifstream *>.
Definition at line 918 of file sample_list_impl.hpp.
|
inlineprotected |
Definition at line 901 of file sample_list_impl.hpp.
|
inlineprotected |
Definition at line 910 of file sample_list_impl.hpp.
|
inline |
Build map from sample names to indices for sample list.
Definition at line 1025 of file sample_list_impl.hpp.
|
inline |
Clear the map from sample names to indices.
Definition at line 1034 of file sample_list_impl.hpp.
|
inline |
Definition at line 323 of file sample_list_impl.hpp.
|
inline |
Keep track of existing filenames
Definition at line 336 of file sample_list_impl.hpp.
|
inline |
Tells if the internal list is empty.
Definition at line 421 of file sample_list_impl.hpp.
|
inline |
Allow the read-only access to the list header.
Definition at line 813 of file sample_list_impl.hpp.
|
inline |
|
inline |
Allow read-only access to the internal list data.
Definition at line 807 of file sample_list_impl.hpp.
|
inlinevirtual |
Tells how many sample files are there.
Reimplemented in lbann::sample_list_open_files< sample_name_t, file_handle_t >, lbann::sample_list_open_files< long long, std::ifstream *>, lbann::sample_list_open_files< std::string, hid_t >, lbann::sample_list_open_files< sample_name_t, hid_t >, lbann::sample_list_open_files< sample_name_t, conduit::relay::io::IOHandle *>, and lbann::sample_list_open_files< sample_name_t, std::ifstream *>.
Definition at line 415 of file sample_list_impl.hpp.
|
inlineprotectedvirtual |
Get the number of total/included/excluded samples.
Reimplemented in lbann::sample_list_open_files< sample_name_t, file_handle_t >, lbann::sample_list_open_files< long long, std::ifstream *>, lbann::sample_list_open_files< std::string, hid_t >, lbann::sample_list_open_files< sample_name_t, hid_t >, lbann::sample_list_open_files< sample_name_t, conduit::relay::io::IOHandle *>, and lbann::sample_list_open_files< sample_name_t, std::ifstream *>.
Definition at line 731 of file sample_list_impl.hpp.
|
inline |
Return the index of the sample with the specified name.
Definition at line 1045 of file sample_list_impl.hpp.
|
inline |
Definition at line 834 of file sample_list_impl.hpp.
|
inlinevirtual |
Reimplemented in lbann::sample_list_open_files< sample_name_t, file_handle_t >, lbann::sample_list_open_files< long long, std::ifstream *>, lbann::sample_list_open_files< std::string, hid_t >, lbann::sample_list_open_files< sample_name_t, hid_t >, lbann::sample_list_open_files< sample_name_t, conduit::relay::io::IOHandle *>, and lbann::sample_list_open_files< sample_name_t, std::ifstream *>.
Definition at line 827 of file sample_list_impl.hpp.
|
inlineprotected |
Reads a sample list and populates the internal list.
Definition at line 547 of file sample_list_impl.hpp.
|
inline |
Set to maintain the original sample order as listed in the file.
Definition at line 1056 of file sample_list_impl.hpp.
|
inline |
Load a sample list file using the given stride and offset on the sample sequence
Definition at line 349 of file sample_list_impl.hpp.
|
inline |
Load a sample list file using the stride as the number of processes per trainer and the offset as the current rank within the trainer if interleaving option is on.
Definition at line 358 of file sample_list_impl.hpp.
|
inline |
Definition at line 371 of file sample_list_impl.hpp.
|
inline |
Load sample list using the given header instead of reading it from the input stream
Definition at line 381 of file sample_list_impl.hpp.
|
inline |
Restore a sample list from a serialized string.
Definition at line 396 of file sample_list_impl.hpp.
|
inline |
Definition at line 309 of file sample_list_impl.hpp.
|
inline |
Allow read-only access to the metadata of the idx-th sample in the list.
Definition at line 820 of file sample_list_impl.hpp.
|
inlineprotected |
Reads the header of a sample list.
Definition at line 454 of file sample_list_impl.hpp.
|
inlineprotected |
Reads a header line from the sample list given as a stream, and use the info string for error message
Definition at line 428 of file sample_list_impl.hpp.
|
inlineprotectedvirtual |
read the body of a sample list, which is the list of sample files, where each file contains a single sample.
Reimplemented in lbann::sample_list_open_files< sample_name_t, file_handle_t >, lbann::sample_list_open_files< long long, std::ifstream *>, lbann::sample_list_open_files< std::string, hid_t >, lbann::sample_list_open_files< sample_name_t, hid_t >, lbann::sample_list_open_files< sample_name_t, conduit::relay::io::IOHandle *>, and lbann::sample_list_open_files< sample_name_t, std::ifstream *>.
Definition at line 485 of file sample_list_impl.hpp.
|
inlineprotectedvirtual |
Reorder the sample list to its initial order.
Reimplemented in lbann::sample_list_open_files< sample_name_t, file_handle_t >, lbann::sample_list_open_files< long long, std::ifstream *>, lbann::sample_list_open_files< std::string, hid_t >, lbann::sample_list_open_files< sample_name_t, hid_t >, lbann::sample_list_open_files< sample_name_t, conduit::relay::io::IOHandle *>, and lbann::sample_list_open_files< sample_name_t, std::ifstream *>.
Definition at line 1000 of file sample_list_impl.hpp.
| void lbann::sample_list< sample_name_t >::serialize | ( | Archive & | ar | ) |
Serialize to and from an archive using the cereal library.
Definition at line 675 of file sample_list_impl.hpp.
|
inline |
Set to check the existence of data file in the list.
Definition at line 1069 of file sample_list_impl.hpp.
|
inline |
Manually set the sample list name, which can be used for stream-based sources
Definition at line 1063 of file sample_list_impl.hpp.
|
inlineprotectedvirtual |
Reimplemented in lbann::sample_list_open_files< sample_name_t, file_handle_t >, lbann::sample_list_open_files< long long, std::ifstream *>, lbann::sample_list_open_files< std::string, hid_t >, lbann::sample_list_open_files< sample_name_t, hid_t >, lbann::sample_list_open_files< sample_name_t, conduit::relay::io::IOHandle *>, and lbann::sample_list_open_files< sample_name_t, std::ifstream *>.
Definition at line 847 of file sample_list_impl.hpp.
|
inlinevirtual |
Tells how many samples in the list.
Reimplemented in lbann::sample_list_open_files< sample_name_t, file_handle_t >, lbann::sample_list_open_files< long long, std::ifstream *>, lbann::sample_list_open_files< std::string, hid_t >, lbann::sample_list_open_files< sample_name_t, hid_t >, lbann::sample_list_open_files< sample_name_t, conduit::relay::io::IOHandle *>, and lbann::sample_list_open_files< sample_name_t, std::ifstream *>.
Definition at line 409 of file sample_list_impl.hpp.
|
inlinevirtual |
Serialize sample list.
Reimplemented in lbann::sample_list_open_files< sample_name_t, file_handle_t >, lbann::sample_list_open_files< long long, std::ifstream *>, lbann::sample_list_open_files< std::string, hid_t >, lbann::sample_list_open_files< sample_name_t, hid_t >, lbann::sample_list_open_files< sample_name_t, conduit::relay::io::IOHandle *>, and lbann::sample_list_open_files< sample_name_t, std::ifstream *>.
Definition at line 741 of file sample_list_impl.hpp.
|
inline |
Set not to check the existence of data file in the list.
Definition at line 1075 of file sample_list_impl.hpp.
|
inline |
Write the sample list.
Definition at line 779 of file sample_list_impl.hpp.
|
inlineprotected |
Add the header info to the given string.
Definition at line 684 of file sample_list_impl.hpp.
|
protected |
Whether to check the existence of data file.
Definition at line 257 of file sample_list.hpp.
|
private |
Maps sample's file id to file names, file descriptors, and use counts.
Definition at line 267 of file sample_list.hpp.
|
protected |
header info of sample list
Definition at line 248 of file sample_list.hpp.
|
protected |
maintain the original sample order as listed in the file
Definition at line 254 of file sample_list.hpp.
|
protected |
Map from sample name to the corresponding index into the sample list.
Definition at line 263 of file sample_list.hpp.
|
protected |
List of all samples with a file identifier and sample name for each sample.
Definition at line 260 of file sample_list.hpp.
|
protected |
The stride used in loading sample list file.
Definition at line 251 of file sample_list.hpp.