| // Copyright (c) Meta Platforms, Inc. and affiliates. |
| |
| // |
| // See README.md before modifying this file. |
| // |
| |
| include "scalar_type.fbs"; |
| |
| namespace bundled_program_flatbuffer; |
| |
| // Identifier of a valid bundled program schema. |
| file_identifier "BP06"; |
| // Extension of written files. |
| file_extension "bpte"; |
| |
| // Reason for basic struct: union value type can only be table/struct/string |
| table Int { |
| int_val:long; |
| } |
| |
| table Bool { |
| bool_val:bool; |
| } |
| |
| table Double { |
| double_val:double; |
| } |
| |
| // All information we need to bundle for a tensor EValue input. |
| table Tensor { |
| // The scalar type of Tensor |
| scalar_type: executorch_flatbuffer.ScalarType; |
| // The target sizes of the tensor. |
| sizes: [int]; |
| // The contents of the corresponding input tensor. |
| data: [ubyte] (force_align: 16); |
| dim_order:[ubyte]; |
| } |
| |
| union ValueUnion { |
| Tensor, |
| Int, |
| Bool, |
| Double, |
| } |
| |
| // Abstraction for BundledIOSet values |
| table Value { |
| val: ValueUnion; |
| } |
| |
| // All inputs and referenced outputs needs for single verification. |
| table BundledIOSet { |
| // All inputs required by Program for execution. Its length should be |
| // equal to the length of program inputs. |
| inputs: [Value]; |
| |
| // The expected outputs generated while running the model in eager mode |
| // using the inputs provided. Its length should be equal to the length |
| // of program outputs. |
| expected_outputs: [Value]; |
| } |
| |
| |
| // Context for testing and verifying an exceution plan. |
| table BundledExecutionPlanTest { |
| |
| // The name of the method to test; e.g., "forward" for the forward() method |
| // of an nn.Module. This name match a method defined by the ExecuTorch |
| // program. |
| method_name: string; |
| |
| // Sets of input/outputs to test with. |
| test_sets: [BundledIOSet]; |
| } |
| |
| // Executorch program bunlded with data for verification. |
| table BundledProgram { |
| // Schema version. |
| version:uint; |
| |
| // Test sets and other meta datas to verify the whole program. |
| // Each BundledExecutionPlanTest should be used for the execution plan of program sharing same index. |
| // Its length should be equal to the number of execution plans in program. |
| execution_plan_tests: [BundledExecutionPlanTest]; |
| |
| // The binary data of a serialized Executorch program. |
| // The following `force_align` may sliently override any larger force_align |
| // used in the program. Therefore, to keep the data (including constant |
| // tensor, delegate data, etc, see schema.fbs for more info) in the |
| // executorch program keeps the same alignment as original no matter how |
| // the program schema changes, we need to make the force_align here the max |
| // one around all kinds of force_align in the current and future program |
| // schema, so we use the 16, the largest possible alignment of flatbuffer, |
| // as the force_align here. |
| // In the future, we may need to revisit that to enforce larger alignment |
| // constraint. If needed, check against FLATBUFFERS_MAX_ALIGNMENT in the |
| // flatbuffers/base.h, which is the given alignment ceiling of flatbuffer. |
| program: [ubyte] (force_align: 16); |
| } |
| |
| root_type BundledProgram; |