| // |
| // 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 |
| } |
| |
| // 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 FullyConnectedLayer { |
| base:LayerBase; |
| descriptor:FullyConnectedDescriptor; |
| weights:ConstTensor; |
| biases:ConstTensor; |
| } |
| |
| table FullyConnectedDescriptor { |
| biasEnabled:bool = false; |
| transposeWeightsMatrix:bool = false; |
| } |
| |
| table InputLayer { |
| base:BindableLayerBase; |
| } |
| |
| 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; |
| } |
| |
| union Layer { |
| ActivationLayer, |
| AdditionLayer, |
| BatchToSpaceNdLayer, |
| ConstantLayer, |
| Convolution2dLayer, |
| DepthwiseConvolution2dLayer, |
| FullyConnectedLayer, |
| InputLayer, |
| MultiplicationLayer, |
| OutputLayer, |
| PermuteLayer, |
| Pooling2dLayer, |
| ReshapeLayer, |
| SoftmaxLayer, |
| SpaceToBatchNdLayer |
| } |
| |
| 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; |