Skip to content

[executorch][serialization] Move DataSegment into shared common.fbs #6679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions devtools/bundled_program/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;
}
16 changes: 16 additions & 0 deletions devtools/etdump/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;
}
9 changes: 9 additions & 0 deletions exir/common_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

# pyre-unsafe

from dataclasses import dataclass
from enum import IntEnum

# Check exir/common.fbs for explanations of these fields.


class ScalarType(IntEnum):
BYTE = 0
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 DataSegment, ScalarType


@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
Loading