Nattapat Chaimanowong | 969eea3 | 2019-01-30 13:33:11 +0000 | [diff] [blame^] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | namespace armnn.armnnSerializer; |
| 7 | |
| 8 | file_identifier "ARMN"; |
| 9 | |
| 10 | file_extension "armnn"; |
| 11 | |
| 12 | enum DataType : byte { |
| 13 | Float16 = 0, |
| 14 | Float32 = 1, |
| 15 | QuantisedAsymm8 = 2, |
| 16 | Signed32 = 3, |
| 17 | Boolean = 4 |
| 18 | } |
| 19 | |
| 20 | table TensorInfo { |
| 21 | dimensions:[uint]; |
| 22 | dataType:DataType; |
| 23 | quantizationScale:float = 1.0; |
| 24 | quantizationOffset:int = 0; |
| 25 | } |
| 26 | |
| 27 | struct Connection { |
| 28 | sourceLayerIndex:uint; |
| 29 | outputSlotIndex:uint; |
| 30 | } |
| 31 | |
| 32 | table ByteData { |
| 33 | data:[byte]; |
| 34 | } |
| 35 | |
| 36 | table ShortData { |
| 37 | data:[short]; |
| 38 | } |
| 39 | |
| 40 | table IntData { |
| 41 | data:[int]; |
| 42 | } |
| 43 | |
| 44 | table LongData { |
| 45 | data:[long]; |
| 46 | } |
| 47 | |
| 48 | union ConstTensorData { ByteData, ShortData, IntData, LongData } |
| 49 | |
| 50 | table ConstTensor { |
| 51 | info:TensorInfo; |
| 52 | data:ConstTensorData; |
| 53 | } |
| 54 | |
| 55 | table InputSlot { |
| 56 | index:uint; |
| 57 | connection:Connection; |
| 58 | } |
| 59 | |
| 60 | table OutputSlot { |
| 61 | index:uint; |
| 62 | tensorInfo:TensorInfo; |
| 63 | } |
| 64 | |
| 65 | enum LayerType : uint { |
| 66 | Addition = 0, |
| 67 | Input = 1, |
| 68 | Output = 2 |
| 69 | } |
| 70 | |
| 71 | // Base layer table to be used as part of other layers |
| 72 | table LayerBase { |
| 73 | index:uint; |
| 74 | layerName:string; |
| 75 | layerType:LayerType; |
| 76 | inputSlots:[InputSlot]; |
| 77 | outputSlots:[OutputSlot]; |
| 78 | } |
| 79 | |
| 80 | table BindableLayerBase { |
| 81 | base:LayerBase; |
| 82 | layerBindingId:int; |
| 83 | } |
| 84 | |
| 85 | // Table for each layer defined below |
| 86 | table AdditionLayer { |
| 87 | base:LayerBase; |
| 88 | } |
| 89 | |
| 90 | table InputLayer { |
| 91 | base:BindableLayerBase; |
| 92 | } |
| 93 | |
| 94 | table OutputLayer { |
| 95 | base:BindableLayerBase; |
| 96 | } |
| 97 | |
| 98 | union Layer { |
| 99 | AdditionLayer, |
| 100 | InputLayer, |
| 101 | OutputLayer |
| 102 | } |
| 103 | |
| 104 | // Root type for serialized data is the graph of the network |
| 105 | table SerializedGraph { |
| 106 | layers:[Layer]; |
| 107 | inputIds:[int]; |
| 108 | outputIds:[int]; |
| 109 | } |
| 110 | |
| 111 | root_type SerializedGraph; |