blob: dea588918625a7d7e66cd9b3695e211903486b22 [file] [log] [blame]
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
namespace armnnSerializer;
file_identifier "ARMN";
file_extension "armnn";
enum ActivationFunction : byte {
Sigmoid = 0,
TanH = 1,
Linear = 2,
ReLu = 3,
BoundedReLu = 4,
SoftReLu = 5,
LeakyReLu = 6,
Abs = 7,
Sqrt = 8,
Square = 9
}
enum DataType : byte {
Float16 = 0,
Float32 = 1,
QuantisedAsymm8 = 2,
Signed32 = 3,
Boolean = 4
}
enum DataLayout : byte {
NHWC = 0,
NCHW = 1
}
table TensorInfo {
dimensions:[uint];
dataType:DataType;
quantizationScale:float = 1.0;
quantizationOffset:int = 0;
}
struct Connection {
sourceLayerIndex:uint;
outputSlotIndex:uint;
}
table ByteData {
data:[byte];
}
table ShortData {
data:[short];
}
table IntData {
data:[int];
}
table LongData {
data:[long];
}
union ConstTensorData { ByteData, ShortData, IntData, LongData }
table ConstTensor {
info:TensorInfo;
data:ConstTensorData;
}
table InputSlot {
index:uint;
connection:Connection;
}
table OutputSlot {
index:uint;
tensorInfo:TensorInfo;
}
enum LayerType : uint {
Addition = 0,
Input = 1,
Multiplication = 2,
Output = 3,
Pooling2d = 4,
Reshape = 5,
Softmax = 6,
Convolution2d = 7,
DepthwiseConvolution2d = 8,
Activation = 9,
Permute = 10,
FullyConnected = 11,
Constant = 12,
SpaceToBatchNd = 13,
BatchToSpaceNd = 14,
Division = 15,
Minimum = 16,
Equal = 17,
Maximum = 18,
Normalization = 19,
Pad = 20,
Rsqrt = 21,
Floor = 22,
BatchNormalization = 23,
Greater = 24,
ResizeBilinear = 25
}
// Base layer table to be used as part of other layers
table LayerBase {
index:uint;
layerName:string;
layerType:LayerType;
inputSlots:[InputSlot];
outputSlots:[OutputSlot];
}
table BindableLayerBase {
base:LayerBase;
layerBindingId:int;
}
// Table for each layer defined below
table ActivationLayer {
base:LayerBase;
descriptor:ActivationDescriptor;
}
table ActivationDescriptor {
function:ActivationFunction = Sigmoid;
a:float;
b:float;
}
table AdditionLayer {
base:LayerBase;
}
table ConstantLayer {
base:LayerBase;
input:ConstTensor;
}
table Convolution2dLayer {
base:LayerBase;
descriptor:Convolution2dDescriptor;
weights:ConstTensor;
biases:ConstTensor;
}
table Convolution2dDescriptor {
padLeft:uint;
padRight:uint;
padTop:uint;
padBottom:uint;
strideX:uint;
strideY:uint;
biasEnabled:bool = false;
dataLayout:DataLayout = NCHW;
}
table DivisionLayer {
base:LayerBase;
}
table EqualLayer {
base:LayerBase;
}
table FloorLayer{
base:LayerBase;
}
table FullyConnectedLayer {
base:LayerBase;
descriptor:FullyConnectedDescriptor;
weights:ConstTensor;
biases:ConstTensor;
}
table FullyConnectedDescriptor {
biasEnabled:bool = false;
transposeWeightsMatrix:bool = false;
}
table GreaterLayer {
base:LayerBase;
}
table InputLayer {
base:BindableLayerBase;
}
table MinimumLayer {
base:LayerBase;
}
table MaximumLayer {
base:LayerBase;
}
table MultiplicationLayer {
base:LayerBase;
}
table Pooling2dLayer {
base:LayerBase;
descriptor:Pooling2dDescriptor;
}
enum PoolingAlgorithm : byte {
Max = 0,
Average = 1,
L2 = 2
}
enum OutputShapeRounding : byte {
Floor = 0,
Ceiling = 1
}
enum PaddingMethod : byte {
IgnoreValue = 0,
Exclude = 1
}
table Pooling2dDescriptor {
poolType:PoolingAlgorithm;
padLeft:uint;
padRight:uint;
padTop:uint;
padBottom:uint;
poolWidth:uint;
poolHeight:uint;
strideX:uint;
strideY:uint;
outputShapeRounding:OutputShapeRounding;
paddingMethod:PaddingMethod;
dataLayout:DataLayout;
}
table SoftmaxLayer {
base:LayerBase;
descriptor:SoftmaxDescriptor;
}
table SoftmaxDescriptor {
beta:float;
}
table DepthwiseConvolution2dLayer {
base:LayerBase;
descriptor:DepthwiseConvolution2dDescriptor;
weights:ConstTensor;
biases:ConstTensor;
}
table DepthwiseConvolution2dDescriptor {
padLeft:uint;
padRight:uint;
padTop:uint;
padBottom:uint;
strideX:uint;
strideY:uint;
biasEnabled:bool = false;
dataLayout:DataLayout = NCHW;
}
table OutputLayer {
base:BindableLayerBase;
}
table ReshapeLayer {
base:LayerBase;
descriptor:ReshapeDescriptor;
}
table ReshapeDescriptor {
targetShape:[uint];
}
table PermuteLayer {
base:LayerBase;
descriptor:PermuteDescriptor;
}
table PermuteDescriptor {
dimMappings:[uint];
}
table SpaceToBatchNdLayer {
base:LayerBase;
descriptor:SpaceToBatchNdDescriptor;
}
table SpaceToBatchNdDescriptor {
blockShape:[uint];
padList:[uint];
dataLayout:DataLayout;
}
table BatchToSpaceNdLayer {
base:LayerBase;
descriptor:BatchToSpaceNdDescriptor;
}
table BatchToSpaceNdDescriptor {
blockShape:[uint];
crops:[uint];
dataLayout:DataLayout;
}
enum NormalizationAlgorithmChannel : byte {
Across = 0,
Within = 1
}
enum NormalizationAlgorithmMethod : byte {
LocalBrightness = 0,
LocalContrast = 1
}
table NormalizationLayer {
base:LayerBase;
descriptor:NormalizationDescriptor;
}
table NormalizationDescriptor {
normChannelType:NormalizationAlgorithmChannel = Across;
normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
normSize:uint;
alpha:float;
beta:float;
k:float;
dataLayout:DataLayout = NCHW;
}
table PadLayer {
base:LayerBase;
descriptor:PadDescriptor;
}
table PadDescriptor {
padList:[uint];
}
table RsqrtLayer {
base:LayerBase;
}
table BatchNormalizationLayer {
base:LayerBase;
descriptor:BatchNormalizationDescriptor;
mean:ConstTensor;
variance:ConstTensor;
beta:ConstTensor;
gamma:ConstTensor;
}
table BatchNormalizationDescriptor {
eps:float;
dataLayout:DataLayout;
}
table ResizeBilinearLayer {
base:LayerBase;
descriptor:ResizeBilinearDescriptor;
}
table ResizeBilinearDescriptor {
targetWidth:uint;
targetHeight:uint;
dataLayout:DataLayout;
}
union Layer {
ActivationLayer,
AdditionLayer,
BatchToSpaceNdLayer,
BatchNormalizationLayer,
ConstantLayer,
Convolution2dLayer,
DepthwiseConvolution2dLayer,
FullyConnectedLayer,
InputLayer,
MultiplicationLayer,
OutputLayer,
PermuteLayer,
Pooling2dLayer,
ReshapeLayer,
SoftmaxLayer,
SpaceToBatchNdLayer,
DivisionLayer,
MinimumLayer,
EqualLayer,
MaximumLayer,
NormalizationLayer,
PadLayer,
RsqrtLayer,
FloorLayer,
GreaterLayer,
ResizeBilinearLayer
}
table AnyLayer {
layer:Layer;
}
// Root type for serialized data is the graph of the network
table SerializedGraph {
layers:[AnyLayer];
inputIds:[uint];
outputIds:[uint];
}
root_type SerializedGraph;