• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16package ohos.hdi.nnrt.v1_0;
17
18struct SharedBuffer {
19    FileDescriptor fd;
20    unsigned int bufferSize;
21    unsigned int offset;
22    unsigned int dataSize;
23};
24
25enum DeviceType: int {
26    OTHER,
27    CPU,
28    GPU,
29    ACCELERATOR
30};
31
32enum DeviceStatus: int {
33    AVAILABLE,
34    BUSY,
35    OFFLINE,
36    UNKNOWN
37};
38
39enum PerformanceMode: int {
40    PERFORMANCE_NONE,
41    PERFORMANCE_LOW,
42    PERFORMANCE_MEDIUM,
43    PERFORMANCE_HIGH,
44    PERFORMANCE_EXTREME
45};
46
47enum Priority: int {
48    PRIORITY_NONE,
49    PRIORITY_LOW,
50    PRIORITY_MEDIUM,
51    PRIORITY_HIGH
52};
53
54struct ModelConfig {
55    boolean enableFloat16;
56    enum PerformanceMode mode;
57    enum Priority priority;
58};
59
60enum Format : byte {
61    FORMAT_NONE = -1,
62    FORMAT_NCHW = 0,
63    FORMAT_NHWC = 1
64};
65
66struct QuantParam {
67    int numBits;
68    int zeroPoint;
69    double scale;
70};
71
72enum DataType : byte {
73    DATA_TYPE_UNKNOWN = 0,
74    DATA_TYPE_BOOL = 30,
75    DATA_TYPE_INT8 = 32,
76    DATA_TYPE_INT16 = 33,
77    DATA_TYPE_INT32 = 34,
78    DATA_TYPE_INT64 = 35,
79    DATA_TYPE_UINT8 = 37,
80    DATA_TYPE_UINT16 = 38,
81    DATA_TYPE_UINT32 = 39,
82    DATA_TYPE_UINT64 = 40,
83    DATA_TYPE_FLOAT16 = 42,
84    DATA_TYPE_FLOAT32 = 43,
85    DATA_TYPE_FLOAT64 = 44,
86};
87
88struct IOTensor {
89    String name;
90    enum DataType dataType;
91    int[] dimensions;
92    enum Format format;
93    struct SharedBuffer data;
94};
95
96enum QuantType: byte {
97    QUANT_TYPE_NONE,
98    QUANT_TYPE_ALL,
99};
100
101enum NodeType : unsigned int {
102    NODE_TYPE_NONE = 0,
103    NODE_TYPE_ACTIVATION = 2,
104    NODE_TYPE_ADD_FUSION = 5,
105    NODE_TYPE_ARGMAX_FUSION = 11,
106    NODE_TYPE_AVGPOOL_FUSION = 17,
107    NODE_TYPE_BATCH_TO_SPACE_ND = 22,
108    NODE_TYPE_BIAS_ADD = 23,
109    NODE_TYPE_CAST = 28,
110    NODE_TYPE_CONCAT = 31,
111    NODE_TYPE_CONV2D_FUSION = 35,
112    NODE_TYPE_CONV2D_TRANSPOSE_FUSION = 36,
113    NODE_TYPE_DIV_FUSION = 47,
114    NODE_TYPE_ELTWISE = 52,
115    NODE_TYPE_EXPAND_DIMS = 56,
116    NODE_TYPE_FILL = 66,
117    NODE_TYPE_FULL_CONNECTION = 67,
118    NODE_TYPE_FUSED_BATCH_NORM = 68,
119    NODE_TYPE_GATHER = 69,
120    NODE_TYPE_LAYER_NORM_FUSION = 75,
121    NODE_TYPE_LESS_EQUAL = 78,
122    NODE_TYPE_MATMUL_FUSION = 89,
123    NODE_TYPE_MAXIMUM = 90,
124    NODE_TYPE_MAX_POOL_FUSION = 92,
125    NODE_TYPE_MUL_FUSION = 99,
126    NODE_TYPE_ONE_HOT = 105,
127    NODE_TYPE_PAD_FUSION = 107,
128    NODE_TYPE_POW_FUSION = 110,
129    NODE_TYPE_PRELU_FUSION = 112,
130    NODE_TYPE_QUANT_DTYPE_CAST = 113,
131    NODE_TYPE_REDUCE_FUSION = 118,
132    NODE_TYPE_RESHAPE = 119,
133    NODE_TYPE_RESIZE = 120,
134    NODE_TYPE_RSQRT = 126,
135    NODE_TYPE_SCALE_FUSION = 127,
136    NODE_TYPE_SHAPE = 130,
137    NODE_TYPE_SLICE_FUSION = 135,
138    NODE_TYPE_SOFTMAX = 138,
139    NODE_TYPE_SPACE_TO_BATCH_ND = 141,
140    NODE_TYPE_SPLIT = 145,
141    NODE_TYPE_SQRT = 146,
142    NODE_TYPE_SQUEEZE = 147,
143    NODE_TYPE_SQUARED_DIFFERENCE = 149,
144    NODE_TYPE_STACK = 150,
145    NODE_TYPE_STRIDED_SLICE = 151,
146    NODE_TYPE_SUB_FUSION = 152,
147    NODE_TYPE_TILE_FUSION = 160,
148    NODE_TYPE_TOPK_FUSION = 161,
149    NODE_TYPE_TRANSPOSE = 162,
150    NODE_TYPE_UNSQUEEZE = 165,
151};
152
153enum ResizeMethod : byte {
154    RESIZE_METHOD_UNKNOWN = -1,
155    RESIZE_METHOD_LINEAR = 0,
156    RESIZE_METHOD_NEAREST = 1,
157    RESIZE_METHOD_CUBIC = 2
158};
159
160enum CoordinateTransformMode : byte {
161    COORDINATE_TRANSFORM_MODE_ASYMMETRIC = 0,
162    COORDINATE_TRANSFORM_MODE_ALIGN_CORNERS = 1,
163    COORDINATE_TRANSFORM_MODE_HALF_PIXEL = 2
164};
165
166enum NearestMode : byte {
167    NEAREST_MODE_NORMAL = 0,
168    NEAREST_MODE_ROUND_HALF_DOWN = 1,
169    NEAREST_MODE_ROUND_HALF_UP = 2,
170    NEAREST_MODE_FLOOR = 3,
171    NEAREST_MODE_CEIL = 4
172};
173
174enum ActivationType : byte {
175    ACTIVATION_TYPE_NO_ACTIVATION = 0,
176    ACTIVATION_TYPE_RELU = 1,
177    ACTIVATION_TYPE_SIGMOID = 2,
178    ACTIVATION_TYPE_RELU6 = 3,
179    ACTIVATION_TYPE_ELU = 4,
180    ACTIVATION_TYPE_LEAKY_RELU = 5,
181    ACTIVATION_TYPE_ABS = 6,
182    ACTIVATION_TYPE_RELU1 = 7,
183    ACTIVATION_TYPE_SOFTSIGN = 8,
184    ACTIVATION_TYPE_SOFTPLUS = 9,
185    ACTIVATION_TYPE_TANH = 10,
186    ACTIVATION_TYPE_SELU = 11,
187    ACTIVATION_TYPE_HSWISH = 12,
188    ACTIVATION_TYPE_HSIGMOID = 13,
189    ACTIVATION_TYPE_THRESHOLDRELU = 14,
190    ACTIVATION_TYPE_LINEAR = 15,
191    ACTIVATION_TYPE_HARD_TANH = 16,
192    ACTIVATION_TYPE_SIGN = 17,
193    ACTIVATION_TYPE_SWISH = 18,
194    ACTIVATION_TYPE_GELU = 19,
195    ACTIVATION_TYPE_UNKNOWN = 20
196};
197
198enum ReduceMode : byte {
199    REDUCE_MODE_MEAN = 0,
200    REDUCE_MODE_MAX = 1,
201    REDUCE_MODE_MIN = 2,
202    REDUCE_MODE_PROD = 3,
203    REDUCE_MODE_SUM = 4,
204    REDUCE_MODE_SUM_SQUARE = 5,
205    REDUCE_MODE_ASUM = 6,
206    REDUCE_MODE_ALL = 7
207};
208
209enum EltwiseMode : byte {
210    ELTWISE_MODE_PROD = 0,
211    ELTWISE_MODE_SUM = 1,
212    ELTWISE_MODE_MAXIMUM = 2,
213    ELTWISE_MODE_UNKNOWN = 3
214};
215
216enum PadMode : byte {
217    PAD_MODE_PAD = 0,
218    PAD_MODE_SAME = 1,
219    PAD_MODE_VALID = 2,
220};
221
222enum RoundMode : byte {
223    ROUND_MODE_FLOOR = 0,
224    ROUND_MODE_CEIL = 1
225};
226
227enum PaddingMode : byte {
228    PADDING_MODE_CONSTANT = 0,
229    PADDING_MODE_REFLECT = 1,
230    PADDING_MODE_SYMMETRIC = 2,
231    PADDING_MODE_RESERVED = 3
232};