LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
unit_test::utilities Namespace Reference

Namespaces

 expert
 Expert-only methods.
 

Classes

struct  BadPointer
 
struct  BadSubstitutionPattern
 Indicates that an invalid pattern is detected. More...
 

Functions

lbann::lbann_commcurrent_world_comm ()
 Get the world communicator for this MPI session. More...
 
template<typename T >
size_t as_size (T const &size) noexcept
 
std::string replace_escapes (std::string const &str, lbann::utils::SystemInfo const &sys_info)
 Substitute basic escape sequences in a string. More...
 
template<typename T >
bool IsValidPtr (std::unique_ptr< T > const &ptr) noexcept
 
template<typename T >
bool IsValidPtr (std::shared_ptr< T > const &ptr) noexcept
 
template<typename T >
bool IsValidPtr (T const *ptr) noexcept
 
lbann::default_arg_parser_typereset_global_argument_parser ()
 Return the global LBANN argument parser reset to its default condition. More...
 
void mock_data_reader (lbann::trainer &trainer, const std::vector< El::Int > &sample_size, int num_classes)
 

Function Documentation

◆ as_size()

template<typename T >
size_t unit_test::utilities::as_size ( T const &  size)
noexcept

Definition at line 61 of file MPITestHelpers.hpp.

◆ current_world_comm()

lbann::lbann_comm& unit_test::utilities::current_world_comm ( )

Get the world communicator for this MPI session.

Here is the caller graph for this function:

◆ IsValidPtr() [1/3]

template<typename T >
bool unit_test::utilities::IsValidPtr ( std::unique_ptr< T > const &  ptr)
noexcept

Definition at line 40 of file TestHelpers.hpp.

◆ IsValidPtr() [2/3]

template<typename T >
bool unit_test::utilities::IsValidPtr ( std::shared_ptr< T > const &  ptr)
noexcept

Definition at line 46 of file TestHelpers.hpp.

◆ IsValidPtr() [3/3]

template<typename T >
bool unit_test::utilities::IsValidPtr ( T const *  ptr)
noexcept

Definition at line 52 of file TestHelpers.hpp.

◆ mock_data_reader()

void unit_test::utilities::mock_data_reader ( lbann::trainer trainer,
const std::vector< El::Int > &  sample_size,
int  num_classes 
)
inline

Definition at line 71 of file TestHelpers.hpp.

Here is the call graph for this function:

◆ replace_escapes()

std::string unit_test::utilities::replace_escapes ( std::string const &  str,
lbann::utils::SystemInfo const &  sys_info 
)

Substitute basic escape sequences in a string.

The following patterns are supported:

Pattern Replacement
%% A literal percent sign ("%")
%h The hostname of the current process
%p The PID of the current process
%r The MPI rank of the current process, if available, or 0
%s The MPI size of the current job, if available, or 1
%env{<NAME>} The value of ${NAME} in the current environment

The MPI runtime is queried if available for MPI information. After that, environment variables are checked for common libraries (SLURM, Open-MPI, MVAPICH2). If neither of these methods gives the required information, default information consistent with a sequential job is returned: the rank will be 0 and the size will be 1.

If the "%env{<NAME>}" substitution fails to find NAME in the current environment, the replacement will be the empty string.

The double-percent sequence is extracted first, so "%%r" will return "%r" and "%%%r" will return "%<mpi-rank>".

Parameters
strThe string to which substitutions should be applied.
sys_infoThe source of system information. This is primarily exposed for stubbing the functionality to test this function.
Exceptions
BadSubstitutionPatternAn escape sequence is found in the string that has no valid substitution.
Returns
A copy of the input string with all substitutions applied.

◆ reset_global_argument_parser()

lbann::default_arg_parser_type& unit_test::utilities::reset_global_argument_parser ( )
inline

Return the global LBANN argument parser reset to its default condition.

With respect to testing, this means that the options have been added as with lbann::construct_all_options().

Definition at line 63 of file TestHelpers.hpp.

Here is the call graph for this function: