[PyOV] Fix warnings (#16674)
* [PyOV] Fix warnings * another win * fix codestyle * fix test * fix any * exclude some warnings
This commit is contained in:
parent
ff8f361778
commit
2e0bac34db
@ -34,7 +34,6 @@ endif()
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
# disable warning: This operator was deprecated and will be removed with v0 operation.
|
||||
add_compile_options(/wd4996)
|
||||
add_compile_options(/wd4244)
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
add_compile_options(-Wno-deprecated-register -Wno-range-loop-analysis)
|
||||
elseif(OV_COMPILER_IS_APPLECLANG)
|
||||
|
@ -36,7 +36,7 @@ void regclass_pyngraph_AxisSet(py::module m) {
|
||||
|
||||
axis_set.def("__repr__", [](const ngraph::AxisSet& self) -> std::string {
|
||||
std::stringstream data_ss;
|
||||
std::copy(self.begin(), self.end(), std::ostream_iterator<int>(data_ss, ", "));
|
||||
std::copy(self.begin(), self.end(), std::ostream_iterator<size_t>(data_ss, ", "));
|
||||
std::string data_str = data_ss.str();
|
||||
return "<AxisSet {" + data_str.substr(0, data_str.size() - 2) + "}>";
|
||||
});
|
||||
|
@ -26,7 +26,7 @@ void regclass_pyngraph_CoordinateDiff(py::module m) {
|
||||
|
||||
coordinate_diff.def("__str__", [](const ngraph::CoordinateDiff& self) -> std::string {
|
||||
std::stringstream stringstream;
|
||||
std::copy(self.begin(), self.end(), std::ostream_iterator<int>(stringstream, ", "));
|
||||
std::copy(self.begin(), self.end(), std::ostream_iterator<size_t>(stringstream, ", "));
|
||||
std::string string = stringstream.str();
|
||||
return string.substr(0, string.size() - 2);
|
||||
});
|
||||
|
@ -24,7 +24,7 @@ void regclass_pyngraph_Strides(py::module m) {
|
||||
|
||||
strides.def("__str__", [](const ngraph::Strides& self) -> std::string {
|
||||
std::stringstream stringstream;
|
||||
std::copy(self.begin(), self.end(), std::ostream_iterator<int>(stringstream, ", "));
|
||||
std::copy(self.begin(), self.end(), std::ostream_iterator<size_t>(stringstream, ", "));
|
||||
std::string string = stringstream.str();
|
||||
return string.substr(0, string.size() - 2);
|
||||
});
|
||||
|
@ -26,15 +26,8 @@ endif()
|
||||
|
||||
# compile options
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
# disable warning: This operator was deprecated and will be removed with v0 operation.
|
||||
add_compile_options(/wd4996)
|
||||
add_compile_options(/wd4244)
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
add_compile_options(-Wno-deprecated-register -Wno-range-loop-analysis)
|
||||
elseif(OV_COMPILER_IS_APPLECLANG)
|
||||
if(OV_COMPILER_IS_APPLECLANG)
|
||||
add_link_options(-stdlib=libc++)
|
||||
add_compile_options(-Wno-unused-value -Wno-range-loop-analysis)
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
# WA for GCC 7.5 "PYBIND11_NOINLINE inline" warning
|
||||
add_compile_options(-Wno-error=attributes)
|
||||
|
@ -288,14 +288,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(bounded_dim[0].get_type().str()) + ", " +
|
||||
std::string(bounded_dim[1].get_type().str()) +
|
||||
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())) +
|
||||
") 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(dim.get_type().str()) +
|
||||
throw py::type_error("Incorrect type " + std::string(py::str(dim.get_type())) +
|
||||
" for dimension. Expected types are: "
|
||||
"int, str, openvino.runtime.Dimension, list/tuple with lower and upper values for "
|
||||
"dynamic dimension.");
|
||||
|
@ -360,7 +360,7 @@ void regclass_Core(py::module m) {
|
||||
}
|
||||
|
||||
std::stringstream str;
|
||||
str << "Provided python object type " << model_path.get_type().str()
|
||||
str << "Provided python object type " << py::str(model_path.get_type())
|
||||
<< " isn't supported as 'model' argument.";
|
||||
OPENVINO_THROW(str.str());
|
||||
},
|
||||
|
@ -85,7 +85,7 @@ void regclass_frontend_NodeContext(py::module m) {
|
||||
auto any = self.get_attribute_as_any(name);
|
||||
|
||||
auto type = m.attr("Type");
|
||||
if (dtype == type) {
|
||||
if (dtype.is(type)) {
|
||||
if (any.is<int32_t>() || any.is<int64_t>()) {
|
||||
return py::cast(self.get_attribute<ov::element::Type>(name));
|
||||
} else if (any.is<std::vector<int32_t>>() || any.is<std::vector<int64_t>>()) {
|
||||
|
@ -75,14 +75,14 @@ void regclass_frontend_Place(py::module m) {
|
||||
place.def(
|
||||
"get_consuming_operations",
|
||||
[](const ov::frontend::Place& self, py::object outputName, py::object outputPortIndex) {
|
||||
if (outputName == py::none()) {
|
||||
if (outputPortIndex == py::none()) {
|
||||
if (outputName.is(py::none())) {
|
||||
if (outputPortIndex.is(py::none())) {
|
||||
return self.get_consuming_operations();
|
||||
} else {
|
||||
return self.get_consuming_operations(py::cast<int>(outputPortIndex));
|
||||
}
|
||||
} else {
|
||||
if (outputPortIndex == py::none()) {
|
||||
if (outputPortIndex.is(py::none())) {
|
||||
return self.get_consuming_operations(py::cast<std::string>(outputName));
|
||||
} else {
|
||||
return self.get_consuming_operations(py::cast<std::string>(outputName),
|
||||
@ -108,14 +108,14 @@ void regclass_frontend_Place(py::module m) {
|
||||
place.def(
|
||||
"get_target_tensor",
|
||||
[](const ov::frontend::Place& self, py::object outputName, py::object outputPortIndex) {
|
||||
if (outputName == py::none()) {
|
||||
if (outputPortIndex == py::none()) {
|
||||
if (outputName.is(py::none())) {
|
||||
if (outputPortIndex.is(py::none())) {
|
||||
return self.get_target_tensor();
|
||||
} else {
|
||||
return self.get_target_tensor(py::cast<int>(outputPortIndex));
|
||||
}
|
||||
} else {
|
||||
if (outputPortIndex == py::none()) {
|
||||
if (outputPortIndex.is(py::none())) {
|
||||
return self.get_target_tensor(py::cast<std::string>(outputName));
|
||||
} else {
|
||||
return self.get_target_tensor(py::cast<std::string>(outputName), py::cast<int>(outputPortIndex));
|
||||
@ -140,14 +140,14 @@ void regclass_frontend_Place(py::module m) {
|
||||
place.def(
|
||||
"get_producing_operation",
|
||||
[](const ov::frontend::Place& self, py::object inputName, py::object inputPortIndex) {
|
||||
if (inputName == py::none()) {
|
||||
if (inputPortIndex == py::none()) {
|
||||
if (inputName.is(py::none())) {
|
||||
if (inputPortIndex.is(py::none())) {
|
||||
return self.get_producing_operation();
|
||||
} else {
|
||||
return self.get_producing_operation(py::cast<int>(inputPortIndex));
|
||||
}
|
||||
} else {
|
||||
if (inputPortIndex == py::none()) {
|
||||
if (inputPortIndex.is(py::none())) {
|
||||
return self.get_producing_operation(py::cast<std::string>(inputName));
|
||||
} else {
|
||||
return self.get_producing_operation(py::cast<std::string>(inputName),
|
||||
@ -181,14 +181,14 @@ void regclass_frontend_Place(py::module m) {
|
||||
place.def(
|
||||
"get_input_port",
|
||||
[](const ov::frontend::Place& self, py::object inputName, py::object inputPortIndex) {
|
||||
if (inputName == py::none()) {
|
||||
if (inputPortIndex == py::none()) {
|
||||
if (inputName.is(py::none())) {
|
||||
if (inputPortIndex.is(py::none())) {
|
||||
return self.get_input_port();
|
||||
} else {
|
||||
return self.get_input_port(py::cast<int>(inputPortIndex));
|
||||
}
|
||||
} else {
|
||||
if (inputPortIndex == py::none()) {
|
||||
if (inputPortIndex.is(py::none())) {
|
||||
return self.get_input_port(py::cast<std::string>(inputName));
|
||||
} else {
|
||||
return self.get_input_port(py::cast<std::string>(inputName), py::cast<int>(inputPortIndex));
|
||||
@ -211,14 +211,14 @@ void regclass_frontend_Place(py::module m) {
|
||||
place.def(
|
||||
"get_output_port",
|
||||
[](const ov::frontend::Place& self, py::object outputName, py::object outputPortIndex) {
|
||||
if (outputName == py::none()) {
|
||||
if (outputPortIndex == py::none()) {
|
||||
if (outputName.is(py::none())) {
|
||||
if (outputPortIndex.is(py::none())) {
|
||||
return self.get_output_port();
|
||||
} else {
|
||||
return self.get_output_port(py::cast<int>(outputPortIndex));
|
||||
}
|
||||
} else {
|
||||
if (outputPortIndex == py::none()) {
|
||||
if (outputPortIndex.is(py::none())) {
|
||||
return self.get_output_port(py::cast<std::string>(outputName));
|
||||
} else {
|
||||
return self.get_output_port(py::cast<std::string>(outputName), py::cast<int>(outputPortIndex));
|
||||
@ -250,14 +250,14 @@ void regclass_frontend_Place(py::module m) {
|
||||
place.def(
|
||||
"get_source_tensor",
|
||||
[](const ov::frontend::Place& self, py::object inputName, py::object inputPortIndex) {
|
||||
if (inputName == py::none()) {
|
||||
if (inputPortIndex == py::none()) {
|
||||
if (inputName.is(py::none())) {
|
||||
if (inputPortIndex.is(py::none())) {
|
||||
return self.get_source_tensor();
|
||||
} else {
|
||||
return self.get_source_tensor(py::cast<int>(inputPortIndex));
|
||||
}
|
||||
} else {
|
||||
if (inputPortIndex == py::none()) {
|
||||
if (inputPortIndex.is(py::none())) {
|
||||
return self.get_source_tensor(py::cast<std::string>(inputName));
|
||||
} else {
|
||||
return self.get_source_tensor(py::cast<std::string>(inputName), py::cast<int>(inputPortIndex));
|
||||
|
@ -36,7 +36,7 @@ void regclass_graph_AxisSet(py::module m) {
|
||||
|
||||
axis_set.def("__repr__", [](const ov::AxisSet& self) -> std::string {
|
||||
std::stringstream data_ss;
|
||||
std::copy(self.begin(), self.end(), std::ostream_iterator<int>(data_ss, ", "));
|
||||
std::copy(self.begin(), self.end(), std::ostream_iterator<size_t>(data_ss, ", "));
|
||||
std::string data_str = data_ss.str();
|
||||
return "<AxisSet {" + data_str.substr(0, data_str.size() - 2) + "}>";
|
||||
});
|
||||
|
@ -24,7 +24,7 @@ void regclass_graph_CoordinateDiff(py::module m) {
|
||||
|
||||
coordinate_diff.def("__str__", [](const ov::CoordinateDiff& self) -> std::string {
|
||||
std::stringstream stringstream;
|
||||
std::copy(self.begin(), self.end(), std::ostream_iterator<int>(stringstream, ", "));
|
||||
std::copy(self.begin(), self.end(), std::ostream_iterator<size_t>(stringstream, ", "));
|
||||
std::string string = stringstream.str();
|
||||
return string.substr(0, string.size() - 2);
|
||||
});
|
||||
|
@ -347,7 +347,7 @@ void regclass_graph_Model(py::module m) {
|
||||
} else if (py::isinstance<ov::Output<ov::Node>>(item.first)) {
|
||||
new_shape.first = item.first.cast<ov::Output<ov::Node>>();
|
||||
} else {
|
||||
throw py::type_error("Incorrect key type " + std::string(item.first.get_type().str()) +
|
||||
throw py::type_error("Incorrect key type " + std::string(py::str(item.first.get_type())) +
|
||||
" to reshape a model, expected keys as openvino.runtime.Output, int or str.");
|
||||
}
|
||||
// check values
|
||||
@ -359,7 +359,7 @@ void regclass_graph_Model(py::module m) {
|
||||
new_shape.second = ov::PartialShape(item.second.cast<std::string>());
|
||||
} else {
|
||||
throw py::type_error(
|
||||
"Incorrect value type " + std::string(item.second.get_type().str()) +
|
||||
"Incorrect value type " + std::string(py::str(item.second.get_type())) +
|
||||
" to reshape a model, expected values as openvino.runtime.PartialShape, str, list or tuple.");
|
||||
}
|
||||
new_shapes.insert(new_shape);
|
||||
|
@ -24,7 +24,7 @@ void regclass_graph_Strides(py::module m) {
|
||||
|
||||
strides.def("__str__", [](const ov::Strides& self) -> std::string {
|
||||
std::stringstream stringstream;
|
||||
std::copy(self.begin(), self.end(), std::ostream_iterator<int>(stringstream, ", "));
|
||||
std::copy(self.begin(), self.end(), std::ostream_iterator<size_t>(stringstream, ", "));
|
||||
std::string string = stringstream.str();
|
||||
return string.substr(0, string.size() - 2);
|
||||
});
|
||||
|
@ -215,7 +215,7 @@ std::string convert_path_to_string(const py::object& path) {
|
||||
py::object Path = py::module_::import("pathlib").attr("Path");
|
||||
// check if model path is either a string or pathlib.Path
|
||||
if (py::isinstance(path, Path) || py::isinstance<py::str>(path)) {
|
||||
return path.str();
|
||||
return py::str(path);
|
||||
}
|
||||
// Convert bytes to string
|
||||
if (py::isinstance<py::bytes>(path)) {
|
||||
|
@ -6,7 +6,18 @@
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Warning occurred at the junction of pybind11
|
||||
// and the templates inside ov::Any.
|
||||
// Generated by operator `==` inside pybind::handle.
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4996 )
|
||||
#endif
|
||||
#include "openvino/core/any.hpp"
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
#include "openvino/core/type/element_type.hpp"
|
||||
#include "openvino/runtime/properties.hpp"
|
||||
#include "openvino/pass/serialize.hpp"
|
||||
|
Loading…
Reference in New Issue
Block a user