Skip to content

Commit 2c03306

Browse files
authored
[py-api] Add compiled_blob property to py API (#29614)
### Details: - Add `ov::hint::compiled_blob` property to python API ### Tickets: - CVS-164401 --------- Signed-off-by: Raasz, Pawel <[email protected]>
1 parent c7147b7 commit 2c03306

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/bindings/python/src/pyopenvino/core/properties/properties.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ void regmodule_properties(py::module m) {
100100
wrap_property_RW(m_hint, ov::hint::dynamic_quantization_group_size, "dynamic_quantization_group_size");
101101
wrap_property_RW(m_hint, ov::hint::kv_cache_precision, "kv_cache_precision");
102102
wrap_property_RW(m_hint, ov::hint::activations_scale_factor, "activations_scale_factor");
103+
wrap_property_RW(m_hint, ov::hint::compiled_blob, "compiled_blob");
103104

104105
// Submodule intel_cpu
105106
py::module m_intel_cpu =

src/bindings/python/src/pyopenvino/utils/utils.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ py::object from_ov_any(const ov::Any& any) {
269269
return py::cast(any.as<ov::frontend::type::PyNone>());
270270
} else if (any.is<ov::frontend::type::PyScalar>()) {
271271
return py::cast(any.as<ov::frontend::type::PyScalar>());
272+
} else if (any.is<ov::Tensor>()) {
273+
return py::cast(any.as<ov::Tensor>());
272274
} else {
273275
PyErr_SetString(PyExc_TypeError, "Failed to convert parameter to Python representation!");
274276
return py::cast<py::object>((PyObject*)NULL);

src/bindings/python/tests/test_runtime/test_properties.py

+9
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,15 @@ def test_properties_rw(ov_property_rw, expected_value, test_values):
474474
###
475475
# Special cases
476476
###
477+
def test_compiled_blob_property():
478+
assert hints.compiled_blob == "COMPILED_BLOB"
479+
compiled_blob = hints.compiled_blob(ov.Tensor(Type.u8, [2, 5]))
480+
481+
assert compiled_blob[0] == "COMPILED_BLOB"
482+
assert compiled_blob[1].value.element_type == Type.u8
483+
assert compiled_blob[1].value.shape == [2, 5]
484+
485+
477486
def test_properties_device_priorities():
478487
assert device.priorities == "MULTI_DEVICE_PRIORITIES"
479488
assert device.priorities("CPU,GPU") == ("MULTI_DEVICE_PRIORITIES", OVAny("CPU,GPU,"))

0 commit comments

Comments
 (0)