Commit 656b2f72 authored by gcwenger's avatar gcwenger Committed by Robert Kimball

Addressed some all_close_f loose ends (#2200)

* Simplified all_close_f tolerance determination. Made all_close_f less verbose. Transitioned graph comparison to use double comparison when appropriate.

* Reworked all_close_f AssertionResult returning code to include message in AssertionResult on success also.

* Added CMake option NGRAPH_GTEST_INFO, which controls whether or not any gtest info cout is done. Quiets all_close_f tests by default.

* Moved NGRAPH_GTEST_INFO from build option to environment variable.
parent dd41bb62
......@@ -150,9 +150,12 @@ protected:
TEST_P(all_close_f_param_test, test_boundaries)
{
// Print short string documenting which test is being run
std::cout << "[ INFO ] Test params: (" << expected << ", " << mantissa_bits << ", "
<< tolerance_bits << ")\n";
if (std::getenv("NGRAPH_GTEST_INFO") != nullptr)
{
// Print short string documenting which test is being run
std::cout << "[ INFO ] Test params: (" << expected << ", " << mantissa_bits << ", "
<< tolerance_bits << ")\n";
}
// Format verbose info to only print out in case of test failure
stringstream ss;
......@@ -190,7 +193,6 @@ TEST_P(all_close_f_param_test, test_boundaries)
<< ss.str();
}
// Avoid warning with how gtest defines INSTANTIATE_TEST_CASE_P
INSTANTIATE_TEST_CASE_P(
test_simple_floats_with_range_of_precisions,
all_close_f_param_test,
......@@ -279,8 +281,11 @@ protected:
TEST_P(all_close_f_double_param_test, test_boundaries)
{
// Print short string documenting which test is being run
std::cout << "[ INFO ] Test params: (" << expected << ", " << tolerance_bits << ")\n";
if (std::getenv("NGRAPH_GTEST_INFO") != nullptr)
{
// Print short string documenting which test is being run
std::cout << "[ INFO ] Test params: (" << expected << ", " << tolerance_bits << ")\n";
}
// Format verbose info to only print out in case of test failure
......@@ -313,7 +318,6 @@ TEST_P(all_close_f_double_param_test, test_boundaries)
<< ss.str();
}
// Avoid warning with how gtest defines INSTANTIATE_TEST_CASE_P
INSTANTIATE_TEST_CASE_P(
test_simple_doubles_with_range_of_precisions,
all_close_f_double_param_test,
......
......@@ -92,7 +92,7 @@ public:
test::all_close<char>(ref_data_vector, bk_isolated_data_vector);
EXPECT_TRUE(all_close_graph && all_close_isolated);
}
else if ((et == element::f32) || (et == element::f64))
else if (et == element::f32)
{
vector<float> ref_data_vector = read_float_vector(ref_data);
vector<float> bk_data_vector = read_float_vector(bk_data);
......@@ -106,6 +106,26 @@ public:
test::all_close_f(ref_data_vector, bk_isolated_data_vector);
EXPECT_TRUE(all_close_graph && all_close_isolated);
}
else if (et == element::f64)
{
vector<double> ref_data_vector = read_vector<double>(ref_data);
vector<double> bk_data_vector = read_vector<double>(bk_data);
vector<double> bk_isolated_data_vector = read_vector<double>(bk_isolated_data);
cout << "Test backed op run w/ original graph dependencies:" << endl;
print_results(ref_data_vector, bk_data_vector);
// When testing with original graph dependencies test w/ loose f64 tolerance
constexpr int tolerance_bits = 30;
bool all_close_graph =
test::all_close_f(ref_data_vector, bk_data_vector, tolerance_bits);
cout << "Test backed op run isolated w/ inputs from ref graph run:" << endl;
print_results(ref_data_vector, bk_isolated_data_vector);
// When testing with isolated graph dependencies test w/ default (tight) f64 tolerance
bool all_close_isolated =
test::all_close_f(ref_data_vector, bk_isolated_data_vector);
EXPECT_TRUE(all_close_graph && all_close_isolated);
}
else if (et == element::i8)
{
vector<int8_t> ref_data_vector = read_vector<int8_t>(ref_data);
......
This diff is collapsed.
......@@ -137,7 +137,7 @@ namespace ngraph
/// \returns Number of matching mantissa bits
///
/// See float_distance for limitations and assumptions.
uint64_t matching_mantissa_bits(uint64_t distance);
uint32_t matching_mantissa_bits(uint64_t distance);
/// \brief Check if the two floating point vectors are all close
/// \param a First number to compare
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment