Skip to content

Commit 1e32f68

Browse files
committed
Use vclAllocateExecutionCreate3 to get metadata
Signed-off-by: Xin Wang <[email protected]>
1 parent 7732543 commit 1e32f68

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

src/plugins/intel_npu/src/compiler_adapter/include/npu_driver_compiler.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extern "C" {
2323
#endif
2424

2525
#define VCL_COMPILER_VERSION_MAJOR 7
26-
#define VCL_COMPILER_VERSION_MINOR 4
26+
#define VCL_COMPILER_VERSION_MINOR 5
2727
#define VCL_PROFILING_VERSION_MAJOR 2
2828
#define VCL_PROFILING_VERSION_MINOR 0
2929

@@ -272,6 +272,13 @@ VCL_APIEXPORT vcl_result_t VCL_APICALL vclAllocatedExecutableCreate2(vcl_compile
272272
uint8_t** blobBuffer,
273273
uint64_t* blobSize);
274274

275+
VCL_APIEXPORT vcl_result_t VCL_APICALL vclAllocatedExecutableCreate3(vcl_compiler_handle_t compiler,
276+
vcl_executable_desc_t desc,
277+
vcl_allocator2_t* allocator,
278+
uint8_t** blobBuffer,
279+
uint64_t* blobSize,
280+
void* metadata);
281+
275282
///////////////////////////////////////////////////////////////////////////////
276283
/// @brief Destroys the executable and releases the cached blob.
277284
VCL_APIEXPORT vcl_result_t VCL_APICALL vclExecutableDestroy(vcl_executable_handle_t executable);

src/plugins/intel_npu/src/compiler_adapter/include/vcl_api.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ namespace intel_npu {
3434

3535
//unsupported symbols with older ze_loader versions
3636
#define vcl_weak_symbols_list() \
37+
vcl_symbol_statement(vclAllocatedExecutableCreate3) \
3738
vcl_symbol_statement(vclAllocatedExecutableCreate2) \
3839
vcl_symbol_statement(vclGetCompilerSupportedOptions) \
3940
vcl_symbol_statement(vclGetCompilerIsOptionSupported)

src/plugins/intel_npu/src/compiler_adapter/src/plugin_compiler_adapter.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,20 @@ std::shared_ptr<IGraph> PluginCompilerAdapter::compile(const std::shared_ptr<con
106106
ov::Tensor tensor = make_tensor_from_vector(networkDesc.compiledNetwork);
107107
ze_graph_handle_t graphHandle = nullptr;
108108

109-
NetworkMetadata networkMeta;
109+
NetworkMetadata networkMeta = std::move(networkDesc.metadata);
110110
if (_zeGraphExt) {
111111
// Depending on the config, we may get an error when trying to get the graph handle from the compiled
112112
// network
113113
try {
114114
graphHandle =
115115
_zeGraphExt->getGraphHandle(*reinterpret_cast<const uint8_t*>(tensor.data()), tensor.get_byte_size());
116116
#ifdef VCL_FOR_COMPILER
117-
// For VCL, we need to get metadata from driver parser
118-
networkMeta = _zeGraphExt->getNetworkMeta(graphHandle);
119-
networkMeta.name = model->get_friendly_name();
117+
if (networkMeta.inputs.empty() && networkMeta.outputs.empty()) {
118+
// If the metadata is empty, we can try to get it from the driver parser
119+
_logger.info("Metadata is empty, trying to get it from the driver parser");
120+
networkMeta = _zeGraphExt->getNetworkMeta(graphHandle);
121+
networkMeta.name = model->get_friendly_name();
122+
}
120123
#endif
121124
} catch (...) {
122125
_logger.info("Failed to obtain the level zero graph handle. Inference requests for this model are not "

src/plugins/intel_npu/src/compiler_adapter/src/vcl_api.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,27 @@ NetworkDescription VCLCompilerImpl::compile(const std::shared_ptr<const ov::Mode
208208
buildFlags.c_str(),
209209
buildFlags.size()};
210210
_logger.debug("compiler vcl version: %d.%d", _vclVersion.major, _vclVersion.minor);
211-
if (_vclVersion.major >= 7 && _vclVersion.minor >= 4) {
211+
if (_vclVersion.major >= 7 && _vclVersion.minor >= 5) {
212+
// For VCL 7.5 and later, we can use vclAllocatedExecutableCreate2
213+
_logger.debug("Using vclAllocatedExecutableCreate2 for 7.5 <= VCL");
214+
vcl_allocator_vector allocator;
215+
uint8_t* blob = nullptr;
216+
size_t size = 0;
217+
NetworkMetadata metadata;
218+
219+
THROW_ON_FAIL_FOR_VCL(
220+
"vclAllocatedExecutableCreate3",
221+
vclAllocatedExecutableCreate3(_compilerHandle, exeDesc, &allocator, &blob, &size, &metadata),
222+
_logHandle);
223+
if (size == 0 || blob == nullptr) {
224+
OPENVINO_THROW("Failed to create VCL executable, size is zero or blob is null");
225+
}
226+
227+
_logger.debug("compile end, blob size:%d", allocator.m_vec.size());
228+
return NetworkDescription(std::move(allocator.m_vec), std::move(metadata));
229+
} else if (_vclVersion.major >= 7 && _vclVersion.minor >= 4) {
212230
// For VCL 7.4 and later, we can use vclAllocatedExecutableCreate2
213-
_logger.debug("Using vclAllocatedExecutableCreate2 for VCL 7.4+");
231+
_logger.debug("Using vclAllocatedExecutableCreate2 for 7.4 <= VCL < 7.5");
214232
vcl_allocator_vector allocator;
215233
uint8_t* blob = nullptr;
216234
size_t size = 0;

0 commit comments

Comments
 (0)