Skip to content

Commit 859cf52

Browse files
committed
Update on "Introduce data schema to store raw tensors"
Differential Revision: [D65156641](https://our.internmc.facebook.com/intern/diff/D65156641) [ghstack-poisoned]
1 parent cec36f6 commit 859cf52

File tree

1 file changed

+15
-29
lines changed

1 file changed

+15
-29
lines changed

schema/data.fbs

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ namespace executorch_flatbuffer;
33

44
// Update after BC breaking changes.
55
file_identifier "DT01";
6-
file_extension "data";
6+
file_extension "ptd";
77

88
table TensorMetadata {
99
// The unique id used to connect the data and program.
10-
fully_qualified_name:string;
11-
scalar_type:ScalarType;
10+
fully_qualified_name: string;
11+
scalar_type: ScalarType;
1212

1313
// Size of each dimension.
14-
dim_sizes:[int];
14+
dim_sizes: [int32];
1515

1616
// Specifies in what order the dimensions are laid out in memory (from outer
1717
// to inner).
@@ -24,34 +24,19 @@ table TensorMetadata {
2424
// - (0, 2, 1) represents a [row, batch, column] ordering where "column" is
2525
// the innermost dimension, then comes "batch", and the outermost dimension
2626
// is "row".
27-
dim_order:[ubyte];
27+
dim_order: [uint8];
2828

29-
// Offset in scalar_type elements (e.g., multiples of 4 bytes for an int
30-
// scalar type) from the beginning of the tensor buffer to the beginning of
31-
// the actual data. Currently, the runtime only supports a value of zero.
32-
storage_offset:int;
33-
34-
// May not be needed.
35-
layout:byte;
29+
// Segment index that the tensor data is stored in.
30+
segment_index: uint32;
3631

3732
// Tensor offsets are relative to each TensorSegment.
3833
// To retrieve a given tensor:
3934
// 1. segment_base_offset: from the file header.
40-
// 2. segment offset: segments[tensor_segments[i].segment_index].offset
35+
// 2. segment offset: segments[segment_index].offset
4136
// This is likely to be 0 (all the tensors in one segment).
4237
// 3. tensor offset: tensor_segments[i].tensor_metadata[j].offset
43-
// May need to binary search over tensor_metadata to find the matching
44-
// tensor using fqn.
38+
// Find the relevant index j by matching on tensor fqn.
4539
offset: uint64;
46-
size: uint64;
47-
}
48-
49-
table TensorSegment {
50-
// Index of the segment in Data.segments.
51-
segment_index: uint;
52-
53-
// Tensor information, including the offset and size.
54-
tensor_metadata:[TensorMetadata];
5540
}
5641

5742
table DataSegment {
@@ -66,18 +51,19 @@ table DataSegment {
6651
size: uint64;
6752
}
6853

69-
table Data {
54+
table DataFile {
7055
// Schema version.
71-
version:uint;
56+
version: uint32;
7257

73-
// Alignment for each tensor.
58+
// Alignment for each tensor in bytes. Offsets of the tensor provided
59+
// in TensorMetadata.offset are aligned to tensor_alignment.
7460
tensor_alignment: uint32;
7561

7662
// Tensor information.
77-
tensor_segments:[TensorSegment];
63+
tensor_segments: [TensorMetadata];
7864

7965
// Data segments.
80-
segments:[DataSegment];
66+
segments: [DataSegment];
8167
}
8268

8369
root_type Data;

0 commit comments

Comments
 (0)