Improved dependencies handling for ie_wheel (#12666)

* Improved dependencies handling for ie_wheel

* Fixed compilation erros

Co-authored-by: Ilya Churaev <ilya.churaev@intel.com>
This commit is contained in:
Ilya Lavrenov 2022-08-22 11:09:56 +04:00 committed by GitHub
parent f26c3d035a
commit 0ac5cfd17a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 65 additions and 46 deletions

View File

@ -104,29 +104,12 @@ function(ie_add_plugin)
endif()
add_dependencies(ov_plugins ${IE_PLUGIN_NAME})
if(TARGET openvino_gapi_preproc)
if(BUILD_SHARED_LIBS)
add_dependencies(${IE_PLUGIN_NAME} openvino_gapi_preproc)
else()
target_link_libraries(${IE_PLUGIN_NAME} PRIVATE openvino_gapi_preproc)
endif()
endif()
# fake dependencies to build in the following order:
# IE -> IE readers -> IE inference plugins -> IE-based apps
# OV -> OV frontends -> OV inference plugins -> OV-based apps
if(BUILD_SHARED_LIBS)
if(TARGET openvino_ir_frontend)
add_dependencies(${IE_PLUGIN_NAME} openvino_ir_frontend)
endif()
if(TARGET openvino_onnx_frontend)
add_dependencies(${IE_PLUGIN_NAME} openvino_onnx_frontend)
endif()
if(TARGET openvino_paddle_frontend)
add_dependencies(${IE_PLUGIN_NAME} openvino_paddle_frontend)
endif()
if(TARGET openvino_tensorflow_frontend)
add_dependencies(${IE_PLUGIN_NAME} openvino_tensorflow_frontend)
endif()
add_dependencies(${IE_PLUGIN_NAME} ov_frontends)
# TODO: remove with legacy CNNNLayer API / IR v7
if(TARGET inference_engine_ir_v7_reader)
add_dependencies(${IE_PLUGIN_NAME} inference_engine_ir_v7_reader)

View File

@ -15,7 +15,6 @@ add_subdirectory(frontends)
if(ENABLE_TESTS)
add_subdirectory(core/tests)
endif()
add_subdirectory(bindings)
if(CMAKE_COMPILER_IS_GNUCXX)
ie_add_compiler_flags(-Wall)
@ -27,6 +26,7 @@ add_subdirectory(inference)
include(cmake/openvino.cmake)
# preprocessing has dependency on `openvino` for static build
add_subdirectory(common/preprocessing)
add_subdirectory(bindings)
if(ENABLE_TESTS)
add_subdirectory(tests_deprecated)

View File

@ -4,6 +4,12 @@
project(OpenVINO_C_API)
# TODO: fix it
if(CMAKE_COMPILER_IS_GNUCXX)
ie_add_compiler_flags(-Wno-error=sign-compare)
ie_add_compiler_flags(-Wno-error=missing-declarations)
endif()
add_subdirectory(src)
if(ENABLE_TESTS)

View File

@ -1113,7 +1113,7 @@ cdef class ExecutableNetwork:
"""
A tuple of :class:`InferRequest` instances
"""
cdef size_t c_infer_requests_size = deref(self.impl).infer_requests.size()
cdef int c_infer_requests_size = deref(self.impl).infer_requests.size()
if len(self._infer_requests) == 0:
for i in range(c_infer_requests_size):
infer_request = InferRequest()

View File

@ -40,7 +40,7 @@ std::map<std::string, InferenceEngine::Layout> layout_map = {{"ANY", InferenceEn
} \
}
uint32_t getOptimalNumberOfRequests(const InferenceEngine::ExecutableNetwork& actual) {
static uint32_t getOptimalNumberOfRequests(const InferenceEngine::ExecutableNetwork& actual) {
try {
auto parameter_value = actual.GetMetric(METRIC_KEY(SUPPORTED_METRICS));
auto supported_metrics = parameter_value.as<std::vector<std::string>>();
@ -61,7 +61,7 @@ uint32_t getOptimalNumberOfRequests(const InferenceEngine::ExecutableNetwork& ac
}
}
PyObject* parse_parameter(const InferenceEngine::Parameter& param) {
static PyObject* parse_parameter(const InferenceEngine::Parameter& param) {
// Check for std::string
if (param.is<std::string>()) {
return PyUnicode_FromString(param.as<std::string>().c_str());
@ -476,12 +476,12 @@ int InferenceEnginePython::IdleInferRequestQueue::wait(int num_requests, int64_t
std::unique_lock<std::mutex> lock(mutex);
if (timeout > 0) {
if (!cv.wait_for(lock, std::chrono::milliseconds(timeout), [this, num_requests]() {
return idle_ids.size() >= num_requests;
return static_cast<int>(idle_ids.size()) >= num_requests;
}))
return static_cast<int>(InferenceEngine::StatusCode::RESULT_NOT_READY);
} else
cv.wait(lock, [this, num_requests]() {
return idle_ids.size() >= num_requests;
return static_cast<int>(idle_ids.size()) >= num_requests;
});
return static_cast<int>(InferenceEngine::StatusCode::OK);
}
@ -508,7 +508,7 @@ void InferenceEnginePython::IEExecNetwork::createInferRequests(int num_requests)
}
infer_requests.resize(num_requests);
for (size_t i = 0; i < num_requests; ++i) {
for (int i = 0; i < num_requests; ++i) {
InferRequestWrap& infer_request = infer_requests[i];
infer_request.index = i;
request_queue_ptr->setRequestIdle(i);

View File

@ -30,6 +30,7 @@ public:
};
namespace impl {
namespace {
py::dict get_attributes(const std::shared_ptr<ngraph::Node>& node) {
util::DictAttributeSerializer dict_serializer(node);
return dict_serializer.get_attributes();
@ -42,6 +43,7 @@ void set_attribute(std::shared_ptr<ngraph::Node>& node, const std::string& atr_n
util::DictAttributeDeserializer dict_deserializer(attr_dict, variables);
node->visit_attributes(dict_deserializer);
}
} // namespace
} // namespace impl
namespace py = pybind11;

View File

@ -15,7 +15,7 @@
namespace py = pybind11;
void* numpy_to_c(py::array a) {
inline void* numpy_to_c(py::array a) {
py::buffer_info info = a.request();
return info.ptr;
}

View File

@ -112,7 +112,7 @@ public:
py::gil_scoped_acquire acquire;
try {
f_callback(_requests[handle], _user_ids[handle]);
} catch (py::error_already_set py_error) {
} catch (const py::error_already_set& py_error) {
// This should behave the same as assert(!PyErr_Occurred())
// since constructor for pybind11's error_already_set is
// performing PyErr_Fetch which clears error indicator and

View File

@ -125,7 +125,7 @@ ov::PartialShape partial_shape_from_list(const py::list& shape) {
return pshape;
}
bool check_all_digits(const std::string& value) {
inline bool check_all_digits(const std::string& value) {
auto val = ov::util::trim(value);
for (const auto& c : val) {
if (!std::isdigit(c) || c == '-') {

View File

@ -8,6 +8,7 @@
#include <pybind11/stl.h>
#include "common.hpp"
#include "pyopenvino/core/compiled_model.hpp"
#include "pyopenvino/core/containers.hpp"
#include "pyopenvino/core/infer_request.hpp"
#include "pyopenvino/utils/utils.hpp"

View File

@ -16,7 +16,7 @@
namespace py = pybind11;
std::string to_string(py::handle handle) {
inline std::string to_string(py::handle handle) {
auto encodedString = PyUnicode_AsUTF8String(handle.ptr());
return PyBytes_AsString(encodedString);
}

View File

@ -2,6 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "pyopenvino/core/extension.hpp"
#include <pybind11/functional.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

View File

@ -18,7 +18,7 @@ PYBIND11_MAKE_OPAQUE(Containers::TensorNameMap);
namespace py = pybind11;
py::dict run_sync_infer(InferRequestWrapper& self) {
inline py::dict run_sync_infer(InferRequestWrapper& self) {
{
py::gil_scoped_release release;
self._start_time = Time::now();

View File

@ -6,6 +6,8 @@
#include <pybind11/stl.h>
#include "pyopenvino/core/version.hpp"
namespace py = pybind11;
void regclass_Version(py::module m) {

View File

@ -2,6 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "pyopenvino/frontend/extension.hpp"
#include <pybind11/functional.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

View File

@ -2,6 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "pyopenvino/frontend/frontend.hpp"
#include <pybind11/functional.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

View File

@ -2,6 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "pyopenvino/frontend/input_model.hpp"
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/stl_bind.h>

View File

@ -9,6 +9,7 @@
#include <pybind11/stl_bind.h>
#include "openvino/frontend/exception.hpp"
#include "pyopenvino/frontend/manager.hpp"
namespace py = pybind11;

View File

@ -2,6 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "pyopenvino/frontend/place.hpp"
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/stl_bind.h>

View File

@ -24,7 +24,7 @@ using PyRTMap = ov::RTMap;
PYBIND11_MAKE_OPAQUE(PyRTMap);
void set_tensor_names(const ov::ParameterVector& parameters) {
static void set_tensor_names(const ov::ParameterVector& parameters) {
for (const auto& param : parameters) {
ov::Output<ov::Node> p = param;
if (p.get_node()->output(0).get_names().empty()) {
@ -34,7 +34,7 @@ void set_tensor_names(const ov::ParameterVector& parameters) {
}
}
ov::SinkVector cast_to_sink_vector(const std::vector<std::shared_ptr<ov::Node>>& nodes) {
static ov::SinkVector cast_to_sink_vector(const std::vector<std::shared_ptr<ov::Node>>& nodes) {
ov::SinkVector sinks;
for (const auto& node : nodes) {
auto sink = std::dynamic_pointer_cast<ov::op::Sink>(node);

View File

@ -9,6 +9,7 @@
#include "ngraph/log.hpp"
#include "openvino/core/node.hpp"
#include "openvino/op/util/multi_subgraph_base.hpp"
#include "pyopenvino/graph/ops/if.hpp"
#include "pyopenvino/graph/ops/util/multisubgraph.hpp"
namespace py = pybind11;

View File

@ -18,7 +18,7 @@
#include "openvino/pass/pattern/op/pattern.hpp"
#include "openvino/pass/pattern/op/wrap_type.hpp"
ov::NodeTypeInfo get_type(const std::string& type_name) {
static ov::NodeTypeInfo get_type(const std::string& type_name) {
// Supported types: opsetX.OpName or opsetX::OpName
std::string opset_type;
auto it = type_name.cbegin();
@ -60,7 +60,7 @@ ov::NodeTypeInfo get_type(const std::string& type_name) {
return m_opset.create(operation_type)->get_type_info();
}
std::vector<ov::NodeTypeInfo> get_types(const std::vector<std::string>& type_names) {
inline std::vector<ov::NodeTypeInfo> get_types(const std::vector<std::string>& type_names) {
std::vector<ov::NodeTypeInfo> types;
for (const auto& type_name : type_names) {
types.emplace_back(get_type(type_name));
@ -70,7 +70,7 @@ std::vector<ov::NodeTypeInfo> get_types(const std::vector<std::string>& type_nam
using Predicate = const ov::pass::pattern::op::ValuePredicate;
void reg_pattern_wrap_type(py::module m) {
static void reg_pattern_wrap_type(py::module m) {
py::class_<ov::pass::pattern::op::WrapType, std::shared_ptr<ov::pass::pattern::op::WrapType>, ov::Node> wrap_type(
m,
"WrapType");
@ -432,7 +432,7 @@ void reg_pattern_wrap_type(py::module m) {
)");
}
void reg_pattern_or(py::module m) {
static void reg_pattern_or(py::module m) {
py::class_<ov::pass::pattern::op::Or, std::shared_ptr<ov::pass::pattern::op::Or>, ov::Node> or_type(m, "Or");
or_type.doc() = "openvino.runtime.passes.Or wraps ov::pass::pattern::op::Or";
@ -459,7 +459,7 @@ void reg_pattern_or(py::module m) {
)");
}
void reg_pattern_any_input(py::module m) {
static void reg_pattern_any_input(py::module m) {
py::class_<ov::pass::pattern::op::Label, std::shared_ptr<ov::pass::pattern::op::Label>, ov::Node> any_input(
m,
"AnyInput");
@ -486,7 +486,7 @@ void reg_pattern_any_input(py::module m) {
)");
}
void reg_predicates(py::module m) {
inline void reg_predicates(py::module m) {
m.def("consumers_count", &ov::pass::pattern::consumers_count);
m.def("has_static_dim", &ov::pass::pattern::has_static_dim);
m.def("has_static_dims", &ov::pass::pattern::has_static_dims);

View File

@ -15,7 +15,7 @@ namespace py = pybind11;
template <typename... Args>
using overload_cast_ = pybind11::detail::overload_cast_impl<Args...>;
void* numpy_to_c(py::array a) {
inline void* numpy_to_c(py::array a) {
py::buffer_info info = a.request();
return info.ptr;
}

View File

@ -64,7 +64,7 @@
namespace py = pybind11;
std::string get_version() {
inline std::string get_version() {
auto version = ov::get_openvino_version();
return version.buildNumber;
}

View File

@ -14,6 +14,9 @@ PlaceStat PlaceMockPy::m_stat = {};
using namespace ngraph;
using namespace ov::frontend;
extern "C" MOCK_API FrontEndVersion GetAPIVersion();
extern "C" MOCK_API void* GetFrontEndData();
extern "C" MOCK_API FrontEndVersion GetAPIVersion() {
return OV_FRONTEND_API_VERSION;
}

View File

@ -140,6 +140,13 @@ if(ENABLE_GAPI_PREPROCESSING)
if(BUILD_SHARED_LIBS)
target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime)
# make plugin to depend on preprocessing library
foreach(plugin IN LISTS PLUGIN_FILES)
string(REPLACE ":" ";" plugin "${plugin}")
list(REMOVE_AT plugin 0)
add_dependencies(${plugin} openvino_gapi_preproc)
endforeach()
add_dependencies(ov_plugins openvino_gapi_preproc)
else()
# for static linkage the dependencies are in opposite order
target_link_libraries(openvino PRIVATE ${TARGET_NAME})
@ -156,9 +163,9 @@ if(ENABLE_GAPI_PREPROCESSING)
endif()
ie_add_api_validator_post_build_step(TARGET ${TARGET_NAME})
ie_add_vs_version_file(NAME ${TARGET_NAME}
FILEDESCRIPTION "Inference Engine Preprocessing plugin")
FILEDESCRIPTION "OpenVINO Preprocessing plugin")
endif()
target_include_directories(${TARGET_NAME} INTERFACE
@ -202,7 +209,7 @@ openvino_developer_export_targets(COMPONENT core TARGETS ${TARGET_NAME})
if(BUILD_SHARED_LIBS)
install(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION ${OV_CPACK_PLUGINSDIR}/ COMPONENT ${OV_CPACK_COMP_CORE})
LIBRARY DESTINATION ${OV_CPACK_PLUGINSDIR} COMPONENT ${OV_CPACK_COMP_CORE})
else()
ov_install_static_lib(${TARGET_NAME} ${OV_CPACK_COMP_CORE})
endif()

View File

@ -198,6 +198,9 @@ public:
}
};
extern "C" MOCK_API FrontEndVersion GetAPIVersion();
extern "C" MOCK_API void* GetFrontEndData();
extern "C" MOCK_API FrontEndVersion GetAPIVersion() {
return OV_FRONTEND_API_VERSION;
}

View File

@ -23,7 +23,7 @@ bool getStrAttribute(const pugi::xml_node& node, const std::string& name, std::s
return true;
}
bool check_all_digits(const std::string& value) {
inline bool check_all_digits(const std::string& value) {
auto val = ov::util::trim(value);
for (const auto& c : val) {
if (!std::isdigit(c) || c == '-')