Commit 0d7cc027 authored by Rob Earhart's avatar Rob Earhart

Adjust PlaidML test tolerances

parent ba226a14
...@@ -255,6 +255,8 @@ endif() ...@@ -255,6 +255,8 @@ endif()
if (NGRAPH_PLAIDML_ENABLE) if (NGRAPH_PLAIDML_ENABLE)
target_link_libraries(unit-test PRIVATE plaidml_backend) target_link_libraries(unit-test PRIVATE plaidml_backend)
# Some PlaidML devices aren't so precise, so we increase the allowable tolerance.
target_compile_definitions(unit-test PRIVATE "PlaidML_FLOAT_TOLERANCE_BITS=12")
endif() endif()
if (NGRAPH_TBB_ENABLE) if (NGRAPH_TBB_ENABLE)
......
...@@ -21,6 +21,16 @@ ...@@ -21,6 +21,16 @@
#include <random> #include <random>
#include <string> #include <string>
// clang-format off
#ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
#define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
#endif
#ifdef ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
#define DEFAULT_DOUBLE_TOLERANCE_BITS ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
#endif
// clang-format on
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "ngraph/ngraph.hpp" #include "ngraph/ngraph.hpp"
#include "util/all_close.hpp" #include "util/all_close.hpp"
......
...@@ -22,6 +22,16 @@ ...@@ -22,6 +22,16 @@
#include <string> #include <string>
#include "gtest/gtest.h" #include "gtest/gtest.h"
// clang-format off
#ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
#define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
#endif
#ifdef ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
#define DEFAULT_DOUBLE_TOLERANCE_BITS ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
#endif
// clang-format on
#include "ngraph/autodiff/adjoints.hpp" #include "ngraph/autodiff/adjoints.hpp"
#include "ngraph/graph_util.hpp" #include "ngraph/graph_util.hpp"
#include "ngraph/log.hpp" #include "ngraph/log.hpp"
...@@ -5234,7 +5244,7 @@ NGRAPH_TEST(${BACKEND_NAME}, sigmoid_bprop_n1c1h4) ...@@ -5234,7 +5244,7 @@ NGRAPH_TEST(${BACKEND_NAME}, sigmoid_bprop_n1c1h4)
handle->call_with_validate({result}, {a, b}); handle->call_with_validate({result}, {a, b});
vector<float> expected{0.196612f, 0.0176627f, 0.196612f, 0.0176627f}; vector<float> expected{0.196612f, 0.0176627f, 0.196612f, 0.0176627f};
EXPECT_TRUE(test::all_close(expected, read_vector<float>(result))); EXPECT_TRUE(test::all_close_f(expected, read_vector<float>(result)));
} }
NGRAPH_TEST(${BACKEND_NAME}, relu_2Dfprop) NGRAPH_TEST(${BACKEND_NAME}, relu_2Dfprop)
...@@ -5540,7 +5550,7 @@ NGRAPH_TEST(${BACKEND_NAME}, softmax_underflow) ...@@ -5540,7 +5550,7 @@ NGRAPH_TEST(${BACKEND_NAME}, softmax_underflow)
handle->call_with_validate({result}, {a}); handle->call_with_validate({result}, {a});
vector<float> expected{ vector<float> expected{
expf(low) / d0, expf(1) / d1, expf(2) / d2, expf(3) / d0, expf(4) / d1, expf(5) / d2}; expf(low) / d0, expf(1) / d1, expf(2) / d2, expf(3) / d0, expf(4) / d1, expf(5) / d2};
EXPECT_TRUE(test::all_close(expected, read_vector<float>(result))); EXPECT_TRUE(test::all_close_f(expected, read_vector<float>(result)));
} }
NGRAPH_TEST(${BACKEND_NAME}, softmax_overflow) NGRAPH_TEST(${BACKEND_NAME}, softmax_overflow)
......
...@@ -21,6 +21,16 @@ ...@@ -21,6 +21,16 @@
#include <random> #include <random>
#include <string> #include <string>
// clang-format off
#ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
#define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
#endif
#ifdef ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
#define DEFAULT_DOUBLE_TOLERANCE_BITS ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
#endif
// clang-format on
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "ngraph/ngraph.hpp" #include "ngraph/ngraph.hpp"
#include "util/all_close.hpp" #include "util/all_close.hpp"
......
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