Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[NPU][WS] Fix for the multiple init schedules & a single thread scenario (#32068)

Razvan Apetroaie68cb103f9727
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp
index f6008434834..1d01272d364 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp
@@ -469,13 +469,16 @@ WeightlessGraph::OutputData WeightlessGraph::allocate_outputs(const size_t initI
void WeightlessGraph::run_init_single_threaded() {
auto constants = get_all_constants_in_topological_order(_model, _wgLogger);
+ const size_t numberOfInits = _initsGraphDesc.size();
- for (size_t initIndex = 0; initIndex < _initsGraphDesc.size(); ++initIndex) {
+ for (size_t initIndex = 0; initIndex < numberOfInits; ++initIndex) {
auto [initInputsViewTensors, initInputsAllocatedTensor] = allocate_inputs(initIndex, constants);
+ if (initIndex == numberOfInits - 1) {
+ // We don't need these anymore, potentially save some memory
+ _model = nullptr;
+ constants = {};
+ }
- // We don't need these anymore, potentially save some memory
- _model = nullptr;
- constants = {};
auto [initOutputsViewTensors, initOutputsAllocatedTensor, initOutputsViewTensorsMap] =
allocate_outputs(initIndex);