diff --git a/src/python/py_generate_pipeline.cpp b/src/python/py_generate_pipeline.cpp index 9518e1ece4..acf1b1c70b 100644 --- a/src/python/py_generate_pipeline.cpp +++ b/src/python/py_generate_pipeline.cpp @@ -257,6 +257,27 @@ bool py_object_is_any_map(const py::object& py_obj) { }); } +bool py_object_is_map_str_str(const py::object& py_obj) { + if (!py::isinstance(py_obj)) { + return false; + } + auto dict = py::cast(py_obj); + return std::all_of(dict.begin(), dict.end(), [&](const std::pair& elem) { + return py::isinstance(elem.first) && py::isinstance(elem.second); + }); +} + +std::map py_object_to_map_str_str(const py::object& py_obj) { + OPENVINO_ASSERT(py_object_is_map_str_str(py_obj), "Unsupported attribute type."); + std::map return_value = {}; + for (auto& item : py::cast(py_obj)) { + std::string key = py::cast(item.first); + std::string value = py::cast(item.second); + return_value[key] = value; + } + return return_value; +} + ov::AnyMap py_object_to_any_map(const py::object& py_obj) { OPENVINO_ASSERT(py_object_is_any_map(py_obj), "Unsupported attribute type."); ov::AnyMap return_value = {}; @@ -332,7 +353,9 @@ ov::Any py_object_to_any(const py::object& py_obj) { default: OPENVINO_ASSERT(false, "Unsupported attribute type."); } - + // W/A For NPU + } else if (py_object_is_map_str_str(py_obj)) { + return py_object_to_map_str_str(py_obj); // OV types } else if (py_object_is_any_map(py_obj)) { return py_object_to_any_map(py_obj);