OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
Switch pybind11 to 3.0.0 (#31409)
Anastasia Kuporosova9d76359cd35a
diff --git a/src/bindings/python/src/pyopenvino/core/common.cpp b/src/bindings/python/src/pyopenvino/core/common.cppindex e06d5a8e947..117ed60308b 100644--- a/src/bindings/python/src/pyopenvino/core/common.cpp+++ b/src/bindings/python/src/pyopenvino/core/common.cpp@@ -572,14 +572,14 @@ ov::PartialShape partial_shape_from_list(const py::list& shape) {std::to_string(bounded_dim.size()) + " elements were given.");}if (!(py::isinstance<py::int_>(bounded_dim[0]) && py::isinstance<py::int_>(bounded_dim[1]))) {- throw py::type_error("Incorrect pair of types (" + std::string(py::str(bounded_dim[0].get_type())) +- ", " + std::string(py::str(bounded_dim[1].get_type())) ++ throw py::type_error("Incorrect pair of types (" + std::string(py::str(py::type::of(bounded_dim[0]))) ++ ", " + std::string(py::str(py::type::of(bounded_dim[1]))) +") for dynamic dimension, ints are expected.");}pshape.insert(pshape.end(),ov::Dimension(bounded_dim[0].cast<value_type>(), bounded_dim[1].cast<value_type>()));} else {- throw py::type_error("Incorrect type " + std::string(py::str(dim.get_type())) ++ throw py::type_error("Incorrect type " + std::string(py::str(py::type::of(dim))) +" for dimension. Expected types are: ""int, str, openvino.Dimension, list/tuple with lower and upper values for ""dynamic dimension.");@@ -595,7 +595,7 @@ const ov::Tensor& cast_to_tensor(const py::handle& tensor) {return tensor.cast<const RemoteTensorWrapper&>().tensor;}- throw py::type_error("Unable to cast " + std::string(py::str(tensor.get_type())) + " object to ov::Tensor");+ throw py::type_error("Unable to cast " + std::string(py::str(py::type::of(tensor))) + " object to ov::Tensor");}void set_request_tensors(ov::InferRequest& request, const py::dict& inputs) {diff --git a/src/bindings/python/src/pyopenvino/core/common.hpp b/src/bindings/python/src/pyopenvino/core/common.hppindex 335b0eed974..54e1b5d6595 100644--- a/src/bindings/python/src/pyopenvino/core/common.hpp+++ b/src/bindings/python/src/pyopenvino/core/common.hpp@@ -179,7 +179,7 @@ ov::pass::Serialize::Version convert_to_version(const std::string& version);template <typename T>std::string get_class_name(const T& obj) {- return py::str(py::cast(obj).get_type().attr("__name__"));+ return py::str(py::type::handle_of(py::cast(obj)).attr("__name__"));}template <typename T>diff --git a/src/bindings/python/src/pyopenvino/core/core.cpp b/src/bindings/python/src/pyopenvino/core/core.cppindex 1e547dfbbe8..c5b23bab5fe 100644--- a/src/bindings/python/src/pyopenvino/core/core.cpp+++ b/src/bindings/python/src/pyopenvino/core/core.cpp@@ -505,7 +505,7 @@ void regclass_Core(py::module m) {return self.read_model(model_path_cpp, weights_path_cpp, any_map);}- throw py::type_error("Provided python object type " + (std::string)(py::str(model_path.get_type())) ++ throw py::type_error("Provided python object type " + (std::string)(py::str(py::type::of(model_path))) +" isn't supported as 'model' argument.");},py::arg("model"),diff --git a/src/bindings/python/src/pyopenvino/graph/attribute_visitor.cpp b/src/bindings/python/src/pyopenvino/graph/attribute_visitor.cppindex adb33797bfb..047c81864f5 100644--- a/src/bindings/python/src/pyopenvino/graph/attribute_visitor.cpp+++ b/src/bindings/python/src/pyopenvino/graph/attribute_visitor.cpp@@ -88,11 +88,11 @@ void regclass_graph_AttributeVisitor(py::module m) {break;default:throw py::type_error("Unsupported attribute type in provided list: " +- std::string(py::str(_list[0].get_type())));+ std::string(py::str(py::type::of(_list[0]))));}} else {throw py::type_error("Unsupported attribute type: " +- std::string(py::str(attribute.second.get_type())));+ std::string(py::str(py::type::of(attribute.second))));}}},diff --git a/src/bindings/python/src/pyopenvino/graph/model.cpp b/src/bindings/python/src/pyopenvino/graph/model.cppindex e65ac9a80c5..89c637b2c15 100644--- a/src/bindings/python/src/pyopenvino/graph/model.cpp+++ b/src/bindings/python/src/pyopenvino/graph/model.cpp@@ -103,7 +103,7 @@ static ov::Output<ov::Node> output_from_handle(ov::Model& model, const py::handl} else if (py::isinstance<ov::Output<ov::Node>>(handle)) {return handle.cast<ov::Output<ov::Node>>();} else {- throw py::type_error("Incorrect key type " + std::string(py::str(handle.get_type())) ++ throw py::type_error("Incorrect key type " + std::string(py::str(py::type::of(handle))) +" to reshape a model, expected keys as openvino.Output, int or str.");}}@@ -116,7 +116,7 @@ static ov::PartialShape partial_shape_from_handle(const py::handle& handle) {} else if (py::isinstance<py::str>(handle)) {return ov::PartialShape(handle.cast<std::string>());} else {- throw py::type_error("Incorrect value type " + std::string(py::str(handle.get_type())) ++ throw py::type_error("Incorrect value type " + std::string(py::str(py::type::of(handle))) +" to reshape a model, expected values as openvino.PartialShape, str, list or tuple.");}}@@ -125,7 +125,7 @@ static std::string string_from_handle(const py::handle& handle) {if (py::isinstance<py::str>(handle)) {return handle.cast<std::string>();} else {- throw py::type_error("Incorrect key type " + std::string(py::str(handle.get_type())) ++ throw py::type_error("Incorrect key type " + std::string(py::str(py::type::of(handle))) +" to reshape a model, expected values as str.");}}diff --git a/src/bindings/python/src/pyopenvino/graph/op.cpp b/src/bindings/python/src/pyopenvino/graph/op.cppindex 2068eb0ee16..27fa98e06e8 100644--- a/src/bindings/python/src/pyopenvino/graph/op.cpp+++ b/src/bindings/python/src/pyopenvino/graph/op.cpp@@ -39,7 +39,7 @@ std::shared_ptr<ov::Node> PyOp::clone_with_new_inputs(const ov::OutputVector& nereturn result.cast<std::shared_ptr<ov::Node>>();}// Default implementation for clone_with_new_inputs- auto py_handle_type = py_handle.get_type();+ auto py_handle_type = py::type::handle_of(py_handle);auto new_py_object = py_handle_type(new_args);return new_py_object.cast<std::shared_ptr<ov::Node>>();}diff --git a/src/bindings/python/src/pyopenvino/graph/op.hpp b/src/bindings/python/src/pyopenvino/graph/op.hppindex 9ea602b764c..e08f88cb391 100644--- a/src/bindings/python/src/pyopenvino/graph/op.hpp+++ b/src/bindings/python/src/pyopenvino/graph/op.hpp@@ -22,7 +22,7 @@ public:// Keeps a reference to the Python object to manage its lifetimePyOp(const py::object& py_obj) : py_handle(py_obj) {// Set default value for DiscreteTypeInfo- const auto py_class_name = py_handle.get_type().attr("__name__").cast<std::string>();+ const auto py_class_name = py::type::handle_of(py_handle).attr("__name__").cast<std::string>();m_type_info = std::make_shared<DiscreteTypeInfoWrapper>(py_class_name, "extension");}diff --git a/src/bindings/python/src/pyopenvino/graph/ops/parameter.cpp b/src/bindings/python/src/pyopenvino/graph/ops/parameter.cppindex fe84bc31c20..6dba421eb44 100644--- a/src/bindings/python/src/pyopenvino/graph/ops/parameter.cpp+++ b/src/bindings/python/src/pyopenvino/graph/ops/parameter.cpp@@ -20,7 +20,7 @@ void regclass_graph_op_Parameter(py::module m) {py::class_<ov::op::v0::Parameter, std::shared_ptr<ov::op::v0::Parameter>, ov::Node> parameter(m, "Parameter");parameter.doc() = "openvino.op.Parameter wraps ov::op::v0::Parameter";parameter.def("__repr__", [](const ov::Node& self) {- std::string class_name = py::cast(self).get_type().attr("__name__").cast<std::string>();+ std::string class_name = py::type::handle_of(py::cast(self)).attr("__name__").cast<std::string>();std::string shape = py::cast(self.get_output_partial_shape(0)).attr("__str__")().cast<std::string>();std::string type = self.get_element_type().c_type_string();return "<" + class_name + ": '" + self.get_friendly_name() + "' (" + shape + ", " + type + ")>";diff --git a/src/bindings/python/tests/test_runtime/test_dimension.py b/src/bindings/python/tests/test_runtime/test_dimension.pyindex 7b9e4078d99..1524a57bcc3 100644--- a/src/bindings/python/tests/test_runtime/test_dimension.py+++ b/src/bindings/python/tests/test_runtime/test_dimension.py@@ -10,7 +10,7 @@ def test_dynamic_dimension():assert dim.is_dynamicassert str(dim) == "?"assert dim.to_string() == "?"- assert str(dim.__repr__) == "<bound method PyCapsule.__repr__ of <Dimension: ?>>"+ assert "<Dimension: ?>" in str(dim.__repr__)def test_dynamic_dimension_with_bounds():diff --git a/src/bindings/python/thirdparty/pybind11 b/src/bindings/python/thirdparty/pybind11index 7c33cdc2d39..ed5057ded69 160000--- a/src/bindings/python/thirdparty/pybind11+++ b/src/bindings/python/thirdparty/pybind11@@ -1 +1 @@-Subproject commit 7c33cdc2d39c7b99a122579f53bc94c8eb3332ff+Subproject commit ed5057ded698e305210269dafa57574ecf964483