Commit a2df5c7c authored by gcwenger's avatar gcwenger Committed by Scott Cyphers

Converted some unit tests to all_close_f (#2601)

* Test convolution via all_close_f

* Test avg pool via all_close_f

* Moved constant into start of generated file
parent ee1a5ca8
......@@ -1249,7 +1249,8 @@ NGRAPH_TEST_P(${BACKEND_NAME}, avg_pool_3d_params, avg_pool_3d_uneven_strided_pa
auto backend_results = execute(cpu_f, args, "${BACKEND_NAME}");
for (size_t i = 0; i < backend_results.size(); i++)
{
EXPECT_TRUE(test::all_close(backend_results.at(i), int_results.at(i), 1.0e-4f, 1.0e-4f));
EXPECT_TRUE(test::all_close_f(
backend_results.at(i), int_results.at(i), DEFAULT_FLOAT_TOLERANCE_BITS + 1));
}
}
......
This diff is collapsed.
......@@ -248,7 +248,7 @@ NGRAPH_TEST (${BACKEND_NAME}, %s)
auto handle = backend->compile(function);
handle->call_with_validate({result}, {a, b});
EXPECT_TRUE(test::all_close<float>(vector<float>{expected_result}, read_vector<float>(result), 1.0e-4f, 1.0e-6f));
EXPECT_TRUE(test::all_close_f(vector<float>{expected_result}, read_vector<float>(result), tolerance));
// only test backprop for certain cases as it takes significant compute resources
%sEXPECT_TRUE(autodiff_numeric_compare<float>(backend.get(), make_graph, {a, b}, .01f, .01f));
}
......@@ -358,6 +358,7 @@ def main():
#include "ngraph/ngraph.hpp"
#include "util/test_tools.hpp"
#include "util/autodiff/numeric_compare.hpp"
#include "util/all_close_f.hpp"
#include "util/test_control.hpp"
using namespace std;
......@@ -365,6 +366,11 @@ using namespace ngraph;
static string s_manifest = "${MANIFEST}";
// for float this will be 18 bits matching
// for bfloat this will be 6 bits matching
constexpr int three_quarters_of_available_bits = (MAX_FLOAT_BITS * 3) / 4;
constexpr int tolerance = FLOAT_MANTISSA_BITS - three_quarters_of_available_bits;
''')
for t in tests:
......
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