diff --git a/ai/neural_network_runtime/neural_network_runtime_type.h b/ai/neural_network_runtime/neural_network_runtime_type.h index edd879626b781067d3fd566bfe6709d9694d2487..00b446a7d0596c9d85330a17550281b4969430e7 100644 --- a/ai/neural_network_runtime/neural_network_runtime_type.h +++ b/ai/neural_network_runtime/neural_network_runtime_type.h @@ -275,6 +275,23 @@ typedef enum { OH_NN_ACCELERATOR = 3, } OH_NN_DeviceType; +/** + * @brief Defines the padding mode. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + /** Padding Constant. */ + OH_NN_PADDING_CONSTANT = 0, + /** Padding Reflect */ + OH_NN_PADDING_REFLECT = 1, + /** Padding Replicate */ + OH_NN_PADDING_SYMMETRIC = 2, + /** Padding Circular */ + OH_NN_PADDING_RESERVED = 3 +} OH_NN_PaddingMode; + /** * @brief Defines tensor data types. * @@ -965,19 +982,23 @@ typedef enum { * Inputs: * * * inputX: n-dimensional tensor in [BatchSize, ...] format. - * * paddings: 2D tensor that specifies the length to pad in each dimension. The shape is [n, 2]. - * For example, paddings[i][0] indicates the number of paddings to be added preceding inputX in the ith dimension. - * paddings[i][1] indicates the number of paddings to be added following inputX in the ith dimension. + * * paddings: 2D tensor that specifies the length to pad in each dimension. The shape is [n, 2]. + * For example, paddings[i][0] indicates the number of paddings to be added preceding + * inputX in the ith dimension. + * paddings[i][1] indicates the number of paddings to be added following inputX + * in the ith dimension. * * Parameters: * - * * padValues: value to be added to the pad operation. The value is a constant with the same data type as inputX. + * * constantValues: value to be added to the pad operation. + * The value is a constant with the same data type as inputX. + * * paddingMode: Padding mode. For details, refer to OH_NN_PaddingMode. * * Outputs: * - * * output: n-dimensional tensor after padding, with the same dimensions and data type as inputX. - * The shape is determined by inputX and paddings. - * output.shape[i] = input.shape[i] + paddings[i][0]+paddings[i][1] + * * output: n-dimensional tensor after padding, with the same dimensions and data type as + * inputX. The shape is determined by inputX and paddings. + * output.shape[i] = input.shape[i] + paddings[i][0]+paddings[i][1]. */ OH_NN_OPS_PAD = 24, @@ -1568,6 +1589,158 @@ typedef enum { * * output: n-dimensional tensor, with the same data type and shape as the input tensor. */ OH_NN_OPS_GELU = 56, + + /** + * Unpacks the given dimension of a rank-R tensor into rank-(R-1) tensors. + * Unpacks tensors from input by chipping it along the axis dimension. + * For example, given a tensor of shape (A, B, C, D); + * If axis == 0, then the i'th tensor in output is the slice value[i, :, :, :],\n + * and each tensor in output will have shape (B, C, D). + * If axis == 1, then the i'th tensor in output is the slice value[:, i, :, :],\n + * and each tensor in output will have shape (A, C, D). Etc. + * This is the opposite of stack. + * + * Inputs: + * * input: n-dimensional tensor. + * + * Parameters: + * * axis: dimension along witch to pack. Default: 0. Negative values wrap around. The range is [-R, R). + * + * Outputs: + * * output: A tuple of tensors, the shape of each objects is the same. + */ + OH_NN_OPS_UNSTACK = 57, + + /** + * Obtains the absolute value of the input tensor. + * + * Inputs: + * * input: n-dimensional tensor. + * + * Outputs: + * * output: The absolute value of the input tensor. + */ + OH_NN_OPS_ABS = 58, + + /** + * Computes the Gauss error function of input element-wise. + * + * Inputs: + * * input: n-dimensional tensor. + * + * Outputs: + * * output: A tensor, has the same shape and dtype as the input. + */ + OH_NN_OPS_ERF = 59, + + /** + * Calculates the exponential of the given input tensor, element-wise. + * ExpFusion computes outputs output = base ^ (shift + scale * input), for base > 0. + * Or if base is set to the default (-1), base is set to e, + * so output = exp(shift + scale * input). + * + * Inputs: + * * input: n-dimensional tensor. + * + * Parameters: + * * base: The base of exponential function, default -1 for a value of e, must be > 0. + * * scale: The amplifcation factor of independent value, default 1. + * * shift: The offset of independent value, default 0. + * + * Outputs: + * * output: A tensor. The exponential of the input tensor computed element-wise. + */ + OH_NN_OPS_EXP = 60, + + /** + * Returns the tensor resulted from performing the less logical operation elementwise\n + * on the input tensors input1 and input2. + * + * Inputs: + * * input1: n-dimensional tensor. + * The first input is a number or a bool or a tensor whose data type is number or bool. + * * input2: n-dimensional tensor. The second input is a number or a bool + * when the first input is a tensor or a tensor whose data type is number or bool. + * + * Outputs: + * * output: A tensor, the shape is the same as the one after broadcasting, and the data type is bool. + */ + OH_NN_OPS_LESS = 61, + + /** + * Selects elements from input1 or input2, depending on condition. + * The input1 and input2 tensors must all have the same shape, + * and the output will also have that shape. + * The condition tensor must be a scalar if input1 and input2 are scalars. + * If input1 and input2 are vectors or higher rank, then condition must be either a scalar, + * a vector with size matching the first dimension of input1, or must have the same shape as input1. + * The condition tensor acts as a mask that chooses, based on the value at each element, whether the\n + * corresponding element / row in the output should be taken from input1 (if true) or input2 (if false). + * + * Inputs: + * * inputCond: n-dimensional tensor or scalar. + * The condition tensor, decides which element is chosen. + * * input1: n-dimensional tensor. a tensor which may have the same shape as condition. + * If condition is rank 1, x1 may have higher rank, but its first dimension must match the size of condition. + * * input2: n-dimensional tensor, has the same shape with input1. + * + * Outputs: + * * output: A tensor, has the same shape as the input_cond. + */ + OH_NN_OPS_SELECT = 62, + + /** + * Calculates the square of a tensor. + * + * Inputs: + * * input: n-dimensional tensor. + * + * Outputs: + * * output: A tensor, has the same shape and dtype as the input. + */ + OH_NN_OPS_SQUARE = 63, + + /** + * Flattens the input tensor into a 2D matrix. If input tensor has shape (d_0, d_1, … d_n), + * then the output will have shape (d_0 X d_1 … d_(axis-1), d_axis X d_(axis+1) … X dn). + * + * Inputs: + * * input: n-dimensional tensor. rank >= axis. + * + * Parameters: + * * axis: Indicate up to which input dimensions (exclusive) should be flattened + * to the outer dimension of the output. + * The value for axis must be in the range [-r, r], where r is the rank of the input tensor. + * Negative value means counting dimensions from the back. When axis = 0, the shape of the output tensor is\n + * (1, (d_0 X d_1 … d_n)), where the shape of the input tensor is (d_0, d_1, … d_n). + * + * Outputs: + * * output: A tensor, with the contents of the input tensor, + * with input dimensions up to axis flattened to the outer dimension of + * the output and remaining input dimensions flattened into the inner dimension of the output. + */ + OH_NN_OPS_FLATTEN = 64, + + /** + * DepthToSpace rearranges (permutes) data from depth into blocks of spatial data. + * This is the reverse transformation of SpaceToDepth. More specifically, this op outputsa copy of the input tensor + * where values from the depth dimension are moved in spatial blocks to the height and width dimensions. + * By default, mode = DCR. In the DCR mode, elements along the depth dimension from the input tensor are rearranged + * in the following order: depth, column, and then row. + * + * Inputs: + * * input: 4-dimensional tensor with specific format of NHWC or NCHW. + * where N is the batch axis, H is the height, W is the width and C is the channel or depth. + * + * Parameters: + * * blockSize: Blocks of [blocksize, blocksize] are moved. + * * mode: DCR (default) for depth-column-row order re-arrangement. Use CRD for column-row-depth order. + * + * Outputs: + * * output: Output tensor of [N, H * blocksize, W * blocksize, C/(blocksize * blocksize)] for NHWC format + * or [N, C/(blocksize * blocksize), H * blocksize, W * blocksize] for NCHW format. + */ + OH_NN_OPS_DEPTH_TO_SPACE = 65, } OH_NN_OperationType; /** @@ -1774,6 +1947,19 @@ typedef enum { /** This enumerated value is used when the tensor is used as the Axis parameter of the Unsqueeze operator. */ OH_NN_UNSQUEEZE_AXIS = 77, + + /** This enumerated value is used when the tensor is used as the axis parameter of the Unstack operator. */ + OH_NN_UNSTACK_AXIS = 78, + + /** This enumerated value is used when the tensor is used as the axis parameter of the Flatten operator. */ + OH_NN_FLATTEN_AXIS = 79, + + /** This enumerated value is used when the tensor is used as the blockSize parameter + * of the DepthToSpace operator. */ + OH_NN_DEPTH_TO_SPACE_BLOCK_SIZE = 80, + /** This enumerated value is used when the tensor is used as the mode parameter + * of the DepthToSpace operator. */ + OH_NN_DEPTH_TO_SPACE_MODE = 81, } OH_NN_TensorType; /**