|
24 | 24 | // Version 3c: Move constant tensor buffers & custom op buffers outside from |
25 | 25 | // Flatbuffers. Has backward compatibility with version 3, 3a and |
26 | 26 | // 3b. |
| 27 | +// Version 3d: Add ExternalBuffer tables and tensor.external_buffer field for |
| 28 | +// referencing immutable data stored in external files. |
27 | 29 |
|
28 | 30 | namespace tflite; |
29 | 31 |
|
@@ -263,6 +265,11 @@ table Tensor { |
263 | 265 | // Currently only 1 subtype is supported. The field is defined as an array for |
264 | 266 | // flexibility of supporting multiple subtypes in the future. |
265 | 267 | 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; |
266 | 273 | } |
267 | 274 |
|
268 | 275 | // A list of builtin operators. Builtin operators are slightly faster than custom |
@@ -1613,6 +1620,22 @@ table Buffer { |
1613 | 1620 | size: ulong; |
1614 | 1621 | } |
1615 | 1622 |
|
| 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 | + |
1616 | 1639 | table Metadata { |
1617 | 1640 | // A human readable string to uniquely identify a Metadata. |
1618 | 1641 | name:string; |
@@ -1680,6 +1703,12 @@ table Model { |
1680 | 1703 |
|
1681 | 1704 | // Optional SignatureDefs for the model. |
1682 | 1705 | 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]; |
1683 | 1712 | } |
1684 | 1713 |
|
1685 | 1714 | root_type Model; |
0 commit comments