Skip to content

Commit

Permalink
[executorch][serialization] Move DataSegment into shared common.fbs
Browse files Browse the repository at this point in the history
So that `DataSegment` can be shared by incoming data.fbs.

Differential Revision: [D65434369](https://our.internmc.facebook.com/intern/diff/D65434369/)

[ghstack-poisoned]
  • Loading branch information
lucylq committed Nov 5, 2024
1 parent 71de9ad commit 03626df
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
9 changes: 9 additions & 0 deletions exir/common_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,3 +32,9 @@ class ScalarType(IntEnum):
QUINT4x2 = 16
QUINT2x4 = 17
BITS16 = 22


@dataclass
class DataSegment:
offset: int
size: int
8 changes: 1 addition & 7 deletions exir/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions schema/common.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
15 changes: 0 additions & 15 deletions schema/program.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 03626df

Please sign in to comment.