File tree 3 files changed +9
-2
lines changed 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,8 @@ uint64_t GetUInt64LE(const uint8_t* data) {
76
76
if (size < FlatTensorHeader::kNumHeadBytes ) {
77
77
return Error::InvalidArgument;
78
78
}
79
- const uint8_t * header = reinterpret_cast <const uint8_t *>(data);
79
+ const uint8_t * header =
80
+ reinterpret_cast <const uint8_t *>(data) + kHeaderOffset ;
80
81
81
82
// Check magic bytes.
82
83
if (std::memcmp (
Original file line number Diff line number Diff line change @@ -23,6 +23,12 @@ struct FlatTensorHeader {
23
23
*/
24
24
static constexpr size_t kNumHeadBytes = 64 ;
25
25
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
+
26
32
/* *
27
33
* The magic bytes that identify the header. This should be in sync with
28
34
* the magic in executorch/extension/flat_tensor/serialize/serialize.py
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ std::vector<uint8_t> CreateExampleFlatTensorHeader() {
68
68
memset (ret.data (), 0x55 , ret.size ());
69
69
// Copy the example header into the right offset.
70
70
memcpy (
71
- ret.data (),
71
+ ret.data () + FlatTensorHeader:: kHeaderOffset ,
72
72
kExampleHeaderData ,
73
73
sizeof (kExampleHeaderData ));
74
74
return ret;
You can’t perform that action at this time.
0 commit comments