diff --git a/exir/common_schema.py b/exir/common_schema.py index 5d41038610..cc69c7cc85 100644 --- a/exir/common_schema.py +++ b/exir/common_schema.py @@ -6,9 +6,12 @@ # pyre-unsafe +from dataclasses import dataclass from enum import IntEnum +# Check exir/common.fbs for explanations of these fields. + class ScalarType(IntEnum): BYTE = 0 CHAR = 1 @@ -29,3 +32,9 @@ class ScalarType(IntEnum): QUINT4x2 = 16 QUINT2x4 = 17 BITS16 = 22 + + +@dataclass +class DataSegment: + offset: int + size: int diff --git a/exir/schema.py b/exir/schema.py index c52240445f..4759bbd0f4 100644 --- a/exir/schema.py +++ b/exir/schema.py @@ -12,7 +12,7 @@ from executorch.exir.backend.compile_spec_schema import CompileSpec -from executorch.exir.common_schema import ScalarType +from executorch.exir.common_schema import ScalarType, DataSegment @dataclass @@ -272,12 +272,6 @@ class ExecutionPlan: non_const_buffer_sizes: List[int] -@dataclass -class DataSegment: - offset: int - size: int - - @dataclass class SubsegmentOffsets: segment_index: int diff --git a/schema/common.fbs b/schema/common.fbs index fc299ac691..0236416951 100644 --- a/schema/common.fbs +++ b/schema/common.fbs @@ -35,3 +35,19 @@ enum ScalarType : byte { // BITS4x2 = 20, // BITS8 = 21, } + +// Describes a contiguous piece of data that lives outside of the flatbuffer data, +// typically appended afterwards in the file. +// For .pte and .ptd files, the "extended header" in the file, when present, +// points to the segment base offset. +table DataSegment { + // Segment offsets are relative to the segment base offset provided in the + // extended file header. Segments will typically be aligned in a way to make + // it possible to use mmap() to load them. + offset: uint64; + + // The size in bytes of valid data starting at the offset. The segment + // data may be followed by padding before the segment that follows it, + // to make it easier to use mmap(). + size: uint64; +} diff --git a/schema/program.fbs b/schema/program.fbs index 7e552de23e..e34ebc1ffd 100644 --- a/schema/program.fbs +++ b/schema/program.fbs @@ -392,21 +392,6 @@ table BackendDelegateInlineData { data: [ubyte] (force_align: 16); // @executorch-delegate-alignment } -// Describes a contiguous piece of data that lives outside of the flatbuffer data, -// typically appended afterwards in the file. The "extended header" in the file, -// when present, points to the segment base offset. -table DataSegment { - // Segment offsets are relative to the segment base offset provided in - // the extended file header. Segments will typically be aligned in a - // way to make it possible to use mmap() to load them. - offset: uint64; - - // The size in bytes of valid data starting at the offset. The segment - // data may be followed by padding before the segment that follows it, - // to make it easier to use mmap(). - size: uint64; -} - // Describes data offsets into a particular segment table SubsegmentOffsets { // Index of the segment in Program.segments