Skip to content

Commit

Permalink
[PyOV] Add npu properties (#28358)
Browse files Browse the repository at this point in the history
### Details:
 - Add NPU properties to Python API

### Tickets:
 - *ticket-id*
  • Loading branch information
akuporos authored Jan 10, 2025
1 parent 8b9579d commit fcf8ce5
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

# Properties
import openvino._pyopenvino.properties.intel_npu as __intel_npu
from openvino.properties._properties import __make_properties

__make_properties(__intel_npu, __name__)
19 changes: 19 additions & 0 deletions src/bindings/python/src/pyopenvino/core/properties/properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

#include "pyopenvino/core/properties/properties.hpp"

#include "openvino/runtime/auto/properties.hpp"
#include "openvino/runtime/intel_cpu/properties.hpp"
#include "openvino/runtime/intel_gpu/properties.hpp"
#include "openvino/runtime/intel_npu/properties.hpp"
#include "pyopenvino/core/common.hpp"
#include "pyopenvino/graph/any.hpp"
#include "pyopenvino/utils/utils.hpp"
Expand Down Expand Up @@ -316,4 +320,19 @@ void regmodule_properties(py::module m) {
wrap_property_RW(m_intel_auto, ov::intel_auto::enable_startup_fallback, "enable_startup_fallback");
wrap_property_RW(m_intel_auto, ov::intel_auto::enable_runtime_fallback, "enable_runtime_fallback");
wrap_property_RW(m_intel_auto, ov::intel_auto::schedule_policy, "schedule_policy");

// Submodule npu
py::module m_intel_npu =
m_properties.def_submodule("intel_npu", "openvino.properties.intel_npu submodule that simulates ov::intel_npu");

wrap_property_RO(m_intel_npu, ov::intel_npu::device_alloc_mem_size, "device_alloc_mem_size");
wrap_property_RO(m_intel_npu, ov::intel_npu::device_total_mem_size, "device_total_mem_size");
wrap_property_RO(m_intel_npu, ov::intel_npu::driver_version, "driver_version");

wrap_property_RW(m_intel_npu, ov::intel_npu::compilation_mode_params, "compilation_mode_params");
wrap_property_RW(m_intel_npu, ov::intel_npu::turbo, "turbo");
wrap_property_RW(m_intel_npu, ov::intel_npu::tiles, "tiles");
wrap_property_RW(m_intel_npu, ov::intel_npu::max_tiles, "max_tiles");
wrap_property_RW(m_intel_npu, ov::intel_npu::bypass_umd_caching, "bypass_umd_caching");
wrap_property_RW(m_intel_npu, ov::intel_npu::defer_weights_load, "defer_weights_load");
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
#include <pybind11/stl.h>

#include "openvino/runtime/properties.hpp"
#include "openvino/runtime/intel_cpu/properties.hpp"
#include "openvino/runtime/intel_gpu/properties.hpp"
#include "openvino/runtime/auto/properties.hpp"
#include "pyopenvino/core/properties/properties.hpp"

namespace py = pybind11;

Expand Down
34 changes: 34 additions & 0 deletions src/bindings/python/tests/test_runtime/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import openvino.properties.intel_auto as intel_auto
import openvino.properties.intel_gpu as intel_gpu
import openvino.properties.intel_gpu.hint as intel_gpu_hint
import openvino.properties.intel_npu as intel_npu
import openvino.properties.device as device
import openvino.properties.log as log
import openvino.properties.streams as streams
Expand Down Expand Up @@ -190,6 +191,9 @@ def test_conflicting_enum(proxy_enums, expected_values):
(intel_gpu.uarch_version, "GPU_UARCH_VERSION"),
(intel_gpu.execution_units_count, "GPU_EXECUTION_UNITS_COUNT"),
(intel_gpu.memory_statistics, "GPU_MEMORY_STATISTICS"),
(intel_npu.device_alloc_mem_size, "NPU_DEVICE_ALLOC_MEM_SIZE"),
(intel_npu.device_total_mem_size, "NPU_DEVICE_TOTAL_MEM_SIZE"),
(intel_npu.driver_version, "NPU_DRIVER_VERSION"),
],
)
def test_properties_ro(ov_property_ro, expected_value):
Expand Down Expand Up @@ -417,6 +421,36 @@ def test_properties_ro(ov_property_ro, expected_value):
"AVAILABLE_DEVICE_MEM_SIZE",
((128, 128),),
),
(
intel_npu.compilation_mode_params,
"NPU_COMPILATION_MODE_PARAMS",
(("dummy-op-replacement=true", "dummy-op-replacement=true"),),
),
(
intel_npu.turbo,
"NPU_TURBO",
((True, True),),
),
(
intel_npu.tiles,
"NPU_TILES",
((128, 128),),
),
(
intel_npu.max_tiles,
"NPU_MAX_TILES",
((128, 128),),
),
(
intel_npu.bypass_umd_caching,
"NPU_BYPASS_UMD_CACHING",
((True, True),),
),
(
intel_npu.defer_weights_load,
"NPU_DEFER_WEIGHTS_LOAD",
((True, True),),
),
],
)
def test_properties_rw(ov_property_rw, expected_value, test_values):
Expand Down

0 comments on commit fcf8ce5

Please sign in to comment.