Skip to content

Commit 05bd05e

Browse files
committed
Don't share config with ze_graph_ext_wrappers
Signed-off-by: Bogdan Pereanu <bogdan.pereanu@intel.com>
1 parent b4bbc76 commit 05bd05e

File tree

5 files changed

+40
-28
lines changed

5 files changed

+40
-28
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ZeGraphExtWrappers {
3535

3636
GraphDescriptor getGraphDescriptor(SerializedIR serializedIR,
3737
const std::string& buildFlags,
38-
const Config& config) const;
38+
const bool disableCache = false) const;
3939

4040
GraphDescriptor getGraphDescriptor(void* data, size_t size) const;
4141

src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compile(const std::shared_ptr<con
102102
_logger.debug("compileIR Build flags : %s", buildFlags.c_str());
103103

104104
_logger.debug("compile start");
105-
auto graphDesc = _zeGraphExt->getGraphDescriptor(std::move(serializedIR), buildFlags, config);
105+
const auto set_cache_dir = config.get<CACHE_DIR>();
106+
auto graphDesc = _zeGraphExt->getGraphDescriptor(std::move(serializedIR),
107+
buildFlags,
108+
!set_cache_dir.empty() || config.get<BYPASS_UMD_CACHING>());
106109
_logger.debug("compile end");
107110

108111
OV_ITT_TASK_NEXT(COMPILE_BLOB, "getNetworkMeta");
@@ -177,7 +180,10 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compileWS(const std::shared_ptr<o
177180
buildFlags += irSerializer.serializeConfig(updatedConfig, compilerVersion);
178181

179182
_logger.debug("compile start");
180-
auto graphDesc = _zeGraphExt->getGraphDescriptor(serializedIR, buildFlags, config);
183+
const auto set_cache_dir = config.get<CACHE_DIR>();
184+
auto graphDesc = _zeGraphExt->getGraphDescriptor(serializedIR,
185+
buildFlags,
186+
!set_cache_dir.empty() || config.get<BYPASS_UMD_CACHING>());
181187
_logger.debug("compile end");
182188

183189
OV_ITT_TASK_NEXT(COMPILE_BLOB, "getNetworkMeta");

src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include <string_view>
1010

11-
#include "intel_npu/config/options.hpp"
1211
#include "intel_npu/prefix.hpp"
1312
#include "intel_npu/utils/utils.hpp"
1413
#include "intel_npu/utils/zero/zero_api.hpp"
@@ -336,13 +335,12 @@ bool ZeGraphExtWrappers::canCpuVaBeImported(void* data, size_t size) const {
336335

337336
GraphDescriptor ZeGraphExtWrappers::getGraphDescriptor(SerializedIR serializedIR,
338337
const std::string& buildFlags,
339-
const Config& config) const {
338+
const bool disableCache) const {
340339
ze_graph_handle_t graphHandle = nullptr;
341340

342341
// If UMD Caching is requested to be bypassed or if OV cache is enabled, disable driver caching
343342
uint32_t flags = ZE_GRAPH_FLAG_NONE;
344-
const auto set_cache_dir = config.get<CACHE_DIR>();
345-
if (!set_cache_dir.empty() || config.get<BYPASS_UMD_CACHING>()) {
343+
if (disableCache) {
346344
flags = flags | ZE_GRAPH_FLAG_DISABLE_CACHING;
347345
}
348346

src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "zero_graph.hpp"
66

7+
#include "openvino/runtime/intel_npu/properties.hpp"
8+
79
namespace {
810
const std::vector<ov::AnyMap> configsGraphCompilationTests = {{},
911
{ov::cache_dir("test")},

src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
#include "common/npu_test_env_cfg.hpp"
1313
#include "common_test_utils/subgraph_builders/multi_single_conv.hpp"
1414
#include "common_test_utils/test_constants.hpp"
15-
#include "intel_npu/config/options.hpp"
1615
#include "intel_npu/utils/utils.hpp"
1716
#include "intel_npu/utils/zero/zero_mem.hpp"
1817
#include "intel_npu/utils/zero/zero_utils.hpp"
1918
#include "ir_serializer.hpp"
20-
#include "openvino/runtime/intel_npu/properties.hpp"
2119
#include "ze_graph_ext_wrappers.hpp"
2220
#include "zero_init_mock.hpp"
2321

@@ -79,15 +77,6 @@ class ZeroGraphTest : public ::testing::TestWithParam<CompilationParamsAndExtens
7977

8078
model = ov::test::utils::make_multi_single_conv();
8179

82-
options->add<::intel_npu::BYPASS_UMD_CACHING>();
83-
options->add<::intel_npu::CACHE_DIR>();
84-
85-
if (!configuration.empty()) {
86-
for (auto& configItem : configuration) {
87-
npu_config.update({{configItem.first, configItem.second.as<std::string>()}});
88-
}
89-
}
90-
9180
std::shared_ptr<ZeroInitStructsMock> zeroInitMock = std::make_shared<ZeroInitStructsMock>(graphExtVersion);
9281
zeroInitStruct = std::reinterpret_pointer_cast<ZeroInitStructsHolder>(zeroInitMock);
9382
zeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);
@@ -108,13 +97,30 @@ class ZeroGraphTest : public ::testing::TestWithParam<CompilationParamsAndExtens
10897
serializedIR = irSerializer->serializeIR(model, compilerVersion, maxOpsetVersion);
10998
}
11099

100+
bool disablCache() {
101+
if (!configuration.empty()) {
102+
for (auto& configItem : configuration) {
103+
if (configItem.first == "CACHE_DIR") {
104+
const auto set_cache_dir = configItem.second;
105+
if (!set_cache_dir.empty()) {
106+
return true;
107+
}
108+
}
109+
if (configItem.first == "NPU_BYPASS_UMD_CACHING") {
110+
if (configItem.second.as<bool>()) {
111+
return true;
112+
}
113+
}
114+
}
115+
}
116+
117+
return false;
118+
}
119+
111120
std::shared_ptr<ZeroInitStructsHolder> zeroInitStruct;
112121
std::shared_ptr<ZeGraphExtWrappers> zeGraphExt;
113122
ov::AnyMap configuration;
114123

115-
std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>();
116-
::intel_npu::Config npu_config = ::intel_npu::Config(options);
117-
118124
SerializedIR serializedIR;
119125
GraphDescriptor graphDescriptor;
120126

@@ -130,7 +136,7 @@ using ZeroGraphCompilationTests = ZeroGraphTest;
130136

131137
TEST_P(ZeroGraphCompilationTests, GetGraphInitIR) {
132138
serializeIR();
133-
OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", npu_config));
139+
OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", disablCache()));
134140

135141
uint32_t initCommandQueueOrdinal = 0;
136142
OV_ASSERT_NO_THROW(initCommandQueueOrdinal =
@@ -141,7 +147,7 @@ TEST_P(ZeroGraphCompilationTests, GetGraphInitIR) {
141147

142148
TEST_P(ZeroGraphCompilationTests, GetInitSetArgsDestroyGraphAlignedMemoryIR) {
143149
serializeIR();
144-
OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", npu_config));
150+
OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", disablCache()));
145151

146152
uint32_t initCommandQueueOrdinal = 0;
147153
OV_ASSERT_NO_THROW(initCommandQueueOrdinal =
@@ -183,7 +189,7 @@ TEST_P(ZeroGraphTest, GetGraphInitBlob) {
183189

184190
TEST_P(ZeroGraphTest, GetNetworkMeta) {
185191
serializeIR();
186-
OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", npu_config));
192+
OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", disablCache()));
187193

188194
OV_ASSERT_NO_THROW(NetworkMetadata meta = zeGraphExt->getNetworkMeta(graphDescriptor));
189195
}
@@ -223,7 +229,7 @@ TEST_P(ZeroGraphTest, GetGraphBinary) {
223229
TEST_P(ZeroGraphTest, SetGraphArgOnNullBuffer) {
224230
serializeIR();
225231

226-
OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", npu_config));
232+
OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", disablCache()));
227233

228234
uint32_t initCommandQueueOrdinal = 0;
229235
OV_ASSERT_NO_THROW(initCommandQueueOrdinal =
@@ -310,7 +316,7 @@ TEST_P(ZeroGraphTest, SetUnalignedAddressBlob) {
310316
auto localZeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);
311317
GraphDescriptor localGraphDescriptor;
312318
serializeIR();
313-
OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", npu_config));
319+
OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", disablCache()));
314320
const uint8_t* blobPtr = nullptr;
315321
std::vector<uint8_t> blobVec; // plugin needs to keep a copy of the blob for older drivers
316322
size_t blobSize;
@@ -345,7 +351,7 @@ TEST_P(ZeroGraphTest, SetUnalignedSizeBlob) {
345351
auto localZeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);
346352
GraphDescriptor localGraphDescriptor;
347353
serializeIR();
348-
OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", npu_config));
354+
OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", disablCache()));
349355
const uint8_t* blobPtr = nullptr;
350356
std::vector<uint8_t> blobVec; // plugin needs to keep a copy of the blob for older drivers
351357
size_t blobSize;
@@ -380,7 +386,7 @@ TEST_P(ZeroGraphTest, SetAlignedBlob) {
380386
auto localZeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);
381387
GraphDescriptor localGraphDescriptor;
382388
serializeIR();
383-
OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", npu_config));
389+
OV_ASSERT_NO_THROW(localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", disablCache()));
384390
const uint8_t* blobPtr = nullptr;
385391
std::vector<uint8_t> blobVec; // plugin needs to keep a copy of the blob for older drivers
386392
size_t blobSize;

0 commit comments

Comments
 (0)