Skip to content

Commit

Permalink
feat(compression): check metadata schema version (#3022)
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
rkuester authored Dec 18, 2024
1 parent cc09a49 commit 478bb78
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 478bb78

Please sign in to comment.