Merge pull request #17605 from TolyaTalamanov:at/fix-plaidml-kernels-function

This commit is contained in:
Alexander Alekhin 2020-06-24 09:44:51 +00:00
commit 4f03f70968
2 changed files with 23 additions and 6 deletions

View File

@ -5,12 +5,14 @@
// Copyright (C) 2019 Intel Corporation // Copyright (C) 2019 Intel Corporation
#ifdef HAVE_PLAIDML
#include "precomp.hpp" #include "precomp.hpp"
#include <opencv2/gapi/core.hpp> #include <opencv2/gapi/core.hpp>
#include <opencv2/gapi/plaidml/core.hpp> #include <opencv2/gapi/plaidml/core.hpp>
#ifdef HAVE_PLAIDML
#include <opencv2/gapi/plaidml/gplaidmlkernel.hpp> #include <opencv2/gapi/plaidml/gplaidmlkernel.hpp>
#include <plaidml2/edsl/edsl.h> #include <plaidml2/edsl/edsl.h>
@ -51,4 +53,12 @@ cv::gapi::GKernelPackage cv::gapi::core::plaidml::kernels()
return pkg; return pkg;
} }
#endif // HACE_PLAIDML #else // HAVE_PLAIDML
cv::gapi::GKernelPackage cv::gapi::core::plaidml::kernels()
{
// Still provide this symbol to avoid linking issues
util::throw_error(std::runtime_error("G-API has been compiled without PlaidML2 support"));
}
#endif // HAVE_PLAIDML

View File

@ -5,8 +5,6 @@
// Copyright (C) 2019 Intel Corporation // Copyright (C) 2019 Intel Corporation
#ifdef HAVE_PLAIDML
#include "test_precomp.hpp" #include "test_precomp.hpp"
#include <stdexcept> #include <stdexcept>
@ -19,6 +17,8 @@
namespace opencv_test namespace opencv_test
{ {
#ifdef HAVE_PLAIDML
inline cv::gapi::plaidml::config getConfig() inline cv::gapi::plaidml::config getConfig()
{ {
auto read_var_from_env = [](const char* env) auto read_var_from_env = [](const char* env)
@ -173,6 +173,13 @@ TEST(GAPI_PlaidML_Pipelines, TwoOutputOperations)
EXPECT_EQ(0, cv::norm(out_mat[1], ref_mat[1])); EXPECT_EQ(0, cv::norm(out_mat[1], ref_mat[1]));
} }
} // namespace opencv_test #else // HAVE_PLAIDML
TEST(GAPI_PlaidML_Pipelines, ThrowIfPlaidMLNotFound)
{
ASSERT_ANY_THROW(cv::gapi::core::plaidml::kernels());
}
#endif // HAVE_PLAIDML #endif // HAVE_PLAIDML
} // namespace opencv_test