LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
lbann::utils Namespace Reference

Namespaces

 details
 
 stubs
 

Classes

class  allow_extra_parameters
 
class  argument_parser
 Basic argument parsing with automatic help messages. More...
 
class  ConstDistTensorView
 
class  ConstTensorView
 
class  DistTensorView
 
class  EnvVariable
 An environment variable. More...
 
class  GetEnvAccessor
 Access environment variables using getenv. More...
 
struct  grid_manager
 RAII grid management. More...
 
class  parse_error
 std::exception subclass that is thrown if the parser can not parse the arguments. More...
 
class  strict_parsing
 
class  SystemInfo
 Query basic system information. More...
 
class  TensorView
 
class  type_erased_matrix
 A type-erased wrapper around an El::Matrix<T,Device::CPU> More...
 

Typedefs

using ENV = EnvVariable<>
 Convenience typedef. More...
 
template<typename ArchiveT , typename ResultT = int>
using WhenTextArchive = EnableWhen< IsTextArchive< ArchiveT > &&IsBuiltinArchive< ArchiveT >, ResultT >
 SFINAE helper for splitting text-based and non-text-based serialization functions. More...
 
template<typename ArchiveT , typename ResultT = int>
using WhenNotTextArchive = EnableWhen<!IsTextArchive< ArchiveT > &&IsBuiltinArchive< ArchiveT >, ResultT >
 SFINAE helper for splitting text-based and non-text-based serialization functions. More...
 

Functions

std::string commify (size_t n)
 Inserts commas large integers for pretty-printing. More...
 
template<typename T >
from_string (std::string const &str)
 An exceedingly simple implementation of boost::lexical_cast, e.g. More...
 
std::string from_string (std::string &&str)
 
template<>
std::string from_string< std::string > (std::string const &str)
 
template<>
int from_string< int > (std::string const &str)
 
template<>
long from_string< long > (std::string const &str)
 
template<>
long long from_string< long long > (std::string const &str)
 
template<>
unsigned long from_string< unsigned long > (std::string const &str)
 
template<>
unsigned long long from_string< unsigned long long > (std::string const &str)
 
template<>
float from_string< float > (std::string const &str)
 
template<>
double from_string< double > (std::string const &str)
 
template<>
long double from_string< long double > (std::string const &str)
 
template<>
bool from_string< bool > (std::string const &str)
 
bool check_is_image (const utils::type_erased_matrix &data, const std::vector< size_t > &dims)
 
void assert_is_image (const utils::type_erased_matrix &data, const std::vector< size_t > &dims)
 
cv::Mat get_opencv_mat (utils::type_erased_matrix &data, const std::vector< size_t > &dims)
 
cv::Mat get_opencv_mat (El::Matrix< uint8_t > &data, const std::vector< size_t > &dims)
 
Grid const & get_current_grid () noexcept
 Get the current grid being used for deserialization. More...
 
lbann_commget_current_comm () noexcept
 
template<typename Field >
std::unique_ptr< type_erased_matrixcreate_type_erased_matrix ()
 Create an empty type-erased matrix with given underlying data type. More...
 

Variables

template<typename ArchiveT >
constexpr bool IsBuiltinArchive = details::IsBuiltinArchiveT<ArchiveT>::value
 Variable template for checking that an archive is a default Cereal archive type. More...
 
template<typename ArchiveT >
constexpr bool IsTextArchive = is_text_archive<ArchiveT>::value
 Variable template for checking that an archive type is marked as a text archive in Cereal. More...
 
template<typename ArchiveT >
constexpr bool IsInputArchive
 Variable template for checking that an archive type is an "Input" archive. More...
 
template<typename ArchiveT >
constexpr bool IsOutputArchive
 Variable template for checking that an archive type is an "Output" archive. More...
 

Typedef Documentation

◆ ENV

using lbann::utils::ENV = typedef EnvVariable<>

Convenience typedef.

Definition at line 93 of file environment_variable.hpp.

◆ WhenNotTextArchive

template<typename ArchiveT , typename ResultT = int>
using lbann::utils::WhenNotTextArchive = typedef EnableWhen<!IsTextArchive<ArchiveT> && IsBuiltinArchive<ArchiveT>, ResultT>

SFINAE helper for splitting text-based and non-text-based serialization functions.

Definition at line 169 of file cereal_utils.hpp.

◆ WhenTextArchive

template<typename ArchiveT , typename ResultT = int>
using lbann::utils::WhenTextArchive = typedef EnableWhen<IsTextArchive<ArchiveT> && IsBuiltinArchive<ArchiveT>, ResultT>

SFINAE helper for splitting text-based and non-text-based serialization functions.

Definition at line 162 of file cereal_utils.hpp.

Function Documentation

◆ assert_is_image()

void lbann::utils::assert_is_image ( const utils::type_erased_matrix data,
const std::vector< size_t > &  dims 
)
inline

Throw an error if data is not an image. Currently requires data to be a uint8_t CPUMat, with 3 dimensions, the first (channel) being 1 or 3. Also throws an error if OpenCV is not supported.

Parameters
dataThe data to check.
dimsThe dimensions associated with data.

Definition at line 71 of file opencv.hpp.

Here is the caller graph for this function:

◆ check_is_image()

bool lbann::utils::check_is_image ( const utils::type_erased_matrix data,
const std::vector< size_t > &  dims 
)
inline

Check whether data is an image. Currently requires data to be a uint8_t CPUMat, with 3 dimensions, the first (channel) being 1 or 3.

