File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Expand file tree Collapse file tree 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) {
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 (
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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;
You can’t perform that action at this time.
0 commit comments