@@ -257,6 +257,27 @@ bool py_object_is_any_map(const py::object& py_obj) {
257
257
});
258
258
}
259
259
260
+ bool py_object_is_map_str_str (const py::object& py_obj) {
261
+ if (!py::isinstance<py::dict>(py_obj)) {
262
+ return false ;
263
+ }
264
+ auto dict = py::cast<py::dict>(py_obj);
265
+ return std::all_of (dict.begin (), dict.end (), [&](const std::pair<py::object::handle, py::object::handle>& elem) {
266
+ return py::isinstance<py::str>(elem.first ) && py::isinstance<py::str>(elem.second );
267
+ });
268
+ }
269
+
270
+ std::map<std::string, std::string> py_object_to_map_str_str (const py::object& py_obj) {
271
+ OPENVINO_ASSERT (py_object_is_map_str_str (py_obj), " Unsupported attribute type." );
272
+ std::map<std::string, std::string> return_value = {};
273
+ for (auto & item : py::cast<py::dict>(py_obj)) {
274
+ std::string key = py::cast<std::string>(item.first );
275
+ std::string value = py::cast<std::string>(item.second );
276
+ return_value[key] = value;
277
+ }
278
+ return return_value;
279
+ }
280
+
260
281
ov::AnyMap py_object_to_any_map (const py::object& py_obj) {
261
282
OPENVINO_ASSERT (py_object_is_any_map (py_obj), " Unsupported attribute type." );
262
283
ov::AnyMap return_value = {};
@@ -332,7 +353,9 @@ ov::Any py_object_to_any(const py::object& py_obj) {
332
353
default :
333
354
OPENVINO_ASSERT (false , " Unsupported attribute type." );
334
355
}
335
-
356
+ // W/A For NPU
357
+ } else if (py_object_is_map_str_str (py_obj)) {
358
+ return py_object_to_map_str_str (py_obj);
336
359
// OV types
337
360
} else if (py_object_is_any_map (py_obj)) {
338
361
return py_object_to_any_map (py_obj);
0 commit comments