From: Anatoliy Talamanov Date: Sun, 21 Jun 2020 21:46:41 +0000 (+0300) Subject: Add implementation in case plaidml isn't found X-Git-Tag: submit/tizen/20210224.033012~2^2~152^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a74ed58893f2e7e27a914c44814c72a60069a9dc;p=platform%2Fupstream%2Fopencv.git Add implementation in case plaidml isn't found --- diff --git a/modules/gapi/src/backends/plaidml/gplaidmlcore.cpp b/modules/gapi/src/backends/plaidml/gplaidmlcore.cpp index e81e4b7..c15f84c 100644 --- a/modules/gapi/src/backends/plaidml/gplaidmlcore.cpp +++ b/modules/gapi/src/backends/plaidml/gplaidmlcore.cpp @@ -5,12 +5,14 @@ // Copyright (C) 2019 Intel Corporation -#ifdef HAVE_PLAIDML - #include "precomp.hpp" #include + #include + +#ifdef HAVE_PLAIDML + #include #include @@ -51,4 +53,12 @@ cv::gapi::GKernelPackage cv::gapi::core::plaidml::kernels() 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 diff --git a/modules/gapi/test/gapi_plaidml_pipelines.cpp b/modules/gapi/test/gapi_plaidml_pipelines.cpp index a090c99..56306b0 100644 --- a/modules/gapi/test/gapi_plaidml_pipelines.cpp +++ b/modules/gapi/test/gapi_plaidml_pipelines.cpp @@ -5,8 +5,6 @@ // Copyright (C) 2019 Intel Corporation -#ifdef HAVE_PLAIDML - #include "test_precomp.hpp" #include @@ -19,6 +17,8 @@ namespace opencv_test { +#ifdef HAVE_PLAIDML + inline cv::gapi::plaidml::config getConfig() { 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])); } -} // namespace opencv_test +#else // HAVE_PLAIDML + +TEST(GAPI_PlaidML_Pipelines, ThrowIfPlaidMLNotFound) +{ + ASSERT_ANY_THROW(cv::gapi::core::plaidml::kernels()); +} #endif // HAVE_PLAIDML + +} // namespace opencv_test