/* * Copyright (c) 2023 Huawei Device Co., Ltd. * 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. */ package ohos.hdi.nnrt.v2_0; struct SharedBuffer { FileDescriptor fd; unsigned int bufferSize; unsigned int offset; unsigned int dataSize; }; enum DeviceType: int { OTHER, CPU, GPU, ACCELERATOR }; enum DeviceStatus: int { AVAILABLE, BUSY, OFFLINE, UNKNOWN }; enum PerformanceMode: int { PERFORMANCE_NONE, PERFORMANCE_LOW, PERFORMANCE_MEDIUM, PERFORMANCE_HIGH, PERFORMANCE_EXTREME }; enum Priority: int { PRIORITY_NONE, PRIORITY_LOW, PRIORITY_MEDIUM, PRIORITY_HIGH }; struct ModelConfig { boolean enableFloat16; enum PerformanceMode mode; enum Priority priority; Map extensions; }; enum Format : byte { FORMAT_NONE = -1, FORMAT_NCHW = 0, FORMAT_NHWC = 1 }; struct QuantParam { int numBits; int zeroPoint; double scale; }; enum DataType : byte { DATA_TYPE_UNKNOWN = 0, DATA_TYPE_BOOL = 30, DATA_TYPE_INT8 = 32, DATA_TYPE_INT16 = 33, DATA_TYPE_INT32 = 34, DATA_TYPE_INT64 = 35, DATA_TYPE_UINT8 = 37, DATA_TYPE_UINT16 = 38, DATA_TYPE_UINT32 = 39, DATA_TYPE_UINT64 = 40, DATA_TYPE_FLOAT16 = 42, DATA_TYPE_FLOAT32 = 43, DATA_TYPE_FLOAT64 = 44, }; struct IOTensor { String name; enum DataType dataType; int[] dimensions; enum Format format; struct SharedBuffer data; }; enum QuantType: byte { QUANT_TYPE_NONE, QUANT_TYPE_ALL, }; enum NodeType : unsigned int { NODE_TYPE_NONE = 0, NODE_TYPE_ACTIVATION = 2, NODE_TYPE_ADD_FUSION = 5, NODE_TYPE_ARGMAX_FUSION = 11, NODE_TYPE_AVGPOOL_FUSION = 17, NODE_TYPE_BATCH_TO_SPACE_ND = 22, NODE_TYPE_BIAS_ADD = 23, NODE_TYPE_CAST = 28, NODE_TYPE_CONCAT = 31, NODE_TYPE_CONV2D_FUSION = 35, NODE_TYPE_CONV2D_TRANSPOSE_FUSION = 36, NODE_TYPE_DIV_FUSION = 47, NODE_TYPE_ELTWISE = 52, NODE_TYPE_EXPAND_DIMS = 56, NODE_TYPE_FILL = 66, NODE_TYPE_FULL_CONNECTION = 67, NODE_TYPE_FUSED_BATCH_NORM = 68, NODE_TYPE_GATHER = 69, NODE_TYPE_LAYER_NORM_FUSION = 75, NODE_TYPE_LESS_EQUAL = 78, NODE_TYPE_MATMUL_FUSION = 89, NODE_TYPE_MAXIMUM = 90, NODE_TYPE_MAX_POOL_FUSION = 92, NODE_TYPE_MUL_FUSION = 99, NODE_TYPE_ONE_HOT = 105, NODE_TYPE_PAD_FUSION = 107, NODE_TYPE_POW_FUSION = 110, NODE_TYPE_PRELU_FUSION = 112, NODE_TYPE_QUANT_DTYPE_CAST = 113, NODE_TYPE_REDUCE_FUSION = 118, NODE_TYPE_RESHAPE = 119, NODE_TYPE_RESIZE = 120, NODE_TYPE_RSQRT = 126, NODE_TYPE_SCALE_FUSION = 127, NODE_TYPE_SHAPE = 130, NODE_TYPE_SLICE_FUSION = 135, NODE_TYPE_SOFTMAX = 138, NODE_TYPE_SPACE_TO_BATCH_ND = 141, NODE_TYPE_SPLIT = 145, NODE_TYPE_SQRT = 146, NODE_TYPE_SQUEEZE = 147, NODE_TYPE_SQUARED_DIFFERENCE = 149, NODE_TYPE_STACK = 150, NODE_TYPE_STRIDED_SLICE = 151, NODE_TYPE_SUB_FUSION = 152, NODE_TYPE_TILE_FUSION = 160, NODE_TYPE_TOPK_FUSION = 161, NODE_TYPE_TRANSPOSE = 162, NODE_TYPE_UNSQUEEZE = 165, }; enum ResizeMethod : byte { RESIZE_METHOD_UNKNOWN = -1, RESIZE_METHOD_LINEAR = 0, RESIZE_METHOD_NEAREST = 1, RESIZE_METHOD_CUBIC = 2 }; enum CoordinateTransformMode : byte { COORDINATE_TRANSFORM_MODE_ASYMMETRIC = 0, COORDINATE_TRANSFORM_MODE_ALIGN_CORNERS = 1, COORDINATE_TRANSFORM_MODE_HALF_PIXEL = 2 }; enum NearestMode : byte { NEAREST_MODE_NORMAL = 0, NEAREST_MODE_ROUND_HALF_DOWN = 1, NEAREST_MODE_ROUND_HALF_UP = 2, NEAREST_MODE_FLOOR = 3, NEAREST_MODE_CEIL = 4 }; enum ActivationType : byte { ACTIVATION_TYPE_NO_ACTIVATION = 0, ACTIVATION_TYPE_RELU = 1, ACTIVATION_TYPE_SIGMOID = 2, ACTIVATION_TYPE_RELU6 = 3, ACTIVATION_TYPE_ELU = 4, ACTIVATION_TYPE_LEAKY_RELU = 5, ACTIVATION_TYPE_ABS = 6, ACTIVATION_TYPE_RELU1 = 7, ACTIVATION_TYPE_SOFTSIGN = 8, ACTIVATION_TYPE_SOFTPLUS = 9, ACTIVATION_TYPE_TANH = 10, ACTIVATION_TYPE_SELU = 11, ACTIVATION_TYPE_HSWISH = 12, ACTIVATION_TYPE_HSIGMOID = 13, ACTIVATION_TYPE_THRESHOLDRELU = 14, ACTIVATION_TYPE_LINEAR = 15, ACTIVATION_TYPE_HARD_TANH = 16, ACTIVATION_TYPE_SIGN = 17, ACTIVATION_TYPE_SWISH = 18, ACTIVATION_TYPE_GELU = 19, ACTIVATION_TYPE_UNKNOWN = 20 }; enum ReduceMode : byte { REDUCE_MODE_MEAN = 0, REDUCE_MODE_MAX = 1, REDUCE_MODE_MIN = 2, REDUCE_MODE_PROD = 3, REDUCE_MODE_SUM = 4, REDUCE_MODE_SUM_SQUARE = 5, REDUCE_MODE_ASUM = 6, REDUCE_MODE_ALL = 7 }; enum EltwiseMode : byte { ELTWISE_MODE_PROD = 0, ELTWISE_MODE_SUM = 1, ELTWISE_MODE_MAXIMUM = 2, ELTWISE_MODE_UNKNOWN = 3 }; enum PadMode : byte { PAD_MODE_PAD = 0, PAD_MODE_SAME = 1, PAD_MODE_VALID = 2, }; enum RoundMode : byte { ROUND_MODE_FLOOR = 0, ROUND_MODE_CEIL = 1 }; enum PaddingMode : byte { PADDING_MODE_CONSTANT = 0, PADDING_MODE_REFLECT = 1, PADDING_MODE_SYMMETRIC = 2, PADDING_MODE_RESERVED = 3 }; enum NNRT_ReturnCode : unsigned int { NNRT_SUCCESS = 0, NNRT_FAILED = 1, NNRT_NULL_PTR = 2, NNRT_INVALID_PARAMETER = 3, NNRT_MEMORY_ERROR = 4, NNRT_OUT_OF_MEMORY = 5, NNRT_OPERATION_FORBIDDEN = 6, NNRT_INVALID_FILE = 7, NNRT_INVALID_PATH = 8, NNRT_INSUFFICIENT_BUFFER = 9, NNRT_NO_CHANGE = 10, NNRT_NOT_SUPPORT = 11, NNRT_SERVICE_ERROR = 12, NNRT_DEVICE_ERROR = 13, NNRT_DEVICE_BUSY = 14, NNRT_CANCELLED = 15, NNRT_PERMISSION_DENIED = 16, NNRT_TIME_OUT = 17, NNRT_INVALID_TENSOR = 18, NNRT_INVALID_NODE = 19, NNRT_INVALID_INPUT = 20, NNRT_INVALID_OUTPUT = 21, NNRT_INVALID_DATATYPE = 22, NNRT_INVALID_FORMAT = 23, NNRT_INVALID_TENSOR_NAME = 24, NNRT_INVALID_SHAPE = 25, NNRT_OUT_OF_DIMENTION_RANGES = 26, NNRT_INVALID_BUFFER = 27, NNRT_INVALID_BUFFER_SIZE = 28, NNRT_INVALID_PERFORMANCE_MODE = 29, NNRT_INVALID_PRIORITY = 30, NNRT_INVALID_MODEL = 31, NNRT_INVALID_MODEL_CACHE = 32, NNRT_UNSUPPORTED_OP = 33 };