-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathschema.fbs
More file actions
159 lines (132 loc) · 3.36 KB
/
schema.fbs
File metadata and controls
159 lines (132 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Copyright (c) Meta Platforms, Inc. and affiliates.
namespace vkgraph;
// Update after any BC breaking changes.
file_identifier "VK00";
table OperatorCall {
node_id:uint;
name:string;
args:[int];
}
enum VkDataType : byte {
BOOL = 0,
UINT8 = 1,
INT8 = 2,
INT32 = 3,
FLOAT16 = 4,
FLOAT32 = 5,
FLOAT64 = 6,
INT64 = 7,
UNSET = 127,
}
// Describes what kind of GPU resource should be used to represent a tensor. The
// int values assigned to each entry must match the corresponding entry in
// api::StorageType.
enum VkStorageType : ubyte {
BUFFER = 0,
TEXTURE_3D = 1,
TEXTURE_2D = 2,
DEFAULT_STORAGE = 255,
}
// Describes how memory should be laid out in GPU memory. See the GPUMemoryLayout
// enum class in PyTorch Vulkan for more details. The int values assigned to each
// entry must match the corresponding entry in utils::GPUMemoryLayout.
enum VkMemoryLayout : ubyte {
TENSOR_WIDTH_PACKED = 0,
TENSOR_HEIGHT_PACKED = 1,
TENSOR_CHANNELS_PACKED = 2,
PACKED_INT8_4W4C = 3,
PACKED_INT8_4H4W = 4,
PACKED_INT8_4C1W = 8,
DEFAULT_LAYOUT = 255,
}
table VkTensor {
// Type of the tensor elements.
datatype:VkDataType;
// Shape dimensions.
dims:[uint];
// Index to the program's constant data. Negative indicates tensor is non-constant.
constant_id:int;
// Index to the shared memory object. Negative indicates the tensor doesn't share memory.
mem_obj_id:int;
// Storage type that should be used to represent this tensor
storage_type:VkStorageType = DEFAULT_STORAGE;
// Memory layout that should be used to represent this tensor
memory_layout:VkMemoryLayout = DEFAULT_LAYOUT;
// dtype to use for staging buffer. This may be different from the tensor's datatype
// if force_fp16 is enabled to force all float tensors to be represented as fp16.
staging_datatype:VkDataType = UNSET;
}
table Null {}
table Int {
int_val:long;
}
table Bool {
bool_val:bool;
}
table Double {
double_val:double;
}
table String {
string_val:string;
}
table IntList {
items:[long];
}
table DoubleList {
items:[double];
}
table BoolList {
items:[bool];
}
table ValueList {
items:[int];
}
table SymInt {
value:int;
}
union GraphTypes {
Null,
Int,
Double,
Bool,
VkTensor,
IntList,
DoubleList,
BoolList,
ValueList,
String,
SymInt,
}
table VkValue {
value:GraphTypes;
}
// Abstraction to represent a region of bytes in a raw data buffer. Useful for referencing raw data
// serialized outside of the flatbuffer.
table VkBytes {
offset:ulong;
length:ulong;
named_key:string;
}
table VkGraph {
// Schema version.
version:string;
// Objects
chain:[OperatorCall];
values:[VkValue];
// Indices
input_ids:[uint];
output_ids:[uint];
// Raw Objects (e.g. weight tensors and custom shaders)
constants:[VkBytes];
shaders:[VkBytes];
// Graph configuration
// As per flatbuffer BC/FC policy, new fields can be freely added to this
// section. It is recommended to provide default values, since older blobs
// without the field will be deserialized with the default value.
// Sets an override for the storage type and memory layout that will be used
// to represent a VkTensor if the VkTensor is not serialized with a particular
// storage type or memory layout setting
storage_type_override:VkStorageType = DEFAULT_STORAGE;
memory_layout_override:VkMemoryLayout = DEFAULT_LAYOUT;
}
root_type VkGraph;