Skip to content

Commit f852a99

Browse files
Investigate refactoring opportunities for batch management in Plugin and Compiler - review (metadata write/read)
1 parent 44532be commit f852a99

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/plugins/intel_npu/src/plugin/src/metadata.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,10 @@ void Metadata<METADATA_VERSION_2_1>::read(const ov::Tensor& tensor) {
126126
void Metadata<METADATA_VERSION_2_2>::read(std::istream& stream) {
127127
Metadata<METADATA_VERSION_2_1>::read(stream);
128128

129-
int64_t batchSize;
129+
std::optional<int64_t> batchSize;
130130
stream.read(reinterpret_cast<char*>(&batchSize), sizeof(batchSize));
131131

132-
if (batchSize) {
133-
_batchSize = std::optional(batchSize);
134-
}
132+
_batchSize = batchSize;
135133
}
136134

137135
void Metadata<METADATA_VERSION_2_2>::read(const ov::Tensor& tensor) {
@@ -186,9 +184,8 @@ void Metadata<METADATA_VERSION_2_1>::write(std::ostream& stream) {
186184
void Metadata<METADATA_VERSION_2_2>::write(std::ostream& stream) {
187185
Metadata<METADATA_VERSION_2_1>::write(stream);
188186

189-
if (_batchSize.has_value()) {
190-
stream.write(reinterpret_cast<const char*>(&_batchSize), sizeof(_batchSize));
191-
}
187+
// _batchSize is std::optional, so either the value or std::nullopt will be written
188+
stream.write(reinterpret_cast<const char*>(&_batchSize), sizeof(_batchSize));
192189

193190
append_padding_blob_size_and_magic(stream);
194191
}

0 commit comments

Comments
 (0)