Skip to content

Commit f9114f2

Browse files
committed
[executorch][flat_tensor] update flat tensor header test
after changes in D68578075 Differential Revision: [D68971340](https://our.internmc.facebook.com/intern/diff/D68971340/) [ghstack-poisoned]
1 parent 3413971 commit f9114f2

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

extension/flat_tensor/serialize/flat_tensor_header.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ uint64_t GetUInt64LE(const uint8_t* data) {
7676
if (size < FlatTensorHeader::kNumHeadBytes) {
7777
return Error::InvalidArgument;
7878
}
79-
const uint8_t* header = reinterpret_cast<const uint8_t*>(data);
79+
const uint8_t* header =
80+
reinterpret_cast<const uint8_t*>(data) + kHeaderOffset;
8081

8182
// Check magic bytes.
8283
if (std::memcmp(

extension/flat_tensor/serialize/flat_tensor_header.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ struct FlatTensorHeader {
2323
*/
2424
static constexpr size_t kNumHeadBytes = 64;
2525

26+
/**
27+
* The offset into the serialized FlatTensor data where the FlatTensor
28+
* header should begin.
29+
*/
30+
static constexpr size_t kHeaderOffset = 8;
31+
2632
/**
2733
* The magic bytes that identify the header. This should be in sync with
2834
* the magic in executorch/extension/flat_tensor/serialize/serialize.py

extension/flat_tensor/test/flat_tensor_header_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ std::vector<uint8_t> CreateExampleFlatTensorHeader() {
6868
memset(ret.data(), 0x55, ret.size());
6969
// Copy the example header into the right offset.
7070
memcpy(
71-
ret.data(),
71+
ret.data() + FlatTensorHeader::kHeaderOffset,
7272
kExampleHeaderData,
7373
sizeof(kExampleHeaderData));
7474
return ret;

0 commit comments

Comments
 (0)