blob: 3439b6927484e4733e79581e26fb10bfaa4c8150 [file] [log] [blame]
// Copyright (c) Meta Platforms, Inc. and affiliates.
//
// See README.md before modifying this file.
//
include "scalar_type.fbs";
// TODO make this unique from the main schemas namespace
namespace executorch_flatbuffer;
// Identifier of a valid bundled program schema.
file_identifier "BP04";
// Extension of written files.
file_extension "bp";
// Reason for basic struct: union value type can only be table/struct/string
table BundledInt {
int_val:long;
}
table BundledBool {
bool_val:bool;
}
table BundledDouble {
double_val:double;
}
// All information we need to bundle for a tensor EValue input.
table BundledTensor {
// The scalar type of Tensor
scalar_type: 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 BundledValueUnion {
BundledTensor,
BundledInt,
BundledBool,
BundledDouble,
}
// Abstraction for BundledIOSet values
table BundledValue {
val: BundledValueUnion;
}
// 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: [BundledValue];
// 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: [BundledValue];
}
table BundledString {
string_value: string;
}
table BundledBytes {
bytes_value: [ubyte];
}
union BundledAttachmentValueUnion {
BundledBytes,
BundledInt,
BundledDouble,
BundledBool,
BundledString,
}
// Abstraction for BundledAttachment values
table BundledAttachmentValue {
val: BundledAttachmentValueUnion;
}
// Extra data or files need to be recorded in BundledProgram
// for executing and verifying.
table BundledAttachment {
key: string;
val: BundledAttachmentValue;
}
// Context for testing and verifying an exceution plan.
table BundledExecutionPlanTest {
// Sets of input/outputs to test with.
test_sets: [BundledIOSet];
// Optional extra data used for verification.
metadata: [BundledAttachment];
}
// Executorch program bunlded with data for verification.
table BundledProgram {
// Schema version.
version:uint;
// Extra files or other data attached by user for verification
attachments: [BundledAttachment];
// 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;