Eric Kunze | 2364dcd | 2021-04-26 11:06:57 -0700 | [diff] [blame] | 1 | |
| 2 | // Copyright (c) 2020-2021, ARM Limited. |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | |
| 16 | /* |
| 17 | Syntax: |
| 18 | DEF_ATTRIBUTE(ATTRIBUTE_NAME, NUM_ARGS_IN_ATTRIBUTES, ARG0_TYPE, ARG0_SCALAR_OR_VECTOR, ARGS0_NAME, ...) |
| 19 | |
| 20 | Description: |
| 21 | ATTRIBUTE_NAME: corresponding attribute name, must match corresponding "table XXXAttribute" in tosa.fbs |
| 22 | NUM_ARGS_IN_ATTRIBUTES: number of arguments in this attribute |
| 23 | ARG0_TYPE: data type of arg0 in attribute |
| 24 | ARG0_SCALAR_OR_VECTOR: is arg0 a scalar(S) or a vector(V) |
| 25 | ARG0_NAME: name of arg0 |
| 26 | ...: variadic variables for more arguments, depending on NUM_ARGS_IN_ATTRIBUTES |
| 27 | */ |
| 28 | |
James Ward | 485a11d | 2022-08-05 13:48:37 +0100 | [diff] [blame] | 29 | DEF_ATTRIBUTE(Pool, 6, |
TatWai Chong | 7be7165 | 2022-05-10 17:26:20 -0700 | [diff] [blame] | 30 | int32_t, V, pad, |
Eric Kunze | 2364dcd | 2021-04-26 11:06:57 -0700 | [diff] [blame] | 31 | int32_t, V, kernel, |
Eric Kunze | bdcc3fe | 2022-06-07 05:17:37 +0000 | [diff] [blame] | 32 | int32_t, V, stride, |
| 33 | int32_t, S, input_zp, |
James Ward | 485a11d | 2022-08-05 13:48:37 +0100 | [diff] [blame] | 34 | int32_t, S, output_zp, |
| 35 | DType, S, accum_dtype) |
Eric Kunze | 2364dcd | 2021-04-26 11:06:57 -0700 | [diff] [blame] | 36 | |
James Ward | 485a11d | 2022-08-05 13:48:37 +0100 | [diff] [blame] | 37 | DEF_ATTRIBUTE(Conv, 6, |
TatWai Chong | 7be7165 | 2022-05-10 17:26:20 -0700 | [diff] [blame] | 38 | int32_t, V, pad, |
Eric Kunze | 2364dcd | 2021-04-26 11:06:57 -0700 | [diff] [blame] | 39 | int32_t, V, stride, |
Eric Kunze | bdcc3fe | 2022-06-07 05:17:37 +0000 | [diff] [blame] | 40 | int32_t, V, dilation, |
| 41 | int32_t, S, input_zp, |
James Ward | 485a11d | 2022-08-05 13:48:37 +0100 | [diff] [blame] | 42 | int32_t, S, weight_zp, |
| 43 | DType, S, accum_dtype) |
Eric Kunze | 2364dcd | 2021-04-26 11:06:57 -0700 | [diff] [blame] | 44 | |
James Ward | 485a11d | 2022-08-05 13:48:37 +0100 | [diff] [blame] | 45 | DEF_ATTRIBUTE(TransposeConv, 6, |
Eric Kunze | 7ffa1ff | 2022-06-01 17:26:48 -0700 | [diff] [blame] | 46 | int32_t, V, out_pad, |
Eric Kunze | 2364dcd | 2021-04-26 11:06:57 -0700 | [diff] [blame] | 47 | int32_t, V, stride, |
Eric Kunze | bdcc3fe | 2022-06-07 05:17:37 +0000 | [diff] [blame] | 48 | int32_t, V, output_shape, |
| 49 | int32_t, S, input_zp, |
James Ward | 485a11d | 2022-08-05 13:48:37 +0100 | [diff] [blame] | 50 | int32_t, S, weight_zp, |
| 51 | DType, S, accum_dtype) |
Eric Kunze | 2364dcd | 2021-04-26 11:06:57 -0700 | [diff] [blame] | 52 | |
Kevin Cheng | 38d214c | 2021-10-15 15:49:19 -0700 | [diff] [blame] | 53 | DEF_ATTRIBUTE(Pad, 3, |
| 54 | int32_t, V, padding, |
| 55 | int32_t, S, pad_const_int, |
| 56 | float, S, pad_const_fp) |
Eric Kunze | 2364dcd | 2021-04-26 11:06:57 -0700 | [diff] [blame] | 57 | |
| 58 | DEF_ATTRIBUTE(Axis, 1, |
| 59 | int32_t, S, axis) |
| 60 | |
| 61 | DEF_ATTRIBUTE(Reshape, 1, |
TatWai Chong | 7be7165 | 2022-05-10 17:26:20 -0700 | [diff] [blame] | 62 | int32_t, V, new_shape) |
Eric Kunze | 2364dcd | 2021-04-26 11:06:57 -0700 | [diff] [blame] | 63 | |
| 64 | DEF_ATTRIBUTE(Slice, 2, |
TatWai Chong | 7be7165 | 2022-05-10 17:26:20 -0700 | [diff] [blame] | 65 | int32_t, V, start, |
Eric Kunze | 2364dcd | 2021-04-26 11:06:57 -0700 | [diff] [blame] | 66 | int32_t, V, size) |
| 67 | |
| 68 | DEF_ATTRIBUTE(Tile, 1, |
| 69 | int32_t, V, multiples) |
| 70 | |
TatWai Chong | 49b1ca6 | 2022-06-10 01:49:13 -0700 | [diff] [blame] | 71 | DEF_ATTRIBUTE(Resize, 4, |
| 72 | int16_t, V, scale, |
| 73 | int16_t, V, offset, |
| 74 | int16_t, V, border, |
Eric Kunze | 2364dcd | 2021-04-26 11:06:57 -0700 | [diff] [blame] | 75 | ResizeMode, S, mode) |
| 76 | |
| 77 | DEF_ATTRIBUTE(Clamp, 4, |
| 78 | int32_t, S, min_int, |
| 79 | int32_t, S, max_int, |
| 80 | float, S, min_fp, |
| 81 | float, S, max_fp) |
| 82 | |
| 83 | DEF_ATTRIBUTE(Rescale, 7, |
| 84 | int32_t, S, input_zp, |
| 85 | int32_t, S, output_zp, |
| 86 | int32_t, V, multiplier, |
| 87 | int32_t, V, shift, |
| 88 | bool, S, scale32, |
| 89 | bool, S, double_round, |
| 90 | bool, S, per_channel) |
| 91 | |
| 92 | DEF_ATTRIBUTE(Mul, 1, |
| 93 | int32_t, S, shift) |
| 94 | |
| 95 | DEF_ATTRIBUTE(ArithmeticRightShift, 1, |
| 96 | bool, S, round) |
| 97 | |
| 98 | DEF_ATTRIBUTE(CondIf, 2, |
| 99 | string, S, then_branch, |
| 100 | string, S, else_branch) |
| 101 | |
| 102 | DEF_ATTRIBUTE(WhileLoop, 2, |
| 103 | string, S, cond_branch, |
| 104 | string, S, body_branch) |
Kevin Cheng | 38d214c | 2021-10-15 15:49:19 -0700 | [diff] [blame] | 105 | |
| 106 | DEF_ATTRIBUTE(Transpose, 1, |
TatWai Chong | 7be7165 | 2022-05-10 17:26:20 -0700 | [diff] [blame] | 107 | int32_t, V, perms) |
Kevin Cheng | 38d214c | 2021-10-15 15:49:19 -0700 | [diff] [blame] | 108 | |
| 109 | DEF_ATTRIBUTE(Table, 1, |
TatWai Chong | 7be7165 | 2022-05-10 17:26:20 -0700 | [diff] [blame] | 110 | int16_t, V, table) |
Kevin Cheng | 38d214c | 2021-10-15 15:49:19 -0700 | [diff] [blame] | 111 | |
James Ward | 485a11d | 2022-08-05 13:48:37 +0100 | [diff] [blame] | 112 | DEF_ATTRIBUTE(MatMul, 3, |
Eric Kunze | bdcc3fe | 2022-06-07 05:17:37 +0000 | [diff] [blame] | 113 | int32_t, S, a_zp, |
James Ward | 485a11d | 2022-08-05 13:48:37 +0100 | [diff] [blame] | 114 | int32_t, S, b_zp, |
| 115 | DType, S, accum_dtype) |
Eric Kunze | bdcc3fe | 2022-06-07 05:17:37 +0000 | [diff] [blame] | 116 | |
James Ward | 485a11d | 2022-08-05 13:48:37 +0100 | [diff] [blame] | 117 | DEF_ATTRIBUTE(FullyConnected, 3, |
Eric Kunze | bdcc3fe | 2022-06-07 05:17:37 +0000 | [diff] [blame] | 118 | int32_t, S, input_zp, |
James Ward | 485a11d | 2022-08-05 13:48:37 +0100 | [diff] [blame] | 119 | int32_t, S, weight_zp, |
| 120 | DType, S, accum_dtype) |
Eric Kunze | bdcc3fe | 2022-06-07 05:17:37 +0000 | [diff] [blame] | 121 | |
| 122 | DEF_ATTRIBUTE(Negate, 2, |
| 123 | int32_t, S, input1_zp, |
| 124 | int32_t, S, output_zp) |