Skip to content

Commit 229527e

Browse files
committed
Update on "Introduce data schema to store raw tensors"
[ghstack-poisoned]
1 parent f24016d commit 229527e

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

exir/schema_data.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# pyre-strict
88

99
from dataclasses import dataclass
10-
from typing import List, Optional
10+
from typing import List
1111

1212
from executorch.exir.scalar_type import ScalarType
1313

@@ -20,6 +20,8 @@ class TensorMetadata:
2020
scalar_type: ScalarType
2121
dim_sizes: List[int]
2222
dim_order: List[bytes]
23+
storage_offset: int
24+
layout: int
2325

2426
offset: int
2527
size: int

schema/data.fbs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,31 @@ table TensorMetadata {
99
// The unique id used to connect the data and program.
1010
fully_qualified_name:string;
1111
scalar_type:ScalarType;
12+
13+
// Size of each dimension.
1214
dim_sizes:[int];
15+
16+
// Specifies in what order the dimensions are laid out in memory (from outer
17+
// to inner).
18+
//
19+
// For example, given a rank 3 Tensor of size (3, 5, 2). If we name
20+
// dimensions: [row, column, batch], then a dim_order of:
21+
// - (2, 0, 1) represents a [batch, row, column] ordering where "column" is
22+
// the innermost dimension, then comes "row", and the outermost dimension is
23+
// "batch".
24+
// - (0, 2, 1) represents a [row, batch, column] ordering where "column" is
25+
// the innermost dimension, then comes "batch", and the outermost dimension
26+
// is "row".
1327
dim_order:[ubyte];
1428

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;
36+
1537
// Tensor offsets are relative to each TensorSegment.
1638
// To retrieve a given tensor:
1739
// 1. segment_base_offset: from the file header.
@@ -56,7 +78,6 @@ table Data {
5678

5779
// Data segments.
5880
segments:[DataSegment];
59-
6081
}
6182

6283
root_type Data;

0 commit comments

Comments
 (0)