mirror of
https://github.com/amd/blis.git
synced 2026-05-24 18:34:40 +00:00
GTestSuite : Designing test cases for ZGEMM
- Designed test cases for unit testing of ZGEMM compute kernel for handling inputs when k == 1. The design uses value-parameterized testing for checking accuracy, and verifying the mandate in case of exception values on the inputs/output. - The design uses type-parameterized testing for verifying BLAS standard for invalid input cases, and also for early return scenarios. - Added the function template set_ev_mat( ... ) as part of testinghelpers. This function is used as a helper for inducing exception values onto indices specified as arguments to the test_gemm( ... ) interface. - Abstracted the function definition of getValueString( ... ) from the NRM2 testing interface to testinghelpers(renamed as get_value_string( ... ) for naming consistency), in order to use it as a helper function across all APIs in case of exception value testing. AMD-Internal: [CPUPL-3823] Change-Id: I0fea21f9c8759bbbdc88ba0a016202753e28f2a7
This commit is contained in:
@@ -614,4 +614,76 @@ template void print_matrix<double>( char, gtint_t, gtint_t, double *, gtint_t, c
|
||||
template void print_matrix<scomplex>( char, gtint_t, gtint_t, scomplex *, gtint_t, const char * );
|
||||
template void print_matrix<dcomplex>( char, gtint_t, gtint_t, dcomplex *, gtint_t, const char * );
|
||||
|
||||
|
||||
/*
|
||||
Helper function that returns a string based on the value that is passed
|
||||
The return values are as follows :
|
||||
If datatype is real : "nan", "inf"/"minus_inf", "value", where "value"
|
||||
is the string version of the value that is passed, if it is not nan/inf/-inf.
|
||||
|
||||
If the datatype is complex : The string is concatenated with both the real and
|
||||
imaginary components values, based on analysis done separately to each of them
|
||||
(similar to real datatype).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string get_value_string(T exval)
|
||||
{
|
||||
std::string exval_str;
|
||||
if constexpr (testinghelpers::type_info<T>::is_real)
|
||||
{
|
||||
if(std::isnan(exval))
|
||||
exval_str = "nan";
|
||||
else if(std::isinf(exval))
|
||||
exval_str = (exval >= 0) ? "inf" : "minus_inf";
|
||||
else
|
||||
exval_str = ( exval >= 0) ? std::to_string(int(exval)) : "minus_" + std::to_string(int(std::abs(exval)));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(std::isnan(exval.real))
|
||||
{
|
||||
exval_str = "nan";
|
||||
if(std::isinf(exval.imag))
|
||||
exval_str = exval_str + "pi" + ((exval.imag >= 0) ? "inf" : "minus_inf");
|
||||
else
|
||||
exval_str = exval_str + "pi" + ((exval.imag >= 0)? std::to_string(int(exval.imag)) : "m" + std::to_string(int(std::abs(exval.imag))));
|
||||
}
|
||||
else if(std::isnan(exval.imag))
|
||||
{
|
||||
if(std::isinf(exval.real))
|
||||
exval_str = ((exval.real >= 0) ? "inf" : "minus_inf");
|
||||
else
|
||||
exval_str = ((exval.real >= 0)? std::to_string(int(exval.real)) : "m" + std::to_string(int(std::abs(exval.real))));
|
||||
exval_str = exval_str + "pinan";
|
||||
}
|
||||
else if(std::isinf(exval.real))
|
||||
{
|
||||
exval_str = ((exval.real >= 0) ? "inf" : "minus_inf");
|
||||
if(std::isnan(exval.imag))
|
||||
exval_str = exval_str + "pinan";
|
||||
else
|
||||
exval_str = exval_str + "pi" + ((exval.imag >= 0)? std::to_string(int(exval.imag)) : "m" + std::to_string(int(std::abs(exval.imag))));
|
||||
}
|
||||
else if(std::isinf(exval.imag))
|
||||
{
|
||||
if(std::isnan(exval.real))
|
||||
exval_str = "nan";
|
||||
else
|
||||
exval_str = ((exval.real >= 0)? std::to_string(int(exval.real)) : "m" + std::to_string(int(std::abs(exval.real))));
|
||||
|
||||
exval_str = exval_str + ((exval.imag >= 0) ? "inf" : "minus_inf");
|
||||
}
|
||||
else
|
||||
{
|
||||
exval_str = ((exval.real >= 0)? std::to_string(int(exval.real)) : "m" + std::to_string(int(std::abs(exval.real))));
|
||||
exval_str = exval_str + "pi" + ((exval.imag >= 0)? std::to_string(int(exval.imag)) : "m" + std::to_string(int(std::abs(exval.imag))));
|
||||
}
|
||||
}
|
||||
return exval_str;
|
||||
}
|
||||
template std::string testinghelpers::get_value_string( float );
|
||||
template std::string testinghelpers::get_value_string( double );
|
||||
template std::string testinghelpers::get_value_string( scomplex );
|
||||
template std::string testinghelpers::get_value_string( dcomplex );
|
||||
|
||||
} //end of namespace testinghelpers
|
||||
Reference in New Issue
Block a user