Parameters
dataThe data to check.
dimsThe dimensions associated with data.

Definition at line 45 of file opencv.hpp.

◆ commify()

std::string lbann::utils::commify ( size_t  n)

Inserts commas large integers for pretty-printing.

◆ create_type_erased_matrix()

template<typename Field >
std::unique_ptr<type_erased_matrix> lbann::utils::create_type_erased_matrix ( )

Create an empty type-erased matrix with given underlying data type.

Template Parameters
FieldThe type of the underlying matrix.
Returns
A pointer to an empty type-erased matrix with data type Field.

Definition at line 144 of file type_erased_matrix.hpp.

◆ from_string() [1/2]

template<typename T >
T lbann::utils::from_string ( std::string const &  str)

An exceedingly simple implementation of boost::lexical_cast, e.g.

Generally, these implementations prefer sto* function calls to the stream method because stream operators do not provide straight-forward error feedback.

Template Parameters
TThe type to cast to.
Parameters
strThe input string.
Returns
The value of the input string as a T.
Todo:
chars, shorts, unsigned. Bool needs some work.

◆ from_string() [2/2]

std::string lbann::utils::from_string ( std::string &&  str)
inline

Definition at line 53 of file from_string.hpp.

◆ from_string< bool >()

template<>
bool lbann::utils::from_string< bool > ( std::string const &  str)
inline

Definition at line 111 of file from_string.hpp.

Here is the call graph for this function:

◆ from_string< double >()

template<>
double lbann::utils::from_string< double > ( std::string const &  str)
inline

Definition at line 99 of file from_string.hpp.

◆ from_string< float >()

template<>
float lbann::utils::from_string< float > ( std::string const &  str)
inline

Definition at line 93 of file from_string.hpp.

◆ from_string< int >()

template<>
int lbann::utils::from_string< int > ( std::string const &  str)
inline

Definition at line 62 of file from_string.hpp.

Here is the caller graph for this function:

◆ from_string< long >()

template<>
long lbann::utils::from_string< long > ( std::string const &  str)
inline

Definition at line 68 of file from_string.hpp.

◆ from_string< long double >()

template<>
long double lbann::utils::from_string< long double > ( std::string const &  str)
inline

Definition at line 105 of file from_string.hpp.

◆ from_string< long long >()

template<>
long long lbann::utils::from_string< long long > ( std::string const &  str)
inline

Definition at line 74 of file from_string.hpp.

◆ from_string< std::string >()

template<>
std::string lbann::utils::from_string< std::string > ( std::string const &  str)
inline

Definition at line 56 of file from_string.hpp.

◆ from_string< unsigned long >()

template<>
unsigned long lbann::utils::from_string< unsigned long > ( std::string const &  str)
inline

Definition at line 80 of file from_string.hpp.

◆ from_string< unsigned long long >()

template<>
unsigned long long lbann::utils::from_string< unsigned long long > ( std::string const &  str)
inline

Definition at line 87 of file from_string.hpp.

◆ get_current_comm()

lbann_comm& lbann::utils::get_current_comm ( )
noexcept

◆ get_current_grid()

Grid const& lbann::utils::get_current_grid ( )
noexcept

Get the current grid being used for deserialization.

If not in a deserialization scope, this will return the default grid (and generate a warning from Hydrogen).

Here is the caller graph for this function:

◆ get_opencv_mat() [1/2]

cv::Mat lbann::utils::get_opencv_mat ( utils::type_erased_matrix data,
const std::vector< size_t > &  dims 
)
inline

Construct an OpenCV Mat that refers to data. No data is copied, this just sets up a cv::Mat header.

Parameters
dataThe matrix with data to use.
dimsDimensions of the data.

Definition at line 93 of file opencv.hpp.

Here is the call graph for this function:

◆ get_opencv_mat() [2/2]

cv::Mat lbann::utils::get_opencv_mat ( El::Matrix< uint8_t > &  data,
const std::vector< size_t > &  dims 
)
inline

Construct an OpenCV Mat that refers to data. No data is copied, this just sets up a cv::Mat header.

Parameters
dataThe matrix with data to use.
dimsDimensions of the data.

Definition at line 110 of file opencv.hpp.

Variable Documentation

◆ IsBuiltinArchive

template<typename ArchiveT >
constexpr bool lbann::utils::IsBuiltinArchive = details::IsBuiltinArchiveT<ArchiveT>::value

Variable template for checking that an archive is a default Cereal archive type.

Definition at line 135 of file cereal_utils.hpp.

◆ IsInputArchive

template<typename ArchiveT >
constexpr bool lbann::utils::IsInputArchive
Initial value:
=
std::is_base_of_v<cereal::detail::InputArchiveBase, ArchiveT>

Variable template for checking that an archive type is an "Input" archive.

Definition at line 147 of file cereal_utils.hpp.

◆ IsOutputArchive

template<typename ArchiveT >
constexpr bool lbann::utils::IsOutputArchive
Initial value:
=
std::is_base_of_v<cereal::detail::OutputArchiveBase, ArchiveT>

Variable template for checking that an archive type is an "Output" archive.

Definition at line 154 of file cereal_utils.hpp.

◆ IsTextArchive

template<typename ArchiveT >
constexpr bool lbann::utils::IsTextArchive = is_text_archive<ArchiveT>::value

Variable template for checking that an archive type is marked as a text archive in Cereal.

Definition at line 141 of file cereal_utils.hpp.