Skip to content

Commit 8412359

Browse files
ai-edge-botcopybara-github
authored andcommitted
Update tflite schema to allow external buffer
LiteRT-Converter-PiperOrigin-RevId: 826640205
1 parent 77ce0bf commit 8412359

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tflite/converter/schema/schema.fbs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
// Version 3c: Move constant tensor buffers & custom op buffers outside from
2525
// Flatbuffers. Has backward compatibility with version 3, 3a and
2626
// 3b.
27+
// Version 3d: Add ExternalBuffer tables and tensor.external_buffer field for
28+
// referencing immutable data stored in external files.
2729

2830
namespace tflite;
2931

@@ -263,6 +265,11 @@ table Tensor {
263265
// Currently only 1 subtype is supported. The field is defined as an array for
264266
// flexibility of supporting multiple subtypes in the future.
265267
variant_tensors:[VariantSubType];
268+
269+
// Optional reference to an ExternalBuffer entry that stores constant tensor
270+
// data outside of the FlatBuffer. A value of 0 indicates that the tensor uses
271+
// the traditional embedded buffer field instead.
272+
external_buffer:uint;
266273
}
267274

268275
// A list of builtin operators. Builtin operators are slightly faster than custom
@@ -1613,6 +1620,22 @@ table Buffer {
16131620
size: ulong;
16141621
}
16151622

1623+
// Groups external buffers by file/URI.
1624+
table ExternalBufferGroup {
1625+
name:string;
1626+
}
1627+
1628+
// Describes an immutable data slice stored in an external file.
1629+
table ExternalBuffer {
1630+
// Unique identifier for this external buffer.
1631+
id:uint;
1632+
// Index into the external_buffer_groups array.
1633+
group:uint;
1634+
offset:ulong;
1635+
length:ulong;
1636+
packing:string;
1637+
}
1638+
16161639
table Metadata {
16171640
// A human readable string to uniquely identify a Metadata.
16181641
name:string;
@@ -1680,6 +1703,12 @@ table Model {
16801703

16811704
// Optional SignatureDefs for the model.
16821705
signature_defs:[SignatureDef];
1706+
1707+
// Optional groups for external weight buffers.
1708+
external_buffer_groups:[ExternalBufferGroup];
1709+
1710+
// Optional list of external weight buffers referenced by tensors.
1711+
external_buffers:[ExternalBuffer];
16831712
}
16841713

16851714
root_type Model;

0 commit comments

Comments
 (0)