From 874f4aa195a0717a3a6bed26cbdb2bd9da2a5990 Mon Sep 17 00:00:00 2001 From: lucylq Date: Tue, 25 Feb 2025 12:00:51 -0800 Subject: [PATCH] [executorch][weight sharing] Introduce NamedData to PTE schema See 'Schema Changes' in the [RFC]( Differential Revision: [D69430152](https://our.internmc.facebook.com/intern/diff/D69430152/) [ghstack-poisoned] --- exir/schema.py | 7 +++++++ schema/program.fbs | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/exir/schema.py b/exir/schema.py index 8e1434a2fe4..7dba623aebf 100644 --- a/exir/schema.py +++ b/exir/schema.py @@ -290,6 +290,12 @@ class SubsegmentOffsets: offsets: List[int] +@dataclass +class NamedData: + key: str + segment_index: int + + @dataclass class Program: version: int @@ -299,3 +305,4 @@ class Program: segments: List[DataSegment] constant_segment: SubsegmentOffsets mutable_data_segments: Optional[List[SubsegmentOffsets]] = None + named_data: Optional[List[NamedData]] = None diff --git a/schema/program.fbs b/schema/program.fbs index 7ab2175f8ac..62d6349ec09 100644 --- a/schema/program.fbs +++ b/schema/program.fbs @@ -431,6 +431,16 @@ table SubsegmentOffsets { offsets: [uint64]; } +// Attributes a name to data referenced by Program.segments. Typically used +// when data is referenced by multiple users. +table NamedData { + // The unique id of the data blob. + key: string; + + // Index of the segment in Program.segments + segment_index: uint32; +} + table Program { // Schema version. version: uint; @@ -468,6 +478,10 @@ table Program { // constant memory, copying it over, and then being unable to release the // constant segment. No two elements should point to the same segment. mutable_data_segments: [SubsegmentOffsets]; + + // [Optional] List of blobs keyed by a name. Stored in segments attached to + // the PTE file. + named_data: [NamedData]; } root_type Program;