Skip to content

Commit 6a3faa7

Browse files
committed
[executorch][serialization] Move DataSegment into shared common.fbs
Pull Request resolved: #6679 So that `DataSegment` can be shared by incoming data.fbs. Update all instances of `common.fbs` with the changes. ghstack-source-id: 253121253 @exported-using-ghexport Differential Revision: [D65434369](https://our.internmc.facebook.com/intern/diff/D65434369/)
1 parent 0afda4a commit 6a3faa7

File tree

6 files changed

+58
-22
lines changed

6 files changed

+58
-22
lines changed

devtools/bundled_program/schema/common.fbs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,19 @@ enum ScalarType : byte {
3535
// BITS4x2 = 20,
3636
// BITS8 = 21,
3737
}
38+
39+
// Describes a contiguous piece of data that lives outside of the flatbuffer data,
40+
// typically appended afterwards in the file.
41+
// For .pte and .ptd files, the "extended header" in the file, when present,
42+
// points to the segment base offset.
43+
table DataSegment {
44+
// Segment offsets are relative to the segment base offset provided in the
45+
// extended file header. Segments will typically be aligned in a way to make
46+
// it possible to use mmap() to load them.
47+
offset: uint64;
48+
49+
// The size in bytes of valid data starting at the offset. The segment
50+
// data may be followed by padding before the segment that follows it,
51+
// to make it easier to use mmap().
52+
size: uint64;
53+
}

devtools/etdump/common.fbs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,19 @@ enum ScalarType : byte {
3535
// BITS4x2 = 20,
3636
// BITS8 = 21,
3737
}
38+
39+
// Describes a contiguous piece of data that lives outside of the flatbuffer data,
40+
// typically appended afterwards in the file.
41+
// For .pte and .ptd files, the "extended header" in the file, when present,
42+
// points to the segment base offset.
43+
table DataSegment {
44+
// Segment offsets are relative to the segment base offset provided in the
45+
// extended file header. Segments will typically be aligned in a way to make
46+
// it possible to use mmap() to load them.
47+
offset: uint64;
48+
49+
// The size in bytes of valid data starting at the offset. The segment
50+
// data may be followed by padding before the segment that follows it,
51+
// to make it easier to use mmap().
52+
size: uint64;
53+
}

exir/common_schema.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66

77
# pyre-unsafe
88

9+
from dataclasses import dataclass
910
from enum import IntEnum
1011

12+
# Check exir/common.fbs for explanations of these fields.
13+
1114

1215
class ScalarType(IntEnum):
1316
BYTE = 0
@@ -29,3 +32,9 @@ class ScalarType(IntEnum):
2932
QUINT4x2 = 16
3033
QUINT2x4 = 17
3134
BITS16 = 22
35+
36+
37+
@dataclass
38+
class DataSegment:
39+
offset: int
40+
size: int

exir/schema.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from executorch.exir.backend.compile_spec_schema import CompileSpec
1414

15-
from executorch.exir.common_schema import ScalarType
15+
from executorch.exir.common_schema import DataSegment, ScalarType
1616

1717

1818
@dataclass
@@ -272,12 +272,6 @@ class ExecutionPlan:
272272
non_const_buffer_sizes: List[int]
273273

274274

275-
@dataclass
276-
class DataSegment:
277-
offset: int
278-
size: int
279-
280-
281275
@dataclass
282276
class SubsegmentOffsets:
283277
segment_index: int

schema/common.fbs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,19 @@ enum ScalarType : byte {
3535
// BITS4x2 = 20,
3636
// BITS8 = 21,
3737
}
38+
39+
// Describes a contiguous piece of data that lives outside of the flatbuffer data,
40+
// typically appended afterwards in the file.
41+
// For .pte and .ptd files, the "extended header" in the file, when present,
42+
// points to the segment base offset.
43+
table DataSegment {
44+
// Segment offsets are relative to the segment base offset provided in the
45+
// extended file header. Segments will typically be aligned in a way to make
46+
// it possible to use mmap() to load them.
47+
offset: uint64;
48+
49+
// The size in bytes of valid data starting at the offset. The segment
50+
// data may be followed by padding before the segment that follows it,
51+
// to make it easier to use mmap().
52+
size: uint64;
53+
}

schema/program.fbs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -392,21 +392,6 @@ table BackendDelegateInlineData {
392392
data: [ubyte] (force_align: 16); // @executorch-delegate-alignment
393393
}
394394

395-
// Describes a contiguous piece of data that lives outside of the flatbuffer data,
396-
// typically appended afterwards in the file. The "extended header" in the file,
397-
// when present, points to the segment base offset.
398-
table DataSegment {
399-
// Segment offsets are relative to the segment base offset provided in
400-
// the extended file header. Segments will typically be aligned in a
401-
// way to make it possible to use mmap() to load them.
402-
offset: uint64;
403-
404-
// The size in bytes of valid data starting at the offset. The segment
405-
// data may be followed by padding before the segment that follows it,
406-
// to make it easier to use mmap().
407-
size: uint64;
408-
}
409-
410395
// Describes data offsets into a particular segment
411396
table SubsegmentOffsets {
412397
// Index of the segment in Program.segments

0 commit comments

Comments
 (0)