Skip to content

Commit

Permalink
[intel-npu] Adding new read-only property: NPU_COMPILER_VERSION (#28314)
Browse files Browse the repository at this point in the history
### Details:
 - extending compiler adapter interfaces with getApiVersion functions
 - adding new public read-only property to expose compiler api version

### Tickets:
 - *EISW-151484*
  • Loading branch information
csoka authored Jan 13, 2025
1 parent 0db7f8e commit 2b0f127
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ offer a limited set of supported OpenVINO features.
ov::intel_npu::device_alloc_mem_size
ov::intel_npu::device_total_mem_size
ov::intel_npu::driver_version
ov::intel_npu::compiler_version
.. note::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ void regmodule_properties(py::module m) {
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_RO(m_intel_npu, ov::intel_npu::compiler_version, "compiler_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");
Expand Down
1 change: 1 addition & 0 deletions src/bindings/python/tests/test_runtime/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def test_conflicting_enum(proxy_enums, expected_values):
(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"),
(intel_npu.compiler_version, "NPU_COMPILER_VERSION"),
],
)
def test_properties_ro(ov_property_ro, expected_value):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ static constexpr ov::Property<uint64_t, ov::PropertyMutability::RO> device_total
*/
static constexpr ov::Property<uint32_t, ov::PropertyMutability::RO> driver_version{"NPU_DRIVER_VERSION"};

/**
* @brief [Only for NPU plugin]
* Type: uint32_t
* Read-only property to get NPU compiler version. Composite of Major (16bit MSB) and Minor (16bit LSB)
* @ingroup ov_runtime_npu_prop_cpp_api
*/
static constexpr ov::Property<uint32_t, ov::PropertyMutability::RO> compiler_version{"NPU_COMPILER_VERSION"};

/**
* @brief [Only for NPU compiler]
* Type: std::string
Expand Down
1 change: 1 addition & 0 deletions src/plugins/intel_npu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ The following properties are supported:
| `ov::intel_npu::device_alloc_mem_size`/</br>`NPU_DEVICE_ALLOC_MEM_SIZE` | RO | Size of already allocated NPU DDR memory | `N/A` | `N/A` |
| `ov::intel_npu::device_total_mem_size`/</br>`NPU_DEVICE_TOTAL_MEM_SIZE` | RO | Size of available NPU DDR memory | `N/A` | `N/A` |
| `ov::intel_npu::driver_version`/</br>`NPU_DRIVER_VERSION` | RO | NPU driver version. | `N/A` | `N/A` |
| `ov::intel_npu::compiler_version`/</br>`NPU_COMPILER_VERSION` | RO | NPU compiler version. MSB 16 bits are Major version, LSB 16 bits are Minor version | `N/A` | `N/A` |
| `ov::intel_npu::compilation_mode_params`/</br>`NPU_COMPILATION_MODE_PARAMS` | RW | Set various parameters supported by the NPU compiler. (See bellow) | `<std::string>`| `N/A` |
| `ov::intel_npu::turbo`/</br>`NPU_TURBO` | RW | Set Turbo mode on/off | `YES`/ `NO`| `NO` |
| `ov::intel_npu::tiles`/</br>`NPU_TILES` | RW | Sets the number of npu tiles to compile the model for | `[0-]` | `-1` |
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/intel_npu/src/al/include/intel_npu/icompiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ class ICompiler : public std::enable_shared_from_this<ICompiler> {
*/
virtual NetworkMetadata parse(const std::vector<uint8_t>& network, const Config& config) const = 0;

/**
* @brief Returns the compiler version
* @return composite uint32_t value of compiler version.
* MSB 16 bits = Major version
* LSB 16bits = Minor version
*/
virtual uint32_t get_version() const = 0;

virtual std::vector<ov::ProfilingInfo> process_profiling_output(const std::vector<uint8_t>& profData,
const std::vector<uint8_t>& network,
const Config& config) const = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ICompilerAdapter {
const Config& config) const = 0;
virtual std::shared_ptr<IGraph> parse(std::vector<uint8_t> network, const Config& config) const = 0;
virtual ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const Config& config) const = 0;
virtual uint32_t get_version() const = 0;

virtual ~ICompilerAdapter() = default;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class DriverCompilerAdapter final : public ICompilerAdapter {

ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const Config& config) const override;

uint32_t get_version() const override;

private:
/**
* @brief Serialize input / output information to string format.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class PluginCompilerAdapter final : public ICompilerAdapter {

ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const Config& config) const override;

uint32_t get_version() const override;

private:
std::shared_ptr<ZeroInitStructsHolder> _zeroInitStruct;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ ov::SupportedOpsMap DriverCompilerAdapter::query(const std::shared_ptr<const ov:
return result;
}

uint32_t DriverCompilerAdapter::get_version() const {
return _zeroInitStruct->getCompilerVersion();
}

/**
* @brief Place xml + weights in sequential memory
* @details Format of the memory:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,8 @@ ov::SupportedOpsMap PluginCompilerAdapter::query(const std::shared_ptr<const ov:
return _compiler->query(model, config);
}

uint32_t PluginCompilerAdapter::get_version() const {
return _compiler->get_version();
}

} // namespace intel_npu
9 changes: 9 additions & 0 deletions src/plugins/intel_npu/src/plugin/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,15 @@ Plugin::Plugin()
[&](const Config& config) {
return _metrics->GetDriverVersion();
}}},
{ov::intel_npu::compiler_version.name(),
{true,
ov::PropertyMutability::RO,
[&](const Config& config) {
/// create dummy compiler
CompilerAdapterFactory compilerAdapterFactory;
auto dummyCompiler = compilerAdapterFactory.getCompiler(_backends->getIEngineBackend(), config);
return dummyCompiler->get_version();
}}},
{ov::intel_npu::compilation_mode_params.name(),
{true,
ov::PropertyMutability::RW,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class ZeroInitStructsHolder final {
inline uint32_t getDriverVersion() const {
return driver_properties.driverVersion;
}
inline uint32_t getCompilerVersion() const {
return compiler_version;
}
inline uint32_t getMutableCommandListVersion() const {
return mutable_command_list_version;
}
Expand Down Expand Up @@ -85,6 +88,8 @@ class ZeroInitStructsHolder final {
uint32_t mutable_command_list_version = 0;

ze_api_version_t ze_drv_api_version = {};

uint32_t compiler_version = 0;
};

} // namespace intel_npu
7 changes: 7 additions & 0 deletions src/plugins/intel_npu/src/utils/src/zero/zero_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ ZeroInitStructsHolder::ZeroInitStructsHolder() : log("NPUZeroInitStructsHolder",
ze_context_desc_t context_desc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC, 0, 0};
THROW_ON_FAIL_FOR_LEVELZERO("zeContextCreate", zeContextCreate(driver_handle, &context_desc, &context));
log.debug("ZeroInitStructsHolder initialize complete");

// Obtain compiler-in-driver (vcl) version
ze_device_graph_properties_t graph_props;
graph_props.stype = ZE_STRUCTURE_TYPE_DEVICE_GRAPH_PROPERTIES;
auto result = graph_dditable_ext_decorator->pfnDeviceGetGraphProperties(device_handle, &graph_props);
THROW_ON_FAIL_FOR_LEVELZERO("pfnDeviceGetGraphProperties", result);
compiler_version = ZE_MAKE_VERSION(graph_props.compilerVersion.major, graph_props.compilerVersion.minor);
}

ZeroInitStructsHolder::~ZeroInitStructsHolder() {
Expand Down

0 comments on commit 2b0f127

Please sign in to comment.