Skip to content

Commit eebe1c2

Browse files
[NPUW] Fix LazyTensor import (#29192)
1 parent 71c9359 commit eebe1c2

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/plugins/intel_npu/src/plugin/npuw/compiled_model.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ void ov::npuw::CompiledModel::CompiledModelDesc::deserialize(std::istream& strea
632632

633633
// Also read weights into LazyTensors
634634
for (std::size_t cidx = 0; cidx < closure.size(); ++cidx) {
635-
if (closure_uid[cidx] != -1) { // previously registered before serialization
635+
if (closure_uid[cidx] != -1 && lazy_closure[cidx]) { // previously registered before serialization
636636
lazy_closure[cidx].read_weight(weights);
637637
}
638638
}

src/plugins/intel_npu/src/plugin/npuw/lazy_tensor.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ struct Unpack {
175175
}
176176
void read_weight(const ov::npuw::s11n::Weights& weights) {
177177
w.read_weight(weights);
178-
z.read_weight(weights);
178+
if (z) { // could be empty
179+
z.read_weight(weights);
180+
}
179181
s.read_weight(weights);
180182
}
181183
void detach() {
@@ -472,6 +474,10 @@ void LazyTensor::read_weight(const ov::npuw::s11n::Weights& weights) {
472474
m_impl->read_weight(weights);
473475
}
474476

477+
LazyTensor::operator bool() const {
478+
return m_impl != nullptr;
479+
}
480+
475481
std::size_t LazyTensor::get_hash() const {
476482
if (!m_impl) {
477483
return 0;

src/plugins/intel_npu/src/plugin/npuw/lazy_tensor.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class LazyTensor {
4848
void serialize(std::ostream& stream) const;
4949
static LazyTensor deserialize(std::istream& stream);
5050
void read_weight(const ov::npuw::s11n::Weights& weights);
51+
operator bool() const;
5152

5253
private:
5354
std::shared_ptr<LazyTensorImpl> m_impl = nullptr;

0 commit comments

Comments
 (0)