Skip to content

Commit

Permalink
[intel-npu] Adding CID version query api; Extend optimization_capabil…
Browse files Browse the repository at this point in the history
…ities property based on CID version
  • Loading branch information
csoka committed Nov 28, 2024
1 parent a1920c4 commit b76077f
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/plugins/intel_npu/src/backend/include/zero_backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ZeroEngineBackend final : public IEngineBackend {
const std::vector<std::string> getDeviceNames() const override;
uint32_t getDriverVersion() const override;
uint32_t getGraphExtVersion() const override;
uint32_t getCompilerVersion() const override;

bool isBatchingSupported() const override;
bool isCommandQueueExtSupported() const override;
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/intel_npu/src/backend/src/zero_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ uint32_t ZeroEngineBackend::getGraphExtVersion() const {
return _initStruct->getGraphDdiTable().version();
}

uint32_t ZeroEngineBackend::getCompilerVersion() const {
return _initStruct->getCompilerVersion();
}

bool ZeroEngineBackend::isBatchingSupported() const {
return _initStruct->isExtensionSupported("ZE_extension_graph_1_6", ZE_MAKE_VERSION(1, 6));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class IEngineBackend : public std::enable_shared_from_this<IEngineBackend> {
virtual uint32_t getDriverVersion() const;
/** @brief Provide driver extension version */
virtual uint32_t getGraphExtVersion() const;
/** @brief Provide compiler-in-driver version */
virtual uint32_t getCompilerVersion() const;
/** @brief Get name of backend */
virtual const std::string getName() const = 0;
/** @brief Backend has support for concurrency batching */
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/intel_npu/src/common/src/npu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ uint32_t IEngineBackend::getGraphExtVersion() const {
OPENVINO_THROW("Get NPU driver extension version is not supported with this backend");
}

uint32_t IEngineBackend::getCompilerVersion() const {
OPENVINO_THROW("Get NPU driver-compiler version is not supported with this backend");
}

void* IEngineBackend::getContext() const {
OPENVINO_THROW("Get NPU context is not supported with this backend");
}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/intel_npu/src/plugin/include/backends.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class NPUBackends final {
std::string getBackendName() const;
uint32_t getDriverVersion() const;
uint32_t getGraphExtVersion() const;
uint32_t getCompilerVersion() const;
bool isBatchingSupported() const;
bool isCommandQueueExtSupported() const;
bool isLUIDExtSupported() const;
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/intel_npu/src/plugin/include/metrics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Metrics final {
uint64_t GetDeviceTotalMemSize(const std::string& specifiedDeviceName) const;
uint32_t GetDriverVersion() const;
uint32_t GetGraphExtVersion() const;
uint32_t GetCompilerVersion() const;
uint32_t GetSteppingNumber(const std::string& specifiedDeviceName) const;
uint32_t GetMaxTiles(const std::string& specifiedDeviceName) const;
ov::device::PCIInfo GetPciInfo(const std::string& specifiedDeviceName) const;
Expand All @@ -51,7 +52,7 @@ class Metrics final {
const std::shared_ptr<const NPUBackends> _backends;
std::vector<std::string> _supportedMetrics;
std::vector<std::string> _supportedConfigKeys;
const std::vector<std::string> _optimizationCapabilities = {
std::vector<std::string> _optimizationCapabilities = {
ov::device::capability::FP16,
ov::device::capability::INT8,
ov::device::capability::EXPORT_IMPORT,
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/intel_npu/src/plugin/src/backends.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ uint32_t NPUBackends::getGraphExtVersion() const {
OPENVINO_THROW("No available backend");
}

uint32_t NPUBackends::getCompilerVersion() const {
if (_backend != nullptr) {
return _backend->getCompilerVersion();
}

OPENVINO_THROW("No available backend");
}

bool NPUBackends::isBatchingSupported() const {
if (_backend != nullptr) {
return _backend->isBatchingSupported();
Expand Down
20 changes: 20 additions & 0 deletions src/plugins/intel_npu/src/plugin/src/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#include "intel_npu/npu_private_properties.hpp"
#include "openvino/runtime/intel_npu/properties.hpp"

#ifndef ONEAPI_MAKE_VERSION
/// @brief Generates generic 'oneAPI' API versions
# define ONEAPI_MAKE_VERSION(_major, _minor) ((_major << 16) | (_minor & 0x0000ffff))
#endif // ONEAPI_MAKE_VERSION

namespace intel_npu {

Metrics::Metrics(const std::shared_ptr<const NPUBackends>& backends) : _backends(backends) {
Expand Down Expand Up @@ -39,6 +44,13 @@ Metrics::Metrics(const std::shared_ptr<const NPUBackends>& backends) : _backends
ov::hint::num_requests.name(),
ov::intel_npu::compilation_mode_params.name(),
ov::intel_npu::dynamic_shape_to_static.name()};

// optimizationCapabilities: append dynamic features based on compiler version
uint32_t compilerversion = GetCompilerVersion();
// Dynamic quantization supported starting from compiler version x
if (compilerversion >= ONEAPI_MAKE_VERSION(6, 3)) {
_optimizationCapabilities.push_back(std::string("DQ"));
}
}

std::vector<std::string> Metrics::GetAvailableDevicesNames() const {
Expand Down Expand Up @@ -134,6 +146,14 @@ uint32_t Metrics::GetGraphExtVersion() const {
return _backends->getGraphExtVersion();
}

uint32_t Metrics::GetCompilerVersion() const {
if (_backends == nullptr) {
OPENVINO_THROW("No available backends");
}

return _backends->getCompilerVersion();
}

uint32_t Metrics::GetSteppingNumber(const std::string& specifiedDeviceName) const {
const auto devName = getDeviceName(specifiedDeviceName);
auto device = _backends->getDevice(devName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class ZeroInitStructsHolder final {
inline ze_api_version_t getZeDrvApiVersion() const {
return ze_drv_api_version;
}
inline uint32_t getCompilerVersion() const {
return compiler_version;
}
// Helper function to check if extension with <ext_name> exists and its newer than <version>
inline bool isExtensionSupported(std::string ext_name, uint32_t version) const {
auto iter = driver_extension_properties.find(ext_name);
Expand Down Expand Up @@ -83,6 +86,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 @@ -248,6 +248,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 b76077f

Please sign in to comment.