| |
| // Copyright (c) 2020-2021, ARM Limited. |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| namespace tosa; |
| |
| // This corresponds to the version. |
| file_identifier "TOSA"; |
| // File extension of any written files. |
| file_extension "tosa"; |
| |
| enum DType:uint32 { |
| UNKNOWN = 0, |
| BOOL, |
| UINT8, |
| INT4, |
| INT8, |
| INT16, |
| INT32, |
| INT48, |
| FLOAT, |
| } |
| |
| enum Format:uint32 { |
| UNKNOWN = 0, |
| NHWC, |
| NDHWC, |
| OHWI, |
| HWIM, |
| DOHWI, |
| } |
| |
| enum Usage:uint32 { |
| UNKNOWN = 0, |
| ACTIVATION, |
| WEIGHT, |
| INDEX, |
| } |
| |
| enum ResizeMode:uint32 { |
| UNKNOWN = 0, |
| NEAREST, |
| BILINEAR, |
| } |
| |
| enum Op:uint32 { |
| UNKNOWN = 0, |
| |
| // Tensor Operator |
| ARGMAX, |
| AVG_POOL2D, |
| CONV2D, |
| CONV3D, |
| DEPTHWISE_CONV2D, |
| FULLY_CONNECTED, |
| MATMUL, |
| MAX_POOL2D, |
| TRANSPOSE_CONV2D, |
| |
| // Activation |
| CLAMP, |
| RELUN, |
| SIGMOID, |
| TANH, |
| |
| // Elementwise-Binary |
| ADD, |
| ARITHMETIC_RIGHT_SHIFT, |
| BITWISE_AND, |
| BITWISE_OR, |
| BITWISE_XOR, |
| LOGICAL_AND, |
| LOGICAL_LEFT_SHIFT, |
| LOGICAL_RIGHT_SHIFT, |
| LOGICAL_OR, |
| LOGICAL_XOR, |
| MAXIMUM, |
| MINIMUM, |
| MUL, |
| POW, |
| SUB, |
| TABLE, |
| |
| // Elementwise-Unary |
| ABS, |
| BITWISE_NOT, |
| CEIL, |
| CLZ, |
| EXP, |
| FLOOR, |
| LOG, |
| LOGICAL_NOT, |
| NEGATE, |
| RECIPROCAL, |
| RSQRT, |
| |
| // Elementwise-Ternary |
| SELECT, |
| |
| // Logical |
| EQUAL, |
| GREATER, |
| GREATER_EQUAL, |
| |
| // Reduction |
| REDUCE_ANY, |
| REDUCE_ALL, |
| REDUCE_MAX, |
| REDUCE_MIN, |
| REDUCE_PRODUCT, |
| REDUCE_SUM, |
| |
| // Data layout operation |
| CONCAT, |
| PAD, |
| RESHAPE, |
| REVERSE, |
| SLICE, |
| TILE, |
| TRANSPOSE, |
| |
| // Gather/scatter operation |
| GATHER, |
| SCATTER, |
| |
| // Image |
| RESIZE, |
| |
| // Type conversion |
| CAST, |
| RESCALE, |
| |
| // Data Nodes |
| CONST, |
| PLACEHOLDER, |
| IDENTITY, |
| IDENTITYN, |
| |
| // Custom operations |
| CUSTOM, |
| |
| // Control flow operators |
| COND_IF, |
| WHILE_LOOP, |
| } |
| |
| union Attribute { |
| Pool2dAttribute, |
| Conv2dAttribute, |
| TransposeConv2dAttribute, |
| ReluNAttribute, |
| AxisAttribute, |
| ReshapeAttribute, |
| SliceAttribute, |
| TileAttribute, |
| ResizeAttribute, |
| ClampAttribute, |
| RescaleAttribute, |
| MulAttribute, |
| ArithmeticRightShiftAttribute, |
| CondIfAttribute, |
| WhileLoopAttribute, |
| } |
| |
| table Pool2dAttribute { |
| padding: [int32]; |
| kernel: [int32]; |
| stride: [int32]; |
| } |
| |
| table Conv2dAttribute { |
| padding: [int32]; |
| stride: [int32]; |
| dilation: [int32]; |
| } |
| |
| table TransposeConv2dAttribute { |
| outpad: [int32]; |
| stride: [int32]; |
| dilation: [int32]; |
| output_shape: [int32]; |
| } |
| |
| table ReluNAttribute { |
| max_int: int32; |
| max_fp: float; |
| } |
| |
| table AxisAttribute { |
| axis: int32; |
| } |
| |
| table ReshapeAttribute { |
| shape: [int32]; |
| } |
| |
| table SliceAttribute { |
| begin: [int32]; |
| size: [int32]; |
| } |
| |
| table TileAttribute { |
| multiples: [int32]; |
| } |
| |
| table ResizeAttribute { |
| output_size: [int32]; |
| stride: [int32]; |
| offset: [int32]; |
| shift: int32; |
| stride_fp: [float]; |
| offset_fp: [float]; |
| mode: ResizeMode; |
| } |
| |
| table ClampAttribute { |
| min_int: int32; |
| max_int: int32; |
| min_fp: float; |
| max_fp: float; |
| } |
| |
| table RescaleAttribute { |
| input_zp: int32; |
| output_zp: int32; |
| multiplier: [int32]; |
| shift: [int32]; |
| scale32: bool; |
| double_round: bool; |
| per_channel: bool; |
| } |
| |
| table MulAttribute { |
| shift: int32; |
| } |
| |
| table ArithmeticRightShiftAttribute { |
| round: bool; |
| } |
| |
| table CondIfAttribute { |
| then_branch: string; |
| else_branch: string; |
| } |
| |
| table WhileLoopAttribute { |
| cond_branch: string; |
| body_branch: string; |
| } |
| |
| union QuantInfo { |
| UnaryQuantInfo, |
| ConvQuantInfo, |
| MatMulQuantInfo, |
| PadQuantInfo, |
| } |
| |
| table UnaryQuantInfo { |
| input_zp: int32; |
| output_zp: int32; |
| } |
| |
| table ConvQuantInfo { |
| input_zp: int32; |
| weight_zp: int32; |
| } |
| |
| table MatMulQuantInfo { |
| a_zp: int32; |
| b_zp: int32; |
| } |
| |
| table PadQuantInfo { |
| input_zp: int32; |
| } |
| |
| table Version { |
| _major: int32 = 0; |
| _minor: int32 = 21; |
| _patch: int32 = 0; |
| _experimental: bool = false; |
| } |
| |
| table TosaTensor { |
| name:string; // name of the tensor, used for solving dependency |
| shape:[int32]; // shape of the tensor |
| type:DType; // data type of the tensor |
| usage:[Usage]; // vector of possible usages. for the convenience of debugging only. |
| format:[Format]; // vector of possible formats. for the convenience of debugging only. |
| npy_filename: string; // numpy array filename |
| } |
| |
| table TosaOperator { |
| op:Op; // operator enum |
| attribute: Attribute; // union structure. operator attribute |
| inputs:[string]; // list of input tensor names |
| outputs:[string]; // list of output tensor names |
| quant_info: QuantInfo; // op-based quantization information |
| } |
| |
| table TosaBasicBlock { |
| name:string; // basic block name |
| operators:[TosaOperator]; // operators array |
| tensors:[TosaTensor]; // tensors array |
| inputs:[string]; // name of graph inputs |
| outputs:[string]; // name of graph outputs |
| } |
| |
| table TosaGraph { |
| version: Version; |
| blocks:[TosaBasicBlock]; // basic blocks array |
| } |
| |
| root_type TosaGraph; |