1// Copyright (c) Meta Platforms, Inc. and affiliates. 2 3namespace fb_xnnpack; 4 5// datatype for xnn-values 6enum XNNDatatype : short { 7 /// Invalid data type. Valid Values never have this datatype. 8 xnn_datatype_invalid = 0, 9 /// IEEE754 single-precision floating-point. 10 xnn_datatype_fp32 = 1, 11 /// IEEE754 half-precision floating-point. 12 xnn_datatype_fp16 = 2, 13 /// Quantized 8-bit signed integer with shared per-Value quantization parameters. 14 xnn_datatype_qint8 = 3, 15 /// Quantized 32-bit signed integer with shared per-Value quantization parameters. 16 xnn_datatype_qint32 = 4, 17} 18 19// taken from executorch 20// Data buffer abstraction. 21table Buffer { 22 storage:[ubyte] (force_align: 16); 23} 24 25table XNNTensorValue { 26 // type of the tensor elements. 27 datatype:XNNDatatype; 28 // number of dimensions in the shape. 29 num_dims:uint; 30 // pointer to an array of @a num_dims shape dimensions. If num_dims is 0, this pointer can be NULL. 31 // XNNPACK does not keep any pointers to this array after the function returns. 32 dims:[uint]; 33 // Index to the program's constant buffer table, value 0 is reserved to indicate non constant 34 constant_buffer_idx:uint; 35 // external ID for the Value. The ID must be within the range of reserved Value IDs specified on 36 // the Subgraph creation. If the external ID is XNN_INVALID_VALUE_ID, an internal ID will be 37 // created for the Value. 38 external_id:uint; 39 // binary features of the Value. Supported values are any combination of XNN_VALUE_FLAG_EXTERNAL_INPUT 40 // and XNN_VALUE_FLAG_EXTERNAL_OUTPUT. 41 flags:uint; 42 // pointer to the variable that will be initialized with the Value ID upon successful return. If a 43 // valid @a external_id was provided, the variable will be initialized with the @a external_id value. 44 id_out:uint; 45} 46 47union XNodeUnion { 48 XNNAdd, 49} 50 51union XValueUnion { 52 XNNTensorValue, 53} 54 55table XNode { 56 xnode:XNodeUnion; 57 // An int which can be linked back to the node in the origin graph 58 debug_handle:uint; 59} 60 61table XValue { 62 xvalue:XValueUnion; 63} 64 65table XNNAdd { 66 input1_id:uint; 67 input2_id:uint; 68 output_id:uint; 69 flags:uint; 70} 71 72table XNNGraph { 73 // Schema version. 74 version:string; 75 xnodes:[XNode]; 76 xvalues:[XValue]; 77 78 // Number of external inputs/outputs 79 num_externs:uint; 80 81 // Ids of external inputs 82 input_ids:[uint]; 83 84 // Ids of external outputs 85 output_ids:[uint]; 86 87 // Tables of constant data, used for constant Values (e.g. 88 // data field of weight tensors). Each constant is assigned an index into the table 89 // which are each individually aligned. 0 index is reserved to be pointed to by non-constant 90 // Tensors 91 constant_buffer:[Buffer]; 92 93 // the list index is memory buffer id, the value is the memory buffer size. 94 mem_buffer_sizes: [uint]; 95} 96 97root_type XNNGraph; 98