Skip to content

Commit

Permalink
feat(compression): check metadata schema version
Browse files Browse the repository at this point in the history
Add a check in `micro_allocator.cc` to verify the compression
metadata schema version. If the schema version in the metadata is
greater than the expected version, log a schema version mismatch
error and return a `nullptr`. This prevents potential issues
arising from using a newer, unsupported schema version.

BUG=part of #2636
  • Loading branch information
ddavis-2015 authored and rkuester committed Dec 17, 2024
1 parent b1d8a08 commit e8f8298
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tensorflow/lite/micro/micro_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,14 @@ const tflite::micro::compression::Metadata* GetCompressionMetadata(
MicroPrintf("Compression: verification failure");
return nullptr;
} else {
tflite::micro::compression::MetadataT schema;
if (compression_metadata->schema_version() > schema.schema_version) {
MicroPrintf("Compression: schema version mismatch (using %d got %d)",
schema.schema_version,
compression_metadata->schema_version());
return nullptr;
}

return compression_metadata;
}
}
Expand Down

0 comments on commit e8f8298

Please sign in to comment.