You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Table to put additional information about tensors in that is not applicable
58
+
// to the vast majority of tensors in the vast majority of programs.
59
+
table ExtraTensorInfo {
60
+
// [Optional] Specifies the SubsegmentOffsets in
61
+
// program.mutable_data_segments that specifies where the data is located in.
62
+
// If not present and the data is located in a segment, then the data is in
63
+
// the first index.
64
+
mutable_data_segments_idx:uint64;
65
+
66
+
// [Optional] The unique name of the tensor. e.g. 'mod.linear.weight'
67
+
fully_qualified_name:string;
68
+
}
69
+
56
70
table Tensor {
57
71
scalar_type:ScalarType;
58
72
@@ -63,26 +77,47 @@ table Tensor {
63
77
64
78
sizes:[int];
65
79
66
-
// Specifies in what order the dimensions are laid out in memory (from outer to inner).
67
-
// For example, given a rank 3 Tensor of size (3, 5, 2). If we name dimensions: [row, column, batch], then a dim_order of:
68
-
// (2, 0, 1) represents a [batch, row, column] ordering where "column" is the innermost dimension, then comes "row", and the outermost dimension is "batch".
69
-
// (0, 2, 1) represents a [row, batch, column] ordering where "column" is the innermost dimension, then comes "batch", and the outermost dimension is "row".
80
+
// Specifies in what order the dimensions are laid out in memory (from outer
81
+
// to inner).
82
+
//
83
+
// For example, given a rank 3 Tensor of size (3, 5, 2). If we name
84
+
// dimensions: [row, column, batch], then a dim_order of:
85
+
// - (2, 0, 1) represents a [batch, row, column] ordering where "column" is
86
+
// the innermost dimension, then comes "row", and the outermost dimension is
87
+
// "batch".
88
+
// - (0, 2, 1) represents a [row, batch, column] ordering where "column" is
89
+
// the innermost dimension, then comes "batch", and the outermost dimension
90
+
// is "row".
70
91
dim_order:[ubyte];
71
92
72
93
// out of scope M1
73
94
requires_grad:bool;
74
95
75
-
// Overall, a Tensor is either constant or non-constant, except we differentiate 2 special
76
-
// variants of non-constant Tensor ("input" and control-flow "placeholder") as a special
77
-
// optimization to avoid holding unnecessary AllocationDetails.
96
+
// Overall, a Tensor is either constant or mutable. At method load time
97
+
// constant tensors receive a dataptr into the serialized program. Mutable
98
+
// tensors can either receive a pointer from the heirarchical allocator or a
99
+
// nullptr if they will receive a data pointer at execution time (inputs
100
+
// and control flow placeholders can be like this). Mutable tensors may or
101
+
// may not also have an initial value in the serialized program.
102
+
//
78
103
// In summary:
79
-
// constant_buffer_idx > 0, allocation_info = Null: Tensor is a constant
80
-
// constant_buffer_idx = 0, allocation_info = Non Null: Tensor is a non-constant.
81
-
// constant_buffer_idx = 0, allocation_info = Null: Tensor is a non-constant
82
-
// that will receive a dataptr at input time or during execution.
104
+
// data_buffer_idx > 0, allocation_info = Null: Tensor is a constant.
105
+
// data_buffer_idx = 0, allocation_info = Non Null: Tensor is mutable and
106
+
// will receive a dataptr at method load time.
107
+
// data_buffer_idx = 0, allocation_info = Null: Tensor is mutable and
108
+
// will receive a dataptr at input time or during execution.
109
+
// data_buffer_idx > 0, allocation_info = Non Null: Tensor is mutable and
110
+
// will receive a dataptr at method load time, and has an initial state.
83
111
//
84
-
// Index to the program's constant buffer table, value 0 is reserved to indicate non constant
85
-
constant_buffer_idx:uint;
112
+
// Tensor data is stored inline if program.constant_buffer is null. Otherwise
113
+
// it is in a segment. If this tensor's allocation_info is null then the
114
+
// tensor data location is specified by program.constant_segment. If the
115
+
// allocation_info is non_null then the data is somewhere in
116
+
// program.mutable_data_segments. If tensor_info is Null, then the data is
117
+
// in program.mutable_data_segments[0] otherwise if tensor_info is non-null
118
+
// then the mutable_data_segment index is specified by
119
+
// tensor_info.mutable_data_segments_index.
120
+
data_buffer_idx:uint;
86
121
87
122
// [Optional] preallocation details for non-constants (null otherwise).
88
123
allocation_info:AllocationDetails;
@@ -102,7 +137,11 @@ table Tensor {
102
137
//
103
138
// 3. dynamism == DYNAMIC_UNBOUND: the stored sizes field can be ignored since
104
139
// shape is fully dynamic.
105
-
shape_dynamism: TensorShapeDynamism;
140
+
shape_dynamism:TensorShapeDynamism;
141
+
142
+
// [Optional] Additional information about the Tensor that is not applicable
143
+
// to most tensors.
144
+
extra_tensor_info:ExtraTensorInfo;
106
145
}
107
146
108
147
table Int {
@@ -276,9 +315,11 @@ table BackendDelegate {
276
315
compile_specs: [CompileSpec];
277
316
}
278
317
279
-
// A sequence of blocking instructions to be executed in order. The abstraction is not currently leveraged,
280
-
// all current programs are 1 chain. We are leaving chains as part of the program definition for future
281
-
// use cases around graph level async where different threads will be represented as seperate chains.
318
+
// A sequence of blocking instructions to be executed in order. The
319
+
// abstraction is not currently leveraged, all current programs are 1 chain.
320
+
// We are leaving chains as part of the program definition for future use cases
321
+
// around graph level async where different threads will be represented as
322
+
// seperate chains.
282
323
table Chain {
283
324
// Indices of the values that are (non-static) inputs into this Chain.
284
325
inputs:[int];
@@ -401,7 +442,17 @@ table Program {
401
442
// offset. If constant_segment.offsets field is non-empty, constant_buffer
402
443
// must be empty. constant_segment.offsets[0] is reserved to be pointed to by
403
444
// non-constant Tensors.
404
-
constant_segment: SubsegmentOffsets;
445
+
constant_segment:SubsegmentOffsets;
446
+
447
+
// [Optional] Describes the offsets into various segments for each mutable
448
+
// tensor. Only mutable tensors with a meaningful initial state are
449
+
// serialized here (for example weights that will be trained on-device as
450
+
// opposed to just layer activations). Seperate from the constant_segment to
451
+
// reduce peak memory usage by letting us read directly from the PTE file
452
+
// into the mutable tensor, as opposed to loading the .pte data into
453
+
// constant memory, copying it over, and then being unable to release the
454
+
// constant segment. No two elements should point to the same segment.
0 commit comments