Skip to content

Commit

Permalink
[executorch][flat_tensor] update flat tensor header test
Browse files Browse the repository at this point in the history
after changes in D68578075

Differential Revision: [D68971340](https://our.internmc.facebook.com/intern/diff/D68971340/)

[ghstack-poisoned]
  • Loading branch information
lucylq committed Jan 31, 2025
1 parent 3413971 commit f9114f2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion extension/flat_tensor/serialize/flat_tensor_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ uint64_t GetUInt64LE(const uint8_t* data) {
if (size < FlatTensorHeader::kNumHeadBytes) {
return Error::InvalidArgument;
}
const uint8_t* header = reinterpret_cast<const uint8_t*>(data);
const uint8_t* header =
reinterpret_cast<const uint8_t*>(data) + kHeaderOffset;

// Check magic bytes.
if (std::memcmp(
Expand Down
6 changes: 6 additions & 0 deletions extension/flat_tensor/serialize/flat_tensor_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ struct FlatTensorHeader {
*/
static constexpr size_t kNumHeadBytes = 64;

/**
* The offset into the serialized FlatTensor data where the FlatTensor
* header should begin.
*/
static constexpr size_t kHeaderOffset = 8;

/**
* The magic bytes that identify the header. This should be in sync with
* the magic in executorch/extension/flat_tensor/serialize/serialize.py
Expand Down
2 changes: 1 addition & 1 deletion extension/flat_tensor/test/flat_tensor_header_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ std::vector<uint8_t> CreateExampleFlatTensorHeader() {
memset(ret.data(), 0x55, ret.size());
// Copy the example header into the right offset.
memcpy(
ret.data(),
ret.data() + FlatTensorHeader::kHeaderOffset,
kExampleHeaderData,
sizeof(kExampleHeaderData));
return ret;
Expand Down

0 comments on commit f9114f2

Please sign in to comment.