OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[NPU] Migrate to vclAllocatedExecutableCreate4 and vclExecutableGetCompatibilityString (#36582)
Wenjing Kang4afc97b2166d
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cppindex 335c50f877c..b08a6f9343f 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/compiler_impl.cpp@@ -202,6 +202,18 @@ std::pair<ov::Tensor, std::optional<std::string>> VCLCompilerImpl::compile(/// Check the linked vcl version whether supported in pluginUsedVersion usedVersion = getUsedVclVersion(VCL_COMPILER_VERSION_MAJOR, VCL_COMPILER_VERSION_MINOR, _vclVersion);_logger.debug("the finally used compiler vcl version is %d.%d", usedVersion.Major, usedVersion.Minor);+ if (usedVersion.Major < VCL_COMPILER_VERSION_MAJOR ||+ (usedVersion.Major == VCL_COMPILER_VERSION_MAJOR && usedVersion.Minor < VCL_COMPILER_VERSION_MINOR)) {+ OPENVINO_THROW("Unsupported VCL version: ",+ _vclVersion.major,+ ".",+ _vclVersion.minor,+ ", please use VCL ",+ VCL_COMPILER_VERSION_MAJOR,+ ".",+ VCL_COMPILER_VERSION_MINOR,+ " or later");+ }const auto maxOpsetVersion = _compilerProperties.supportedOpsets;_logger.info("getSupportedOpsetVersion Max supported version of opset in CiD: %d", maxOpsetVersion);@@ -244,77 +256,103 @@ std::pair<ov::Tensor, std::optional<std::string>> VCLCompilerImpl::compile(serializedIR.size,buildFlags.c_str(),buildFlags.size()};-- if (usedVersion.Major > 7 || (usedVersion.Major == 7 && usedVersion.Minor >= 7)) {- // Support only the lastest VCL api- auto allocator = std::make_shared<vcl_allocator_3>();- uint8_t* blob = nullptr;- size_t blobSize = 0;- uint8_t* compatibilityStringBuffer = nullptr;- size_t compatibilityStringSize = 0;-- auto result = vclAllocatedExecutableCreate3(_compilerHandle,- exeDesc,- allocator.get(),- &blob,- &blobSize,- &compatibilityStringBuffer,- &compatibilityStringSize);+ // Support only the lastest VCL api+ auto allocator = std::make_shared<vcl_allocator_2>();+ uint8_t* blob = nullptr;+ uint64_t blobSize = 0;+ vcl_executable_handle_t executable = nullptr;++ auto result =+ vclAllocatedExecutableCreate4(_compilerHandle, exeDesc, allocator.get(), &blob, &blobSize, &executable);+ if (result != VCL_RESULT_SUCCESS) {+ // Check if allocations were performed before throwing exception+ auto tracked_allocations = allocator->m_info;+ for (const auto& [buffer, size] : tracked_allocations) {+ allocator->deallocate(allocator.get(), buffer);+ }+ if (executable != nullptr) {+ vclExecutableDestroy(executable);+ }+ OPENVINO_THROW("Compilation failed. vclAllocatedExecutableCreate4 result: 0x",+ std::hex,+ uint64_t(result),+ " - ",+ getLatestVCLLog(_logHandle));+ }+ OPENVINO_ASSERT(executable != nullptr, "Failed to create VCL executable, executable handle is null");+ OPENVINO_ASSERT(blobSize != 0 && blob != nullptr,+ "Failed to create VCL executable, the blob size is zero or the blob is null");++ // Retrieve the real allocated size for the blob from the allocator+ auto it = std::find_if(allocator->m_info.begin(),+ allocator->m_info.end(),+ [blob](const std::pair<uint8_t*, size_t>& item) {+ return item.first == blob;+ });++ OPENVINO_ASSERT(it != allocator->m_info.end(), "Failed to find the allocated blob in the allocator records");+ size_t alignedBlobSize = it->second;++ // The allocated size from VCL will be equal or smaller than the allocated size in allocator+ _logger.debug("Blob size from VCL: %zu ptr %p", static_cast<size_t>(blobSize), static_cast<void*>(blob));+ _logger.debug("Allocated vector size: %zu ptr: %p", alignedBlobSize, static_cast<void*>(blob));++ ov::Tensor alignedBlob = make_tensor_from_aligned_addr(blob, alignedBlobSize, allocator);+ allocator->m_info.erase(it);++ std::optional<std::string> compatibilityString;+ uint64_t compatibilityStringSize = 0;+ result = vclExecutableGetCompatibilityString(executable, nullptr, &compatibilityStringSize);+ if (result == VCL_RESULT_ERROR_UNSUPPORTED_FEATURE) {+ // Some compilation modes (e.g. HostCompile_Interpreter) do not produce a compatibility descriptor.+ _logger.info("vclExecutableGetCompatibilityString is not supported for this executable (0x%x); "+ "compatibility string will be absent",+ uint32_t(result));+ } else if (result != VCL_RESULT_SUCCESS || compatibilityStringSize == 0) {+ if (executable != nullptr) {+ vclExecutableDestroy(executable);+ }+ OPENVINO_THROW("Failed to get compatibility string size. vclExecutableGetCompatibilityString result: 0x",+ std::hex,+ uint64_t(result),+ " - ",+ getLatestVCLLog(_logHandle));+ } else {+ OPENVINO_ASSERT(compatibilityStringSize <= std::numeric_limits<size_t>::max(),+ "Compatibility string size is too large to allocate a local buffer");+ compatibilityString.emplace(static_cast<size_t>(compatibilityStringSize), '\0');+ result = vclExecutableGetCompatibilityString(executable, compatibilityString->data(), &compatibilityStringSize);if (result != VCL_RESULT_SUCCESS) {- // Check if allocations were performed before throwing exception- auto tracked_allocations = allocator->m_info;- for (const auto& [buffer, size] : tracked_allocations) {- allocator->deallocate(allocator.get(), buffer);+ if (executable != nullptr) {+ vclExecutableDestroy(executable);}- OPENVINO_THROW("Compilation failed. vclAllocatedExecutableCreate3 result: 0x",+ OPENVINO_THROW("Failed to get compatibility string. vclExecutableGetCompatibilityString result: 0x",std::hex,uint64_t(result)," - ",getLatestVCLLog(_logHandle));}-- OPENVINO_ASSERT(blobSize != 0 && blob != nullptr,- "Failed to create VCL executable, the blob size is zero or the blob is null");-- // Retrieve the real allocated size for the blob from the allocator- auto it = std::find_if(allocator->m_info.begin(),- allocator->m_info.end(),- [blob](const std::pair<uint8_t*, size_t>& item) {- return item.first == blob;- });-- OPENVINO_ASSERT(it != allocator->m_info.end(), "Failed to find the allocated blob in the allocator records");- size_t alignedBlobSize = it->second;-- // The allocated size from VCL will be equal or smaller than the allocated size in allocator- _logger.debug("Blob size from VCL: %zu ptr %p", blobSize, static_cast<void*>(blob));- _logger.debug("Allocated vector size: %zu ptr: %p", alignedBlobSize, static_cast<void*>(blob));-- ov::Tensor alignedBlob = make_tensor_from_aligned_addr(blob, alignedBlobSize, allocator);- allocator->m_info.erase(it);-- std::optional<std::string> compatibilityString;-- // Populate compatibility string only when VCL provides a buffer.- if (compatibilityStringBuffer != nullptr) {- OPENVINO_ASSERT(compatibilityStringSize != 0,- "Failed to create VCL executable, the compatibility descriptor size is zero");- compatibilityString =- std::string(reinterpret_cast<char*>(compatibilityStringBuffer), compatibilityStringSize);- _logger.debug("Compatibility string from VCL: %s", compatibilityString->c_str());-- allocator->deallocate(allocator.get(), compatibilityStringBuffer);+ OPENVINO_ASSERT(compatibilityStringSize <= compatibilityString->size(),+ "Returned compatibility string size exceeds the allocated buffer size");+ size_t outSize = static_cast<size_t>(compatibilityStringSize);+ if (outSize > 0 && (*compatibilityString)[outSize - 1] == '\0') {+ --outSize;}+ compatibilityString->resize(outSize);+ _logger.debug("Compatibility string from VCL: %s", compatibilityString->c_str());+ }- return std::make_pair<ov::Tensor, std::optional<std::string>>(std::move(alignedBlob),- std::move(compatibilityString));- } else {- OPENVINO_THROW("Unsupported VCL version: ",- _vclVersion.major,- ".",- _vclVersion.minor,- ", please use VCL 7.7 or later");+ result = vclExecutableDestroy(executable);+ if (result != VCL_RESULT_SUCCESS) {+ OPENVINO_THROW("Failed to destroy VCL executable. vclExecutableDestroy result: 0x",+ std::hex,+ uint64_t(result),+ " - ",+ getLatestVCLLog(_logHandle));}++ return std::make_pair<ov::Tensor, std::optional<std::string>>(std::move(alignedBlob),+ std::move(compatibilityString));}std::vector<ov::Tensor> VCLCompilerImpl::compileWsOneShot(const std::shared_ptr<ov::Model>& model,@@ -368,7 +406,7 @@ std::vector<ov::Tensor> VCLCompilerImpl::compileWsOneShot(const std::shared_ptr<_logger.debug("compiler vcl version: %d.%d", _vclVersion.major, _vclVersion.minor);_logger.debug("Using vclAllocatedExecutableCreateWSOneShot");- auto allocator = std::make_shared<vcl_allocator_3>();+ auto allocator = std::make_shared<vcl_allocator_2>();THROW_ON_FAIL_FOR_VCL("vclAllocatedExecutableCreateWSOneShot",vclAllocatedExecutableCreateWSOneShot(_compilerHandle, exeDesc, allocator.get()),diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cppindex 283ef5a5cdd..95c43a24709 100644--- a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp+++ b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp@@ -590,6 +590,19 @@ std::optional<std::string> ZeGraphExtWrappers::getCompatibilityDescriptor(ze_grareturn std::nullopt;}+ if (size > descriptor.size()) {+ _logger.warning("zeDeviceGetRuntimeRequirements returned inconsistent size: %zu > %zu",+ size,+ descriptor.size());+ return std::nullopt;+ }++ size_t outSize = size;+ if (outSize > 0 && descriptor[outSize - 1] == '\0') {+ --outSize;+ }+ descriptor.resize(outSize);+_logger.debug("Fetched runtime requirements from driver: %s", descriptor.c_str());return descriptor;diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl.h b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl.hindex 47e53d4c8a3..3a13932eba9 100644--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl.h+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl.h@@ -22,7 +22,7 @@ extern "C" {#endif#define VCL_COMPILER_VERSION_MAJOR 7-#define VCL_COMPILER_VERSION_MINOR 7+#define VCL_COMPILER_VERSION_MINOR 8#define VCL_PROFILING_VERSION_MAJOR 2#define VCL_PROFILING_VERSION_MINOR 0@@ -276,6 +276,17 @@ VCL_APIEXPORT vcl_result_t VCL_APICALL vclAllocatedExecutableCreate3(vcl_compileuint8_t** compatibilityStringBuffer,uint64_t* compatibilityStringSize);+VCL_APIEXPORT vcl_result_t VCL_APICALL vclAllocatedExecutableCreate4(vcl_compiler_handle_t compiler,+ vcl_executable_desc_t desc,+ vcl_allocator2_t* allocator,+ uint8_t** blobBuffer,+ uint64_t* blobSize,+ vcl_executable_handle_t* executable);++VCL_APIEXPORT vcl_result_t VCL_APICALL vclExecutableGetCompatibilityString(vcl_executable_handle_t executable,+ char* compatibilityStringBuffer,+ uint64_t* compatibilityStringSize);+VCL_APIEXPORT vcl_result_t VCL_APICALL vclAllocatedExecutableCreateWSOneShot(vcl_compiler_handle_t compiler,vcl_executable_desc_t desc,vcl_allocator2_t* allocator);diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_allocator.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_allocator.hppindex 4eacb1b74a1..5c000a702bd 100644--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_allocator.hpp+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_allocator.hpp@@ -18,10 +18,10 @@namespace intel_npu {-struct vcl_allocator_3 : vcl_allocator2_t {- vcl_allocator_3() : vcl_allocator2_t{allocate, deallocate}, m_allocator(intel_npu::utils::STANDARD_PAGE_SIZE) {}+struct vcl_allocator_2 : vcl_allocator2_t {+ vcl_allocator_2() : vcl_allocator2_t{allocate, deallocate}, m_allocator(intel_npu::utils::STANDARD_PAGE_SIZE) {}- ~vcl_allocator_3() {+ ~vcl_allocator_2() {for (auto& item : m_info) {if (item.first) {m_allocator.deallocate(item.first, item.second, intel_npu::utils::STANDARD_PAGE_SIZE);@@ -31,7 +31,7 @@ struct vcl_allocator_3 : vcl_allocator2_t {}static uint8_t* allocate(vcl_allocator2_t* allocator, size_t size) noexcept {- vcl_allocator_3* vclAllocator = static_cast<vcl_allocator_3*>(allocator);+ vcl_allocator_2* vclAllocator = static_cast<vcl_allocator_2*>(allocator);size_t alignedSize = intel_npu::utils::align_size_to_standard_page_size(size);// Prevent integer wraparound on extremely large allocation sizes@@ -63,7 +63,7 @@ struct vcl_allocator_3 : vcl_allocator2_t {if (ptr == nullptr) {return;}- vcl_allocator_3* vclAllocator = static_cast<vcl_allocator_3*>(allocator);+ vcl_allocator_2* vclAllocator = static_cast<vcl_allocator_2*>(allocator);auto it = std::find_if(vclAllocator->m_info.begin(),vclAllocator->m_info.end(),@@ -83,14 +83,14 @@ struct vcl_allocator_3 : vcl_allocator2_t {inline ov::Tensor make_tensor_from_aligned_addr(uint8_t* allocated,size_t size,- std::shared_ptr<vcl_allocator_3> sourceAllocator) {+ std::shared_ptr<vcl_allocator_2> sourceAllocator) {auto tensor = ov::Tensor(ov::element::u8, ov::Shape{size}, allocated);auto impl = ov::get_tensor_impl(std::move(tensor));std::shared_ptr<void> ptr(allocated, [sourceAllocator](uint8_t* p) noexcept {if (p == nullptr) {return;}- vcl_allocator_3::deallocate(sourceAllocator.get(), p);+ vcl_allocator_2::deallocate(sourceAllocator.get(), p);});impl._so = std::move(ptr);return ov::make_tensor(impl);diff --git a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_api.hpp b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_api.hppindex 83a480fd64c..406e33a0138 100644--- a/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_api.hpp+++ b/src/plugins/intel_npu/src/utils/include/intel_npu/utils/vcl/vcl_api.hpp@@ -28,7 +28,8 @@ namespace intel_npu {vcl_symbol_statement(vclProfilingDestroy) \vcl_symbol_statement(vclProfilingGetProperties) \vcl_symbol_statement(vclLogHandleGetString) \- vcl_symbol_statement(vclAllocatedExecutableCreate3) \+ vcl_symbol_statement(vclAllocatedExecutableCreate4) \+ vcl_symbol_statement(vclExecutableGetCompatibilityString) \vcl_symbol_statement(vclGetCompilerSupportedOptions) \vcl_symbol_statement(vclGetCompilerIsOptionSupported) \diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/vcl_allocator_test.hpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/vcl_allocator_test.hppindex 006cbb22032..3fb88671232 100644--- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/vcl_allocator_test.hpp+++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/vcl_allocator_test.hpp@@ -38,12 +38,12 @@ public:protected:std::string targetDevice;std::shared_ptr<ov::Model> model;- std::shared_ptr<::intel_npu::vcl_allocator_3> allocator;+ std::shared_ptr<::intel_npu::vcl_allocator_2> allocator;void SetUp() override {targetDevice = GetParam();model = ov::test::utils::make_conv_pool_relu();- allocator = std::make_shared<::intel_npu::vcl_allocator_3>();+ allocator = std::make_shared<::intel_npu::vcl_allocator_2>();try {std::string ov_lib_dir = ov::test::utils::getOpenvinoLibDirectory();@@ -159,13 +159,43 @@ protected:return state;}++ static std::string getCompatibilityString(vcl_executable_handle_t executable) {+ uint64_t compatibilityStringSize = 0;+ auto result = ::intel_npu::vclExecutableGetCompatibilityString(executable, nullptr, &compatibilityStringSize);+ if (result != VCL_RESULT_SUCCESS || compatibilityStringSize == 0) {+ ADD_FAILURE() << "Failed to get compatibility string size";+ return {};+ }+ const uint64_t maxSize = static_cast<uint64_t>(std::vector<char>().max_size());+ if (compatibilityStringSize > maxSize) {+ ADD_FAILURE() << "Compatibility string size is too large";+ return {};+ }+ std::vector<char> compatibilityStringBuffer(static_cast<size_t>(compatibilityStringSize), '\0');+ result = ::intel_npu::vclExecutableGetCompatibilityString(executable,+ compatibilityStringBuffer.data(),+ &compatibilityStringSize);+ if (result != VCL_RESULT_SUCCESS) {+ ADD_FAILURE() << "Failed to get compatibility string";+ return {};+ }+ if (compatibilityStringSize > static_cast<uint64_t>(compatibilityStringBuffer.size())) {+ ADD_FAILURE() << "Returned compatibility string size exceeds the allocated buffer size";+ return {};+ }+ size_t outSize = static_cast<size_t>(compatibilityStringSize);+ if (outSize > 0 && compatibilityStringBuffer[outSize - 1] == '\0') {+ --outSize;+ }+ return std::string(compatibilityStringBuffer.data(), outSize);+ }};TEST_P(VclAllocatorFuncTests, VerifyAllocation) {uint8_t* blobBuffer = nullptr;uint64_t blobSize = 0;- uint8_t* compatibilityReqBuffer = nullptr;- uint64_t compatibilityReqSize = 0;+ vcl_executable_handle_t executable = nullptr;auto setup = createCompilerAndDescriptor();ASSERT_NE(setup.compiler, nullptr);@@ -175,21 +205,21 @@ TEST_P(VclAllocatorFuncTests, VerifyAllocation) {setup.buildFlags.c_str(),setup.buildFlags.size()};- auto result = ::intel_npu::vclAllocatedExecutableCreate3(setup.compiler,+ auto result = ::intel_npu::vclAllocatedExecutableCreate4(setup.compiler,desc,allocator.get(),&blobBuffer,&blobSize,- &compatibilityReqBuffer,- &compatibilityReqSize);+ &executable);EXPECT_EQ(result, VCL_RESULT_SUCCESS);EXPECT_NE(blobBuffer, nullptr);- EXPECT_NE(compatibilityReqBuffer, nullptr);+ ASSERT_NE(executable, nullptr);+ auto compatibilityString = getCompatibilityString(executable);+ EXPECT_FALSE(compatibilityString.empty());- // Verify it tracked exactly these two buffers- // 2 allocations: blob & compatibility string- EXPECT_EQ(allocator->m_info.size(), 2);+ // Verify it tracked blob allocation.+ EXPECT_EQ(allocator->m_info.size(), 1);auto blobIt = std::find_if(allocator->m_info.begin(),allocator->m_info.end(),@@ -198,19 +228,13 @@ TEST_P(VclAllocatorFuncTests, VerifyAllocation) {});EXPECT_NE(blobIt, allocator->m_info.end());- auto compatIt = std::find_if(allocator->m_info.begin(),- allocator->m_info.end(),- [compatibilityReqBuffer](const std::pair<uint8_t*, size_t>& item) {- return item.first == compatibilityReqBuffer;- });- EXPECT_NE(compatIt, allocator->m_info.end());+ EXPECT_EQ(::intel_npu::vclExecutableDestroy(executable), VCL_RESULT_SUCCESS);}TEST_P(VclAllocatorFuncTests, VerifyDeallocation) {uint8_t* blobBuffer = nullptr;uint64_t blobSize = 0;- uint8_t* compatibilityReqBuffer = nullptr;- uint64_t compatibilityReqSize = 0;+ vcl_executable_handle_t executable = nullptr;auto setup = createCompilerAndDescriptor();ASSERT_NE(setup.compiler, nullptr);@@ -220,36 +244,39 @@ TEST_P(VclAllocatorFuncTests, VerifyDeallocation) {setup.buildFlags.c_str(),setup.buildFlags.size()};- auto result = ::intel_npu::vclAllocatedExecutableCreate3(setup.compiler,+ auto result = ::intel_npu::vclAllocatedExecutableCreate4(setup.compiler,desc,allocator.get(),&blobBuffer,&blobSize,- &compatibilityReqBuffer,- &compatibilityReqSize);+ &executable);EXPECT_EQ(result, VCL_RESULT_SUCCESS);+ ASSERT_NE(executable, nullptr);+ auto compatibilityString = getCompatibilityString(executable);+ EXPECT_FALSE(compatibilityString.empty());- // Clean up compatibility string- if (compatibilityReqBuffer != nullptr) {- allocator->deallocate(allocator.get(), compatibilityReqBuffer);+ // Clean up blob buffer tracked by allocator.+ if (blobBuffer != nullptr) {+ allocator->deallocate(allocator.get(), blobBuffer);}- // Verify compatibility buffer was erased from tracking vector- auto compatIt = std::find_if(allocator->m_info.begin(),- allocator->m_info.end(),- [compatibilityReqBuffer](const std::pair<uint8_t*, size_t>& item) {- return item.first == compatibilityReqBuffer;- });- EXPECT_EQ(compatIt, allocator->m_info.end());- EXPECT_EQ(allocator->m_info.size(), 1);+ // Verify blob buffer was erased from tracking vector.+ auto blobIt = std::find_if(allocator->m_info.begin(),+ allocator->m_info.end(),+ [blobBuffer](const std::pair<uint8_t*, size_t>& item) {+ return item.first == blobBuffer;+ });+ EXPECT_EQ(blobIt, allocator->m_info.end());+ EXPECT_EQ(allocator->m_info.size(), 0);++ EXPECT_EQ(::intel_npu::vclExecutableDestroy(executable), VCL_RESULT_SUCCESS);}TEST_P(VclAllocatorFuncTests, VerifyOwnershipTransferToTensor) {uint8_t* blobBuffer = nullptr;uint64_t blobSize = 0;- uint8_t* compatibilityReqBuffer = nullptr;- uint64_t compatibilityReqSize = 0;+ vcl_executable_handle_t executable = nullptr;auto setup = createCompilerAndDescriptor();ASSERT_NE(setup.compiler, nullptr);@@ -259,15 +286,17 @@ TEST_P(VclAllocatorFuncTests, VerifyOwnershipTransferToTensor) {setup.buildFlags.c_str(),setup.buildFlags.size()};- auto result = ::intel_npu::vclAllocatedExecutableCreate3(setup.compiler,+ auto result = ::intel_npu::vclAllocatedExecutableCreate4(setup.compiler,desc,allocator.get(),&blobBuffer,&blobSize,- &compatibilityReqBuffer,- &compatibilityReqSize);+ &executable);EXPECT_EQ(result, VCL_RESULT_SUCCESS);+ ASSERT_NE(executable, nullptr);+ auto compatibilityString = getCompatibilityString(executable);+ EXPECT_FALSE(compatibilityString.empty());// Retrieve the real allocated size for the blob from the allocator (mirroring compiler_impl.cpp)auto it = std::find_if(allocator->m_info.begin(),@@ -289,21 +318,17 @@ TEST_P(VclAllocatorFuncTests, VerifyOwnershipTransferToTensor) {allocator->m_info.erase(it);} // tensor goes out of scope here: custom deleter correctly handles the physical memory free- // Clean up compatibility string manually- if (compatibilityReqBuffer != nullptr) {- allocator->deallocate(allocator.get(), compatibilityReqBuffer);- }-- // After erasing the blob and deallocating the compatibility string,+ // After erasing the blob,// the tracking info in the allocator should be empty.EXPECT_EQ(allocator->m_info.size(), 0);++ EXPECT_EQ(::intel_npu::vclExecutableDestroy(executable), VCL_RESULT_SUCCESS);}TEST_P(VclAllocatorFuncTests, VerifyOrphanMemoryCleanupOnDestruction) {uint8_t* blobBuffer = nullptr;uint64_t blobSize = 0;- uint8_t* compatibilityReqBuffer = nullptr;- uint64_t compatibilityReqSize = 0;+ vcl_executable_handle_t executable = nullptr;auto setup = createCompilerAndDescriptor();ASSERT_NE(setup.compiler, nullptr);@@ -313,16 +338,20 @@ TEST_P(VclAllocatorFuncTests, VerifyOrphanMemoryCleanupOnDestruction) {setup.buildFlags.c_str(),setup.buildFlags.size()};- auto result = ::intel_npu::vclAllocatedExecutableCreate3(setup.compiler,+ auto result = ::intel_npu::vclAllocatedExecutableCreate4(setup.compiler,desc,allocator.get(),&blobBuffer,&blobSize,- &compatibilityReqBuffer,- &compatibilityReqSize);+ &executable);EXPECT_EQ(result, VCL_RESULT_SUCCESS);- EXPECT_EQ(allocator->m_info.size(), 2); // 2 allocations: blob & compatibility string+ ASSERT_NE(executable, nullptr);+ auto compatibilityString = getCompatibilityString(executable);+ EXPECT_FALSE(compatibilityString.empty());+ EXPECT_EQ(allocator->m_info.size(), 1); // 1 allocation: blob++ EXPECT_EQ(::intel_npu::vclExecutableDestroy(executable), VCL_RESULT_SUCCESS);// Purpose: Simulate VCL crash or early return where the memory is temporarily tracked as an orphan leak// When the allocator goes out of scope and gets destroyed, it should cleanly free all tracked memory