Skip to content

Commit b05041d

Browse files
committed
Update on "[executorch][schema] Add 'EXTERNAL' to DataLocation in schema"
To indicate if a tensor is external to the PTE file or not. Currently, we can also use the existence of 'fqn' to determine if a tensor is external or not. I think it's better to have a specific location field as fqn may be required for cases besides external tensor storage. Differential Revision: [D66523171](https://our.internmc.facebook.com/intern/diff/D66523171/) [ghstack-poisoned]
2 parents 57aedf0 + b4c8222 commit b05041d

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

exir/schema.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ class TensorShapeDynamism(IntEnum):
4343
DYNAMIC_UNBOUND = 2
4444

4545

46-
class DataLocation(IntEnum):
47-
INLINE = 0
48-
SEGMENT = 1
49-
EXTERNAL = 2
46+
class TensorDataLocation(IntEnum):
47+
CONSTANT_SEGMENT = 0
48+
EXTERNAL = 1
5049

5150

5251
@dataclass
@@ -57,7 +56,7 @@ class ExtraTensorInfo:
5756

5857
mutable_data_segments_idx: int = 0
5958
fully_qualified_name: Optional[str] = None
60-
location: Optional[DataLocation] = None
59+
location: TensorDataLocation = TensorDataLocation.CONSTANT_SEGMENT
6160

6261

6362
@dataclass
@@ -230,6 +229,11 @@ class FrameList:
230229
items: List[Frame]
231230

232231

232+
class DataLocation(IntEnum):
233+
INLINE = 0
234+
SEGMENT = 1
235+
236+
233237
@dataclass
234238
class BackendDelegateDataReference:
235239
location: DataLocation

schema/program.fbs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,12 @@ enum TensorShapeDynamism : byte {
5353
DYNAMIC_UNBOUND = 2,
5454
}
5555

56-
// Indicates where a piece of data is stored.
57-
enum DataLocation : byte {
58-
// Stored directly in the flatbuffer.
59-
INLINE = 0,
60-
// Stored in a segment.
61-
SEGMENT = 1,
62-
// Stored outside of the flatbuffer.
63-
EXTERNAL = 2,
56+
// Indicates where a tensor is stored.
57+
enum TensorDataLocation : byte {
58+
// Stored in the constant segment of the PTE file.
59+
CONSTANT_SEGMENT = 0,
60+
// Stored outside of the PTE file.
61+
EXTERNAL = 1,
6462
}
6563

6664
// Table to put additional information about tensors in that is not applicable
@@ -75,11 +73,11 @@ table ExtraTensorInfo {
7573
// [Optional] The unique name of the tensor. e.g. 'mod.linear.weight'
7674
fully_qualified_name: string;
7775

78-
// [Optional] Specifies where the tensor is stored; either in a segment or external
79-
// location. If a constant tensor is stored externally, data_buffer_idx
80-
// is not relevant; use extra_tensor_info.fully_qualified_name to match up
81-
// the external tensor.
82-
location: DataLocation;
76+
// [Optional] Specifies where the tensor is stored; either in the constant segment
77+
// (default case) or an external location. If a constant tensor is stored externally,
78+
// data_buffer_idx is not relevant; use extra_tensor_info.fully_qualified_name to
79+
// match up the external tensor.
80+
location: TensorDataLocation;
8381
}
8482

8583
table Tensor {
@@ -290,6 +288,14 @@ table FrameList {
290288
items: [Frame];
291289
}
292290

291+
// Indicates where a piece of data is stored.
292+
enum DataLocation : byte {
293+
// Stored directly in the flatbuffer.
294+
INLINE = 0,
295+
// Stored in a segment.
296+
SEGMENT = 1,
297+
}
298+
293299
// Indicates where the delegate data is stored
294300
table BackendDelegateDataReference {
295301
// Indicates which list to index into:

0 commit comments

Comments
 (0)