This commit is contained in:
Chao Liu
2022-03-22 21:55:03 -05:00
committed by GitHub
parent d91f9f119c
commit 2206136628
10 changed files with 72 additions and 43 deletions

View File

@@ -55,10 +55,10 @@ check_err(const std::vector<T>& out,
}
bool check_err(const std::vector<_Float16>& out,
const std::vector<_Float16>& ref,
const std::string& msg,
_Float16 rtol = static_cast<_Float16>(1e-3f),
_Float16 atol = static_cast<_Float16>(1e-3f))
const std::vector<_Float16>& ref,
const std::string& msg,
_Float16 rtol = static_cast<_Float16>(1e-3f),
_Float16 atol = static_cast<_Float16>(1e-3f))
{
if(out.size() != ref.size())
{
@@ -69,14 +69,14 @@ bool check_err(const std::vector<_Float16>& out,
}
bool res{true};
int err_count = 0;
double err = 0;
double max_err = std::numeric_limits<_Float16>::min();
int err_count = 0;
double err = 0;
double max_err = std::numeric_limits<_Float16>::min();
for(std::size_t i = 0; i < ref.size(); ++i)
{
double out_ = double(out[i]);
double ref_ = double(ref[i]);
err = std::abs(out_ - ref_);
err = std::abs(out_ - ref_);
if(err > atol + rtol * std::abs(ref_) || !std::isfinite(out_) || !std::isfinite(ref_))
{
max_err = err > max_err ? err : max_err;