/*
* Copyright (c) 2024 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.
*/
/**
* @addtogroup NNRt
* @{
*
* @brief Provides a unified interface for AI chip drivers to access OpenHarmony.
* Neural Network Runtime (NNRt) is a cross-chip inference computing runtime environment oriented to the AI field.
*
* @since 3.2
* @version 2.1
*/
/**
* @file NodeAttrTypes.idl
*
* @brief Defines the parameters and functionality of AI model operators.
*
* All structures in this file declare only operator attributes and do not contain the interfaces for executing\n
* operator functions.
* - 1. The operators in the file are in one-to-one correspondence with a {@link NodeType}. In model inference,\n
* {@link NodeType} is stored in nodeType of {@link Node}.
* - 2. Each operator has at least one input and one output. The input is the tensor received by the operator,\n
* and the output is the tensor produced after the operator operation. The relationship between the input, operator,\n
* and output is determined by inputIndex and outIndex of the {@link Node} structure.
*
* @since 3.2
* @version 2.1
*/
/**
* @brief Defines the package path of the NNRt module.
*
* @since 3.2
* @version 2.1
*/
package ohos.hdi.nnrt.v2_1;
import ohos.hdi.nnrt.v2_1.NnrtTypes;
/**
* @brief Obtains the absolute value of the input tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_ABS.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * The absolute value of the input tensor.
*
* @since 5.0
* @version 2.1
*/
struct Abs
{
};
/**
* @brief Defines the operator of the activation type. All activation functions belong to this operator.\n
* The specific activation function type is determined by the parameters.
*
* The {@link NodeType} of this operator is NODE_TYPE_ACTIVATION.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * A tensor returned after the activation function is executed.
*
* @since 3.2
* @version 2.1
*/
struct Activation
{
/** Activation function type. */
enum ActivationType activationType;
/** Size factor, used for the LeakyReLU and ELU activation functions. */
float alpha;
/** Minimum value, used for the HardTanh activation function. */
float minVal;
/** Maximum value, used for the HardTanh activation function. */
float maxVal;
/** Whether to use the approximation algorithm. It is used for the GRLU activation function. */
boolean approximate;
};
/**
* @brief Adds tensors. The output shape is the same as the input one after broadcasting, and the data type\n
* is the one with higher precision of the two inputs.
*
* The {@link NodeType} of this operator is NODE_TYPE_ADD_FUSION.
*
* Input:
*
* * x, the first input tensor.
* * y, the second input tensor. The data type must be the same as that of the first tensor.
*
* * Output:
*
* * Sum of the elements of x and y. The data shape is the same as the one after broadcasting,\n
* and the data type is the one with higher precision of the two inputs.
* If activationType is configured, the specified activation function will be called before
* the output is returned.
*
* @since 3.2
* @version 2.1
*/
struct AddFusion
{
/** Activation function type. For details, see {@link ActivationType}. */
enum ActivationType activationType;
};
/**
* @brief Determine whether all emements in a given tensor are non-zero. It returns a boolean tensor\n
* where each element is 'True' if corresponding element in the input tensor is non-zero, and 'False' otherwise.
*
* The {@link NodeType} of this operator is NODE_TYPE_ALL.
*
* Input:
*
* * x, a N-dimension tensor of shape (N,*), where * indicates any number of additional dimensions.
* * axis, scalar or tensor, indices the dimension to be computed.
*
* Output:
*
* * 1-dimension or n-dimension tensor with boolean data type.
*
* @since 5.0
* @version 2.1
*/
struct All
{
/** Whether to keep dimension info. */
long keepDims;
};
/**
* @brief Obtains the first K indices or values of a cross-axis tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_ARGMAX_FUSION.
*
* Input:
*
* * x, a tensor of shape (N,*), where * indicates any number of additional dimensions.
*
* Output:
*
* * First K indices or values before the maximum input tensor on the axis.
*
* @since 3.2
* @version 2.1
*/
struct ArgMaxFusion
{
/** Target axis where the maximum indices or values are obtained. */
long axis;
/** First K maximum values on the axis. */
long topK;
/** Whether to keep the output dimensions the same as the input dimensions. */
boolean keepDims;
/** Return the index if the value is false. Return the value if the value is true.\n
* The default value is false.
*/
boolean outMaxValue;
};
/**
* @brief Asserts that the given condition si true.
* If condition evalutes to false, print the list of tensors in data.
* Summerize determines how many entries of the tensors to print.
*
* The {@link NodeType} of this operator is NODE_TYPE_ASSERT.
*
* Input:
*
* * condition, the condition to evalute.
* * data, the tensors to print out when condition is false.
*
* Output:
*
* * Result value judged by condition. If the condition is not true, an Error is returned.
*
* @since 5.0
* @version 2.1
*/
struct Assert
{
/** The number of entries for each tensor is printed. */
long summarize;
};
/**
* @brief Applies a 2D average pooling on the input tensor. The int8 quantization input is supported.
*
* The {@link NodeType} of this operator is NODE_TYPE_AVGPOOL_FUSION.
*
* When padMode==PAD_MODE_PAD, padList must be greater than or equal to 0.\n
* In other cases, padding must be 0.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Tensor after average pooling.
*
* @since 3.2
* @version 2.1
*/
struct AvgPoolFusion
{
/**
* Kernel size used to obtain the average value. It is an int array in the format of [kernel_height, kernel_weight]\n
* with length of 2.
* The first number indicates the kernel height, and the second number indicates the kernel width.
*/
long[] kernelSize;
/**
* Distance of kernel moving. The value is an int array [stride_height, stride_weight] with length of 2.\n
* The first number indicates the moving size in height, and the second number indicates the moving size in width.
*/
long[] strides;
/**
* x is padded with an int array [top, bottom, left, right] with length of 4, and the nearest neighbor values\n
* are used for padding.
*/
long[] pad;
/** Padding method. */
enum PadMode padMode;
/** Numerical operation mode of the output tensor. */
enum RoundMode roundMode;
/** Format of the data during calculation. For details, see {@link Format}. */
enum Format format;
/** Whether to do global pooling. */
boolean global;
/** Activation function type. For details, see {@link ActivationType}. */
enum ActivationType activationType;
};
/**
* @brief Divides the batch dimension of a 4D tensor into small blocks by blockShape, and interleaves these blocks\n
* back into the spatial dimension.
*
* The {@link NodeType} of this operator is NODE_TYPE_BATCH_TO_SPACE_ND.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Output tensor. Assume that the shape of x is (n,h,w,c) and the shape of output is (n',h',w',c'):
* \f$ n' = n / (blockShape[0] * blockShape[1])\f$
* \f$ h' = h * blockShape[0] - crops[0][0] - crops[0][1] \f$
* \f$ w' = w * blockShape[1] - crops[1][0] - crops[1][1] \f$
* \f$ c'= c \f$
*
* @since 3.2
* @version 2.1
*/
struct BatchToSpaceND
{
/** Block size, which is an array [height_block, weight_block] with length of 2. */
long[] blockShape;
/**
* Crop values for the spatial dimension.
* It is a 2D array [crop0_start, crop0_end], [crop1_start, crop1_end] with the shape of (2, 2).
*/
long[][] crops;
};
/**
* @brief Offsets the data in each dimension of the input tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_BIAS_ADD.
*
* Input:
*
* * x, an n-dimensional tensor.
* * bias, the bias tensor.
*
* Output:
*
* * Output tensor, which is the sum of the input tensor and the bias in each dimension.
*
* @since 3.2
* @version 2.1
*/
struct BiasAdd
{
};
/**
* @brief Broadcast a tensor for a compatiable shape.
*
* The {@link NodeType} of this operator is NODE_TYPE_BROADCAST_TO.
*
* Input:
*
* * x, an n-dimensional tensor to broadcast.
*
* Output:
*
* * Output tensor after broadcasted.
*
* @since 5.0
* @version 2.1
*/
struct BroadcastTo
{
/** An 1-dimensional Tensor, the shape of the desired output. */
long[] shape;
};
/**
* @brief Converts the tensor data type.
*
* The {@link NodeType} of this operator is NODE_TYPE_CAST.
*
* Input:
*
* * x, an n-dimensional tensor.
* * type, the target type of the data.
*
* Output:
*
* * A tensor with the specified data type.
*
* @since 3.2
* @version 2.1
*/
struct Cast
{
};
/**
* @brief Returns element-wise smallest integer in not less than x.
*
* The {@link NodeType} of this operator is NODE_TYPE_CEIL.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Output tensor after ceiled.
*
* @since 5.0
* @version 2.1
*/
struct Ceil
{
};
/**
* @brief Returns a tensor of the same type and shape as input tensor with its value clipped to min and max.
* Any values less than min are set to min. Any values greater than max are set to max.
*
* The {@link NodeType} of this operator is NODE_TYPE_CLIP.
*
* Input:
*
* * x, an n-dimensional tensor to clip.
*
* Output:
*
* * Output tensor after clipped.
*
* @since 5.0
* @version 2.1
*/
struct Clip
{
/** Maximum value, above which element is replaced by max. It must be a scalar(tensor of empty shape). */
float max;
/** Minimum value, under which element is replaced by min. It must be a scalar(tensor of empty shape). */
float min;
};
/**
* @brief Connects tensors in the specified axis or connects input tensors along with the given axis.
*
* The {@link NodeType} of this operator is NODE_TYPE_CONCAT.
*
* Input:
*
* * Tensors with the same dimension.
*
* Output:
*
* * Result of the tensors connected.
*
* @since 3.2
* @version 2.1
*/
struct Concat
{
/** Axis specified. The value must be less than the number of dimensions of the input tensor. */
long axis;
};
/**
* @brief Calculates the 2D convolution on a 4D tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_CONV2D_FUSION.
*
* When padMode==PAD_MODE_PAD, padList must be greater than or equal to 0.
* In other cases, padding must be 0.
*
* Input:
*
* * x, a 4D tensor in NHWC format.
* * weight, a convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format.
* The value of inChannel divided by groupmust be an integer.
* * bias: bias of the convolution. It is an array with a length of [outChannel].\n
* In the quantization scenario, bias does not need to be quantized.
* If quantization is required, the input data must be of the int32 type.
* The actual quantization parameter is determined by x and weight.
*
* Output:
*
* * Convolution output.
*
* @since 3.2
* @version 2.1
*/
struct Conv2DFusion
{
/** Size (height and width) of the convolution kernel. */
long[] kernelSize;
/**
* Movement stride of the convolution kernel in height and weight.\n
* It is an int array [strideHeight, strideWidth] with length of 2.
*/
long[] stride;
/**
* Dilation size of the convolution kernel in height and weight. It is an int array in the format of\n
* [dilationHeight, dilationWidth].
* The value must be greater than or equal to 1 and cannot exceed the height and width of x.
*/
long[] dilation;
/** Padding mode. For details, see {@link PadMode}. */
enum PadMode padMode;
/**
* Padding around x in the height and width directions. It is an int array [top, bottom, left, right]\n
* with length of 4.
*/
long[] padList;
/**
* Splits x into groups by inChannel. The group value is of the int type.
* If group is 1, it is a conventional convolution.
* If group is inChannel, it is depthwiseConv2d. In this case, group==inChannel==outChannel.
* If group is greater than 1 and less than inChannel, it is group convolution.\n
* In this case, outChannel==group.
*/
long group;
/** Number of input channels. */
long inChannel;
/** Number of output channels. */
long outChannel;
/** Activation function type. For details, see {@link ActivationType}. */
enum ActivationType activationType;
};
/**
* @brief Calculates a 2D transposed convolution on a 4D tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_CONV2D_TRANSPOSE_FUSION.
*
* When padMode==PAD_MODE_PAD, padList must be greater than or equal to 0.\n
* In other cases, padding must be 0.
*
* Input:
*
* * x, a 4D tensor in NHWC format.
* * weight, a convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format.
* The value of inChannel divided by groupmust be an integer.
* * bias: bias of the convolution. It is an array with a length of [outChannel].\n
* In the quantization scenario, bias does not need to be quantized.
* If quantization is required, the input data must be of the int32 type.
* The actual quantization parameter is determined by x and weight.
*
* Output:
*
* * An n-dimensional tensor.
*
* @since 3.2
* @version 2.1
*/
struct Conv2dTransposeFusion
{
/** Size (height and width) of the convolution kernel. */
long[] kernelSize;
/** Movement stride of the convolution kernel in height and weight. It is an int array [strideHeight, strideWidth]\n
* with length of 2.
*/
long[] stride;
/** Dilation size of the convolution kernel in height and weight. It is an int array [dilationHeight, dilationWidth]\n
* with length of 2.
* The value must be greater than or equal to 1 and cannot exceed the height and width of x.
*/
long[] dilation;
/** Padding mode. For details, see {@link PadMode}. */
enum PadMode padMode;
/** Padding around the input x in the height and width directions. It is an int array [top, bottom, left, right]\n
* with length of 4. */
long[] padList;
/**
* Splits x into groups by inChannel.
* If group is 1, it is a conventional convolution.
* If group is greater than 1 and less than or equal to inChannel, this is a group convolution.
*/
long group;
/** Number of input channels. */
long inChannel;
/** Number of output channels. */
long outChannel;
/** Activation function type. For details, see {@link ActivationType}. */
enum ActivationType activationType;
/**
* A list of integer array with two elements, specifying the paddings along the height and width of the output tensor.
*/
long[] outputPaddings;
};
/**
* @brief Calculates the cosine of the given input tensor, element-wise.
*
* The {@link NodeType} of this operator is NODE_TYPE_COS.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * The cosine of the input tensor computed element-wise.
*
* @since 5.0
* @version 2.1
*/
struct Cos
{
};
/**
* @brief Generate a tensor with given value and shape.
*
* The {@link NodeType} of this operator is NODE_TYPE_CONSTANT_OF_SHAPE.
*
* Input:
*
* * x, an 1-dimensional tensor, indicates the shape of the expected output tensor.
* * If empty tensor is given, the output would be a scalar. All values must be >= 0.
*
* Output:
*
* * Output tensor of shape specified by x.
*
* @since 5.0
* @version 2.1
*/
struct ConstantOfShape
{
/** The data type of output elements. */
long dataType;
/** The value of the output elements. Should be a one-element tensor. */
float[] value;
};
/**
* @brief Crop given tensor acrodding to axis and offset.
*
* The {@link NodeType} of this operator is NODE_TYPE_CROP.
*
* Input:
*
* * x, an n-dimensional tensor.
* * shape, an 1-dimensional tensor, indices cropped windows dimension.
*
* Output:
*
* * Cropped output tensor.
*
* @since 5.0
* @version 2.1
*/
struct Crop
{
/** Cropped dimension. */
long axis;
/** Cropped offset per dimension. */
long[] offset;
};
/**
* @brief The output of the object detection model is post-processed, including decoding the bounding box,
* class probability and score of the model output, and then performing non-maximum suppression (NMS) to remove
* the overlapping bounding box, and finally outputting the detection result.
*
* The {@link NodeType} of this operator is NODE_TYPE_DETECTION_POST_PROCESS.
*
* Input:
*
* * bbox, bounding box for model output.
* * scores, probability of class score for model output.
* * anchors, The coordinates and size information of the candidate boxes used to generate the detection box.
*
* Output:
*
* * bboxes, 3-dimensional tensor with an inner array representing the coordinate values of the object
* * detection box.
* * classes,2-dimensional tensor with an internal numeric value representing the classification index
* * corresponding to each detection box.
* * confidences, 2-dimensional tensor with an internal numerical value indicating the confidence level
* * of the detected object.
* * numDetections, 1-dimensional tensor, the number of test results.
*
* @since 5.0
* @version 2.1
*/
struct DetectionPostProcess
{
/** Format of input tensor, default NCHW. */
enum Format format;
/** The size of the input tensor. */
long inputSize;
/** The scaling factor used to convert the output from the normalized form to the original image coordinates. */
float[] scale;
/** The threshold of overlapping region during NMS. */
float nmsIoUThreshold;
/** The socre threshold used to select target bbox duing NMS. */
float nmsScoreThreshold;
/** Maximum of bboxes per image. */
long maxDetections;
/** Maximum of bboxes per class. */
long detectionsPerClass;
/** Maximum of reserved classes per bboxes. */
long maxClassesPerDetection;
/** Number of target classes to be detected. */
long numClasses;
/** Whether use NMS based on IoU threshold. */
boolean useRegularNms;
/** Whether need to quantize. */
boolean outQuantized;
};
/**
* @brief 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\n
* 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\n
* in the following order: depth, column, and then row.
*
* The {@link NodeType} of this operator is NODE_TYPE_DEPTH_TO_SPACE.
*
* Input:
*
* * x, input tensor of 4-dimensional, 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.
*
* Output:
*
* * Output tensor of [N, H * blockSize, W * blockSize, C/(blockSize * blockSize)] for NHWC format\n
* or [N, C/(blockSize * blockSize), H * blockSize, W * blockSize] for NCHW format.
*
* @since 5.0
* @version 2.1
*/
struct DepthToSpace
{
/** Blocks of [blockSize, blockSize] are moved. */
long blockSize;
/** Format of input tensor, default NCHW. */
enum Format format;
/** DCR (default) for depth-column-row order re-arrangement. Use CRD for column-row-depth order. */
String mode;
};
/**
* @brief Divides the first tensor by the second tensor element-wise.
*
* The {@link NodeType} of this operator is NODE_TYPE_DIV_FUSION.
*
* Input:
*
* * x1, a tensor of the int or float type.
* * x2, a tensor of the int or float type.
*
* Output:
*
* * Quotient of the two inputs.
*
* @since 3.2
* @version 2.1
*/
struct DivFusion
{
/** Activation function type. For details, see {@link ActivationType}. */
enum ActivationType activationType;
};
/**
* @brief Performs an element-wise operation.
*
* The {@link NodeType} of this operator is NODE_TYPE_ELTWISE.
*
* Input:
*
* * x1, the first input tensor.
* * x2, the second input tensor.
*
* Output:
*
* * A tensor with the same data type and shape as x1.
*
* @since 3.2
* @version 2.1
*/
struct Eltwise
{
/** Element-wise operation type. For details, see {@link EltwiseMode}. */
enum EltwiseMode mode;
};
/**
* @brief Returns the tensor resulted from performing the equal logical operation elementwise\n
* on the input tensors x1 and x2.
*
* The {@link NodeType} of this operator is NODE_TYPE_EQUAL.
*
* Input:
*
* * x1, the first input operand.
* * x2, the second input operand.
*
* Output:
*
* * Result tensor.
*
* @since 5.0
* @version 2.1
*/
struct Equal
{
};
/**
* @brief Calculates the exponential of the given input tensor, element-wise.
* ExpFusion computes outputs y = base ^ (shift + scale * x), for base > 0.
* Or if base is set to the default (-1), base is set to e,
* so y = exp(shift + scale * x).
*
* The {@link NodeType} of this operator is NODE_TYPE_EXPFUSION.
*
* Input:
*
* * x, input tensor.
*
* Output:
*
* * The exponential of the input tensor computed element-wise.
*
* @since 5.0
* @version 2.1
*/
struct ExpFusion
{
/** base of exponential function, default -1 for a value of e, must be > 0 */
float base;
/** amplifcation factor of independent value, default 1 */
float scale;
/** offset of independent value, default 1 */
float shift;
};
/**
* @brief Adds an additional dimension to a tensor at the given axis.
*
* The {@link NodeType} of this operator is NODE_TYPE_EXPAND_DIMS.
*
* Input:
*
* * x, an n-dimensional tensor.
* * axis: index of the dimension to be added. The value is of the int32_t type and must be a constant\n
* in the range [-dim-1, dim].
*
* Output:
*
* * Operator with an additional dimension at the given axis.
*
* @since 3.2
* @version 2.1
*/
struct ExpandDims
{
};
/**
* @brief 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).
*
* The {@link NodeType} of this operator is NODE_TYPE_FLATTEN.
*
* Input:
*
* * x: A tensor of rank >= axis.
*
* Output:
*
* * A 2-dimension tensor with the contents of the input tensor, with input dimensions up to axis flattened to\n
* the outer dimension of the output and remaining input dimensions flattened into the inner dimension of the output.
*
* @since 5.0
* @version 2.1
*/
struct Flatten
{
/** 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). */
long axis;
};
/**
* @brief Returns element-wise largest integer not greater than x.
*
* The {@link NodeType} of this operator is NODE_TYPE_FLOOR.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Output tensor after floored.
*
* @since 5.0
* @version 2.1
*/
struct Floor
{
};
/**
* @brief Creates a tensor of the specified dimensions and fills it with a scalar.
*
* The {@link NodeType} of this operator is NODE_TYPE_FILL.
*
* Input:
*
* * value: scalar used to fill the tensor.
* * shape, which specifies the dimensions of the tensor to create.
*
* Output:
*
* * Tensor filled by the scaler.
*
* @since 3.2
* @version 2.1
*/
struct Fill
{
};
/**
* @brief Applies full connection for the input data.
*
* The {@link NodeType} of this operator is NODE_TYPE_FULL_CONNECTION.
*
* When useAxis is true, axis must be set. When useAxis is false,\n
* axis is 0.
*
* Input:
*
* * x, an n-dimensional tensor.
* * weight: weight tensor for a full connection.
* * bias, a full-connection bias. In quantization scenarios, a quantized parameter is not required.
* * If quantization is required, the data must be of the int32 type. The actual quantization parameter is\n
* determined by x and weight.
*
* Output:
*
* * output: computed tensor.
*
* @since 3.2
* @version 2.1
*/
struct FullConnection
{
/** Whether to use the bias. */
boolean hasBias;
/** Whether to use the axis. */
boolean useAxis;
/** Axis specified for the full connection. The specified axis and its following axes are converted into\n
* a 1D tensor and then apply the full connection.
*/
long axis;
/** Activation function type. For details, see {@link ActivationType}. */
enum ActivationType activationType;
};
/**
* @brief Performs batch normalization for a tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_FUSED_BATCH_NORM.
*
* Input:
*
* * x: a tensor of shape [N, ..., C], that is, the nth dimension is the number of channels.
* * scale: 1D tensor of the scaling factor used to scale the first normalized tensor.
* * offset: 1D tensor used to move to the first normalized tensor.
* * mean: 1D tensor of the overall mean value. It is used only for inference. In case of training,\n
* this parameter must be left empty.
* * variance: 1D tensor used for the overall variance. It is used only for inference. In case of training,\n
* this parameter must be left empty.
*
* Output:
*
* * output: computed tensor.
*
* @since 3.2
* @version 2.1
*/
struct FusedBatchNorm
{
/** A small value close to zero. It is used to ensure that the divisor is not 0. */
float epsilon;
};
/**
* @brief Returns the slice of the input tensor based on the specified index and axis.
*
* The {@link NodeType} of this operator is NODE_TYPE_GATHER.
*
* Input:
*
* * x, an n-dimensional tensor.
* * inputIndices, indices of elements of the original tensor. The value is an array of the int type\n
* and must be in the range [0, x.shape[axis]).
* * axis, the axis on which x is sliced. The value is an array with one element of the int32_t type.
*
* Output:
*
* * Sliced tensor.
*
* @since 3.2
* @version 2.1
*/
struct Gather
{
};
/**
* @brief Returns the tensor resulted from performing the greater logical operation elementwise\n
* on the input tensors x1 and x2.
*
* The {@link NodeType} of this operator is NODE_TYPE_GREATER.
*
* Input:
*
* * x1, the first input operand.
* * x2, the second input operand.
*
* Output:
*
* * Result tensor.
*
* @since 5.0
* @version 2.1
*/
struct Greater
{
};
/**
* @brief Returns the tensor resulted from performing the greater-equal logical operation elementwise\n
* on the input tensors x1 and x2.
*
* The {@link NodeType} of this operator is NODE_TYPE_GREATER_EQUAL.
*
* Input:
*
* * x1, the first input operand.
* * x2, the second input operand.
*
* Output:
*
* * Result tensor.
*
* @since 5.0
* @version 2.1
*/
struct GreaterEqual
{
};
/**
* @brief Carries out instance normalization as formula y = scale * (x - mean) / sqrt(variance + epsilon) + B,
* where mean and variance are computed per instance per channel.
*
* The {@link NodeType} of this operator is NODE_TYPE_INSTANCE_NORM.
*
* Input:
*
* * x, input data tensor from the previous operator;
* Dimensions for image case are (N x C x H x W), where N is the batch size,
* C is the number of channels, and H and W are the height and the width of the data.
* For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size.
* * The input 1-dimensional scale tensor of size C.
* * The input 1-dimensional bias tensor of size C.
*
* Output:
*
* * The output tensor of the same shape as input.
*
* @since 5.0
* @version 2.1
*/
struct InstanceNorm
{
/** The epsilon value to use to avoid division by zero. */
float epsilon;
};
/**
* @brief Applies layer normalization for a tensor from the specified axis.
*
* The {@link NodeType} of this operator is NODE_TYPE_LAYER_NORM_FUSION.
*
* Input:
*
* * x, an n-dimensional tensor.
* * gamma, an m-dimensional tensor. The dimensions of gamma must be the same as the shape of the part\n
* of the input tensor to normalize.
* * beta, an m-dimensional tensor with the same shape as gamma.
*
* Output:
*
* * An n-dimensional tensor, with the same data type and shape as the input tensor.
*
* @since 3.2
* @version 2.1
*/
struct LayerNormFusion
{
/** Start axis of x to apply layer normalization. */
long beginNormAxis;
/** A value added to the denominator for numerical stability. */
float epsilon;
/** Whether to perform an element-wise operation. */
boolean elementwiseAffine;
/** Start axis of the parameter input (gamma, beta) to apply layer normalization.\n
* The value must be in the range [-n, n).
*/
long beginParamsAxis;
};
/**
* @brief LeakyRelu takes input data (Tensor) and an argument alpha, and produces one output data (Tensor)\n
* where the function f(x) = alpha * x for x < 0, f(x) = x for x >= 0, is applied to the data tensor elementwise.
*
* The {@link NodeType} of this operator is NODE_TYPE_LEAKY_RELU.
*
* Input:
*
* * x, input tensor.
*
* Output:
*
* * Result tensor.
*
* @since 5.0
* @version 2.1
*/
struct LeakyRelu
{
/** Coefficient of leakage. */
float negativeSlope;
};
/**
* @brief Returns the tensor resulted from performing the less logical operation elementwise\n
* on the input tensors x1 and x2.
*
* The {@link NodeType} of this operator is NODE_TYPE_LESS.
*
* Input:
*
* * x1, the first input operand.
* * x2, the second input operand.
*
* Output:
*
* * Result tensor.
*
* @since 5.0
* @version 2.1
*/
struct Less
{
};
/**
* @brief Calculates the result of x1 <= x2 element-wise.
*
* The {@link NodeType} of this operator is NODE_TYPE_LESS_EQUAL.
*
* Input:
*
* * x1, which can be a number, a Boolean value, or a tensor whose data type is number or Boolean.
* * x2, which can be a number or a Boolean value if x1 is a tensor; or a tensor with the data type\n
* of number or Boolean if x1 is not a tensor.
*
* Output:
*
* * A tensor with the data type of Boolean. When a quantization model is used, the quantization parameters of\n
* the output cannot be omitted. However, values of the quantization parameters do not affect the result.
*
* @since 3.2
* @version 2.1
*/
struct LessEqual
{
};
/**
* @brief Calculates the result of nature logarithm of the input x.
*
* The {@link NodeType} of this operator is NODE_TYPE_LOG.
*
* Input:
*
* * x, the input tensor.
*
* Output:
*
* * Result tensor.
*
* @since 5.0
* @version 2.1
*/
struct Log
{
};
/**
* @brief Calculates the logical value of x1 AND x2 element-wise.
*
* The {@link NodeType} of this operator is NODE_TYPE_LOGICAL_AND.
*
* Input:
*
* * x1, tensor of type boolean or convert to boolean implicitly.
* * x2, tensor of type boolean or convert to boolean implicitly.
*
* Output:
*
* * A tensor of type bool with the shape that x1 and x2 broadcast to.
*
* @since 5.0
* @version 2.1
*/
struct LogicalAnd
{
};
/**
* @brief Calculates the logical value of NOT x element-wise.
*
* The {@link NodeType} of this operator is NODE_TYPE_LOGICAL_NOT.
*
* Input:
*
* * x, tensor of type boolean or convert to boolean implicitly.
*
* Output:
*
* * A tensor of type bool with the shape of x.
*
* @since 5.0
* @version 2.1
*/
struct LogicalNot
{
};
/**
* @brief Calculates the logical value of x1 OR x2 element-wise.
*
* The {@link NodeType} of this operator is NODE_TYPE_LOGICAL_OR.
*
* Input:
*
* * x1, tensor of type boolean or convert to boolean implicitly.
* * x2, tensor of type boolean or convert to boolean implicitly.
*
* Output:
*
* * A tensor of type bool with the shape that x1 and x2 broadcast to.
*
* @since 5.0
* @version 2.1
*/
struct LogicalOr
{
};
/**
* @brief Normalize over local input regions.
*
* The {@link NodeType} of this operator is NODE_TYPE_LRN.
*
* Input:
*
* * x, input tensor of n-dimensional.
*
* Output:
*
* * Result output tensor.
*
* @since 5.0
* @version 2.1
*/
struct LRN
{
/** Half-width of the 1-dimension normalization window. */
long depthRadius;
/** Offset. */
float bias;
/** Scale factor. */
float alpha;
/** Exponent. */
float beta;
/** Specifies normalization region. Options: "ACROSS_CHNNEL". */
String normRegion;
};
/**
* @brief Calculate the L2-normalize of the input using the given axis.
*
* The {@link NodeType} of this operator is NODE_TYPE_L2_NORMALIZE_FUSION.
*
* Input:
*
* * x, input to compute the L2-normalization.
*
* Output:
*
* * Result tensor with the same type and shape as input x.
*
* @since 5.0
* @version 2.1
*/
struct L2NormalizeFusion
{
/** The axis on which to apply normalization, -1 means last axis, default: 0.*/
long[] axis;
/** Value added for numerical stability. default: 1e-4; */
float epsilon;
/** Activation function type. For details, see {@link ActivationType}. */
enum ActivationType activationType;
};
/**
* @brief Computes an one-layer LSTM. This operator is usually supported via some custom implementation.
*
* The {@link NodeType} of this operator is NODE_TYPE_LSTM.
*
* Input:
*
* * input, input tensor, shape is [seqLen, batchSize, inputSize].
* * weightIh, weight tensor of input-layer to hidden-layer,
* shape is [numDirections * numLayers, 4 * hiddenSize, inputSize].
* * weightHh, weight tensor of hidden-layer to hidden-layer,
* shape is [numDirections * numLayers, 4 * hiddenSize, hiddenSize].
* * bias, bias tensor of input-layer and hidden-layer to hidden-layer,
* shape is [numDirections * numLayers, 8 * hiddenSize].
* * hiddenState, init state of hidden-layer, shape is [numDirections * numLayers, batchSize, hiddenSize].
* * cellState, init state of cell, shape is [numDirections * numLayers, batchSize, hiddenSize].
*
* Output:
*
* * output, a tensor that concats all the intermediate output tensor of the hidden,
* shape is [seqLen, batchSize, numDirections * realHiddenSize].
* * hiddenState, the last output tensor of the hidden-layer,
* shape is [numDirections * numLayers, batchSize, realHiddenSize].
* * cellState, the last output tensor of the cell,
* shape is [numDirections * numLayers, batchSize, hiddenSize].
*
* @since 5.0
* @version 2.1
*/
struct LSTM
{
/** Whether the LSTM operation is bi-directional. */
boolean bidirectional;
/** Whether the operation contains bias. */
boolean hasBias;
/** Size of input tensor. */
long inputSize;
/** Size of hidden state tensor. */
long hiddenSize;
/** Layers of LSTM network. */
long numLayers;
/** Number of directions, value is 2 if direction == bidirectional else 1. */
long numDirections;
/** Dropout probalility of each layer except first-layer. */
float dropout;
/** Probalility that the cell state retains the previous state. Default: 0. */
float zoneoutCell;
/** Probalility that the hidden state retains the previous state. Default: 0. */
float zoneoutHidden;
/** If projSize > 0, will use LSTM with projections of corresponding size. Default: 0. */
long projSize;
};
/**
* @brief Calculates the matrix product of x1 and x2.
*
* The {@link NodeType} of this operator is NODE_TYPE_MATMUL_FUSION.
*
* Input:
*
* * x1, an n-dimensional tensor, whose data type can be number or Boolean.
* * x2, an n-dimensional tensor, whose data type can be number or Boolean.
*
* Output:
*
* * Matrix product of the inputs. When type! When = DATA_TYPE_UNKNOWN, the data type of the output is determined by\n
* type. When type==DATA_TYPE_UNKNOWN,
* the data type of the output depends on the data type converted during the calculation of x1 and x2.
*
* @since 3.2
* @version 2.1
*/
struct MatMulFusion
{
/** Whether to transpose the x1 matrix. */
boolean transposeA;
/** Whether to transpose the x2 matrix. */
boolean transposeB;
/** Activation function type. For details, see {@link ActivationType}. */
enum ActivationType activationType;
};
/**
* @brief Calculates the maximum of x1 and x2 element-wise. The inputs of x1 and x2\n
* comply with the implicit type conversion rules to make the data types are consistent.
*
* The input must be two tensors or one tensor and one scalar. When the input is two tensors, the data types\n
* cannot be Boolean at the same time, and their shapes can be broadcast to the same size. When the inputs are\n
* one tensor and one scalar, the scalar must be a constant.
*
* The {@link NodeType} of this operator is NODE_TYPE_MAXIMUM.
*
* Input:
*
* * x1, an n-dimensional tensor, whose data type can be number or Boolean.
* * x2, an n-dimensional tensor, whose data type can be number or Boolean.
*
* Output:
*
* * Maximum value of the elements of the two tensors.
*
* @since 3.2
* @version 2.1
*/
struct Maximum
{
};
/**
* @brief Applies a 2D maximum pooling over an input tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_MAX_POOL_FUSION.
*
* When padMode==PAD_MODE_PAD, padList must be greater than or equal to 0.\n
* In other cases, padding must be 0.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Result tensor after max-pooling.
*
* @since 3.2
* @version 2.1
*/
struct MaxPoolFusion
{
/** Size of the kernel used to take the maximum value. It is an int array [kernel_height, kernel_weight]\n
* with length of 2.
*/
long[] kernelSize;
/** Distance of kernel moving. It is an int array with two elements. */
long[] strides;
/** Array to pad. */
long[] pad;
/** Padding mode. For details, see {@link PadMode}. */
enum PadMode padMode;
/** Format of the tensor data. For details, see {@link Format}. */
enum Format format;
/** RoundMode mode. For details, see {@link RoundMode}. */
enum RoundMode roundMode;
/** Whether to do global pooling. */
boolean global;
/** Activation function type. For details, see {@link ActivationType}. */
enum ActivationType activationType;
};
/**
* @brief Calculates the minimum of x1 and x2 element-wise. The inputs of x1 and x2\n
* comply with the implicit type conversion rules to make the data types are consistent.
*
* The input must be two tensors or one tensor and one scalar. When the input is two tensors, the data types\n
* cannot be Boolean at the same time, and their shapes can be broadcast to the same size. When the inputs are\n
* one tensor and one scalar, the scalar must be a constant.
*
* The {@link NodeType} of this operator is NODE_TYPE_MINIMUM.
*
* Input:
*
* * x1, an n-dimensional tensor, whose data type can be number or Boolean.
* * x2, an n-dimensional tensor, whose data type can be number or Boolean.
*
* Output:
*
* * Minimum value of the elements of the two tensors.
*
* @since 5.0
* @version 2.1
*/
struct Minimum
{
};
/**
* @brief Computes the remainder of dividing the first input tensor by the second input tensor element-wise.
*
* Inputs of x and y comply with the implicit type conversion rules to make the data types consistent.
* The inputs must be two tensors or one tensor and one scalar. When the inputs are two tensors,
* both dtypes cannot be bool, and the shapes of them could be broadcast.
* When the inputs are one tensor and one scalar, the scalar could only be a constant.
*
* The {@link NodeType} of this operator is NODE_TYPE_MOD.
*
* Input:
*
* * x, a number, a bool or a tensor whose data type is number.
* * y, if input x is a tensor, y could be a number, a bool or a tensor whose data type is number.
* If input x is a number or a bool, y must be a tensor whose data type is number.
*
* Output:
*
* * Result tensor, the shape is the same as the one after broadcasting, and the data type is the one with\n
higher precision or higher digits among the two inputs.
*
* @since 5.0
* @version 2.1
*/
struct Mod
{
};
/**
* @brief Multiplies the elements in the same position of x1 and x2 to obtain output.
*
* If the shapes of x1 and x2 are different, expand x1 and x2 to the same shape through\n
* broadcast and then perform the multiplication.
* The {@link NodeType} of this operator is NODE_TYPE_MUL_FUSION.
*
* Input:
*
* * x1, a tensor of the int or float type.
* * x2, a tensor of the int or float type.
*
* Output:
*
* * Product of each element of x1 and x2.
*
* @since 3.2
* @version 2.1
*/
struct MulFusion
{
/** Activation function type. For details, see {@link ActivationType}. */
enum ActivationType activationType;
};
/**
* @brief Calculate the opposite value of the input tensor element-wise.
*
* The {@link NodeType} of this operator is NODE_TYPE_NEG.
*
* Input:
*
* * x, a tensor of the int or float type.
*
* Output:
*
* * Result tensor, has the same shape and dtype as input x.
*
* @since 5.0
* @version 2.1
*/
struct Neg
{
};
/**
* @brief Returns the tensor resulted from performing the not-equal logical operation elementwise\n
* on the input tensors x1 and x2.
*
* The {@link NodeType} of this operator is NODE_TYPE_NOT_EQUAL.
*
* Input:
*
* * x1, the first input operand.
* * x2, the second input operand.
*
* Output:
*
* * Result tensor.
*
* @since 5.0
* @version 2.1
*/
struct NotEqual
{
};
/**
* @brief Generates a one-hot tensor based on the specified locations.
*
* The locations specified by indices are determined by onValue, and other locations are determined\n
* by offValue.
*
* The {@link NodeType} of this operator is NODE_TYPE_ONE_HOT.
*
* Input:
*
* * indices, an n-dimensional tensor. Each element in indices determines the location of onValue\n
* in each one-hot vector.
* * depth, an integer scalar that determines the depth of the one-hot vector. The value of depth must be\n
* greater than 0.
* * onValue, a scalar that specifies a valid value in the one-hot vector.
* * offValue, a scalar that specifies the values of other locations in the one-hot vector except the valid value.
*
* Output:
*
* * An (n+1)-dimensional tensor if indices is an n-dimensional tensor. The output shape is determined by\n
* indices and axis.
*
* @since 3.2
* @version 2.1
*/
struct OneHot
{
/**
* An integer scalar that specifies the dimension for inserting the one-hot.
* Assume that the shape of indices is [N, C],\n
* and the value of depth is D.
* When axis is 0, the shape of the output is [D, N, C].
* When axis is -1, the shape of the output is [N, C, D].
* When axis is -1, the shape of the output is [N, D, C].
*/
long axis;
};
/**
* @brief Pads the input tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_PAD_FUSION.
*
* When paddingMode==PADDING_MODE_CONSTANT, constantValue must be set.
* The default value of constantValue is 0.
*
* Input:
*
* * x, an n-dimensional tensor.
* * paddings, a 2D tensor that specifies the length to add in each dimension.
* The shape is [n, 2]. paddings[i][0] indicates the number of paddings to add before the input\n
* tensor in ith dimension.
* * paddings[i][1] indicates the number of paddings to add after the input tensor in ith dimension.
*
* Output:
*
* * An n-dimensional tensor after padding, with the same dimensions and data type as x.
* The shape is determined by x and paddings.
* output.shape[i] = input.shape[i] + paddings[i][0]+paddings[i][1]
*
* @since 3.2
* @version 2.1
*/
struct PadFusion
{
/**
* A 2D tensor, specifying the length to add in each dimension. The shape is [n, 2]. paddings[i][0]
* indicates the number of paddings to add before the input x in the ith dimension.
* paddings[i][1] indicates the number of paddings to add after the input x in the ith dimension.
* The meaning of this parameter is the same as that of paddings input.
*/
long[][] paddings;
/**
* Padding mode.
* For details, see {@link PaddingMode}.
*/
enum PaddingMode paddingMode;
/**
* A constant with the same data type as x. It specifies the value to add in the pad operation.
* This parameter is valid only when paddingMode==PADDING_MODE_CONSTANT. The default value is 0.
*/
float constantValue;
};
/**
* @brief Calculates the y power of each element in x. The inputs must be two tensors or one tensor
* and one scalar.
*
* When the inputs are two tensors, their data types cannot be Boolean at the same time, and their shapes
* must be the same.
* When the inputs are one tensor and one scalar, the scalar must be a constant.
*
* The {@link NodeType} of this operator is NODE_TYPE_POW_FUSION.
*
* The x' = scale*x+shift operation is performed for each element of x, and then the y power of
* x' is calculated.
*
* Input:
*
* * x, a number, a Boolean value, or a tensor whose data type is number or Boolean.
* * y, a number, a Boolean value, or a tensor whose data type is number or Boolean.
*
* Output:
*
* * A tensor, whose shape is determined by the shape of x and y after broadcasting.
*
* @since 3.2
* @version 2.1
*/
struct PowFusion
{
/** Scale the value of x. */
float scale;
/** Increase or decrease the value of x after scaling. */
float shift;
};
/**
* @brief Applies the PReLU activation of x and weight.
*
* The {@link NodeType} of this operator is NODE_TYPE_PRELU_FUSION.
*
* Input:
*
* * x, an n-dimensional tensor. If n is greater than or equal to 2, x must be
* [BatchSize, ..., Channels]. The second dimension is the number of channels.
* * weight, a 1D tensor. The length of weight must be 1 or equal to the number of channels.
* If the length of weight is 1, all channels share the same weight.
* If the length of weight is equal to the number of channels, each channel exclusively has a weight.
* If n of x is less than 2, the weight length must be 1.
*
* Output:
*
* * PReLU activation value of x, with the same shape and data type as x.
*
* @since 3.2
* @version 2.1
*/
struct PReLUFusion
{
/**
* Whether to enable weight sharing for the parameter validity check.
* If the length of weight is 1, channelShared must be true.
* Otherwise, channelShared is false.
*/
boolean channelShared;
};
/**
* @brief Converts the data type.
*
* The {@link NodeType} of this operator is NODE_TYPE_QUANT_DTYPE_CAST.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Tensor after the data type conversion.
*
* @since 3.2
* @version 2.1
*/
struct QuantDTypeCast
{
/** Data type of the input tensor. */
long srcT;
/** Data type of the output tensor. */
long dstT;
};
/**
* @brief Calculate the rank of a tensor.
*
* The rank of a tensor is the number of indices required to uniquely select each element of the tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_RANK.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Result tensor. 0-D int32 Tensor representing the rank of input.
*
* @since 5.0
* @version 2.1
*/
struct Rank
{
};
/**
* @brief Generate a tensor containing a sequence of numbers that begin at start\n
* and extends by increments of delta up to limit.
*
* The {@link NodeType} of this operator is NODE_TYPE_RANGE.
*
* Input:
*
* * x an n-dimensional tensor.
*
* Output:
*
* * A 1-D tensor with specific data type containing generated range of values.
*
* @since 5.0
* @version 2.1
*/
struct Range
{
/** Reserved dataType parameter. */
long dataType;
/** Scalar. First entry for the range of output values. */
long start;
/** Scalar. Exclusive upper limit for the range of output values. */
long limit;
/** Scalar. Value to step by. */
long delta;
};
/**
* @brief Calculate reciprocal of a tensor element-wise.
*
* The {@link NodeType} of this operator is NODE_TYPE_RECIPROCAL.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Result tensor with the same shape as the input x.
*
* @since 5.0
* @version 2.1
*/
struct Reciprocal
{
};
/**
* @brief Return x / y element-wise for real types. If x and y are reals, this will return floating-point division.
*
* The {@link NodeType} of this operator is NODE_TYPE_REAL_DIV.
*
* Input:
*
* * x, an n-dimensional tensor.
* * y, an n-dimensional tensor. Has the same data type as x.
*
* Output:
*
* * A tensor. Has the same data type as x.
*
* @since 5.0
* @version 2.1
*/
struct RealDiv
{
};
/**
* @brief Reduces the dimensions of a tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_REDUCE_FUSION.
* If mode is REDUCE_ALL, REDUCE_PROD, or REDUCE_MEAN and reduceToEnd
* is true, the output is the reduced value multiplied by coeff.
*
* Input:
*
* * x, an n-dimensional tensor, where n is less than 8.
* * axis, a 1D tensor that specifies the dimension to reduce. The value range of each element in axis
* is [–n, n).
*
* Output:
*
* * An m-dimensional tensor, with the same data type as x. If keepDims is false, m < n.
* If keepDims is true, m==n.
*
* @since 3.2
* @version 2.1
*/
struct ReduceFusion
{
/** Whether to keep the dimensions remain unchanged. */
boolean keepDims;
/** Algorithm used to reduce the tensor dimensions. For details, see {@link ReduceMode}. */
enum ReduceMode mode;
/**
* If this parameter is set to true, the first element is obtained from axis and set to i,
* and then axis will be changed to [i,i+1, ...,n-1,n].
* For example, if reduceToEnd is true, axis is [2,4], and the number of dimensions of
* x is 7, then axis will be [2,3,4,5,6].
*/
boolean reduceToEnd;
/** Coefficient. */
float coeff;
};
/**
* @brief Reshapes a tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_RESHAPE.
*
* Input:
*
* * x, an n-dimensional tensor.
* * InputShape, a 1D tensor that specifies the shape of the output tensor. It must be a constant.
*
* Output:
*
* * A tensor of the specified shape. The data type is the same as that of x.
*
* @since 3.2
* @version 2.1
*/
struct Reshape
{
};
/**
* @brief Resizes a tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_RESIZE.
*
* The parameter combination of this operator can implement the Resize function.
* For example, to implement bilinear interpolation on the four corners of an image that is precisely aligned, set:
* method = RESIZE_METHOD_LINEAR
* coordinateTransformMode = COORDINATE_TRANSFORM_MODE_ALIGN_CORNERS
*
* Input:
*
* * x, a 4D tensor in the [batchSize, height, width, channels] (NHWC) format.
*
* Output:
*
* * An n-dimensional tensor, with the same shape and data type as x.
*
* @since 3.2
* @version 2.1
*/
struct Resize
{
/** Method used for resizing. For details, see {@link ResizeMethod}. */
enum ResizeMethod method;
/** Height of the 4D tensor after resizing. */
long newHeight;
/** Width of the 4D tensor after resizing. */
long newWidth;
/** Whether to maintain the height/width ratio of x after resizing. */
boolean preserveAspectRatio;
/**
* Coordinate transformation method. For details, see {@link CoordinateTransformMode}.
*/
enum CoordinateTransformMode coordinateTransformMode;
/** Cubic coefficient, used when method is RESIZE_METHOD_CUBIC. */
float cubicCoeff;
/** When excludeOutside==1, the sampling weight that exceeds the boundary of x is set to 0,
* and other weights are normalized.
*/
long excludeOutside;
/** Value to interpolate, which is used only when x is cropped. The sampling weight that exceeds the
* boundary is set to extrapolationValue.
*/
float extrapolationValue;
/** Nearest neighbor interpolation algorithm, used when method is RESIZE_METHOD_NEAREST.
* For details, see {@link NearestMode}.
*/
enum NearestMode nearestMode;
};
/**
* @brief Calculate half to even of a tensor element-wise.
*
* The {@link NodeType} of this operator is NODE_TYPE_ROUND.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Result tensor with the same shape as the input x.
*
* @since 5.0
* @version 2.1
*/
struct Round
{
};
/**
* @brief Calculates the reciprocal of the square root of a tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_RSQRT.
*
* Input:
*
* *x, an n-dimensional tensor, where n is less than 8. Each element of the tensor cannot be less than 0.
*
* Output:
*
* * An n-dimensional tensor, with the same shape and data type as x.
*
* @since 3.2
* @version 2.1
*/
struct Rsqrt
{
};
/**
* @brief Scales a tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_SCALE_FUSION.
*
* Input:
*
* * x, an n-dimensional tensor.
* * scale, the scaling tensor.
* * bias, the bias tensor.
*
* Output:
*
* * An n-dimensional tensor scaled, whose data type is the same as that of xx and shape is determined
* by axis.
*
* @since 3.2
* @version 2.1
*/
struct ScaleFusion
{
/** Dimensions to scale. */
long axis;
/** Activation function type. For details, see {@link ActivationType}. */
enum ActivationType activationType;
};
/**
* @brief Scatters a tensor into a new tensor depending on the specified indices.
*
* The {@link NodeType} of this operator is NODE_TYPE_SCATTER_ND.
*
* Input:
*
* * indices, the index of scattering in the new tensor with int32 or int64 data type.
* The rank of indices must be at least 2 and indices_shape[-1] <= len(shape).
* * updates, the source tensor to be scattered. It has shape indices_shape[:-1] + shape[indices_shape[-1]:].
* * shape, the shape of the output tensor, has the same data type as indices.
*
* Output:
*
* * Result tensor with the same type as update and the same shape as shape.
*
* @since 5.0
* @version 2.1
*/
struct ScatterNd
{
};
/**
* @brief Returns the share of the input tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_SHAPE.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * An integer array representing the dimensions of x.
*
* @since 3.2
* @version 2.1
*/
struct Shape
{
};
/**
* @brief Calculate sine of the input element-wise.
*
* The {@link NodeType} of this operator is NODE_TYPE_SIN.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Result tensor with the same shape as the input x.
*
* @since 5.0
* @version 2.1
*/
struct Sin
{
};
/**
* @brief Slices a tensor of the specified size.
*
* The {@link NodeType} of this operator is NODE_TYPE_SLICE_FUSION.
*
* Input:
*
* * x, an n-dimensional tensor.
* * begin, an array of integers greater than or equal to 0, specifying the start of the slice.
* * size, an array of integers greater than or equal to 0, specifying the length of the slice.
* Assume that a dimension is i and 1<=size[i]<=input.shape[i]-begin[i].
*
* Output:
*
* * An n-dimensional tensor obtained.
*
* @since 3.2
* @version 2.1
*/
struct SliceFusion
{
/** Dimensions on which the tensor is sliced. */
long[] axes;
};
/**
* @brief Applies the softmax operation on a tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_SOFTMAX.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Result of the softmax operation. It is an n-dimensional tensor with the same data type and shape
* as x.
*
* @since 3.2
* @version 2.1
*/
struct Softmax
{
/** Dimensions on which the softmax operation is performed. It is an integer in the range [-n, n). */
long[] axis;
};
/**
* @brief Splits a 4D tensor into multiple blocks in the spatial dimension and then concatenates these blocks
* in the batch dimension.
*
* The {@link NodeType} of this operator is NODE_TYPE_SPACE_TO_BATCH_ND.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* A 4D tensor with the same data type as x. The shape is determined by input, blockShape,
* and paddings. Assume that the input shape is [n,c,h,w], then:
* \f$ output.shape[0] = n * blockShape[0] * blockShape[1]\f$
* \f$ output.shape[1] = c \f$
* \f$ output.shape[2] = (h + paddings[0][0] + paddings[0][1]) / blockShape[0] \f$
* \f$ output.shape[3] = (w + paddings[1][0] + paddings[1][1]) / blockShape[1] \f$
* \f$ (h + paddings[0][0] + paddings[0][1]) must be an integer multiple of \f$ blockShape[0]\f$, and
* (w + paddings[1][0] + paddings[1][1]) \f$ must be an integer multiple of \f$ blockShape[1] \f$.
*
* @since 3.2
* @version 2.1
*/
struct SpaceToBatchND
{
/** Number of blocks. The value must be greater than 1. */
long[] blockShape;
/** Padding size for spatial dimensions. */
long[][] paddings;
};
/**
* @brief Rearrange blocks of spatial data into depth.
*
* The output tensor’s height dimension is height / blockSize;
* The output tensor’s weight dimension is weight / blockSize;
* The depth of output tensor is blockSize * blockSize * inputDepth;
* The input tensor’s height and width must be divisible by blockSize.
*
* The {@link NodeType} of this operator is NODE_TYPE_SPACE_TO_DEPTH.
*
* Input:
*
* * x, an 4-dimensional tensor.
*
* Output:
*
* * Result tensor with the same dataType as the input x.
*
* @since 5.0
* @version 2.1
*/
struct SpaceToDepth
{
/** The block size used to divide spatial data. It must be >= 2. */
long blockSize;
/** Format of the tensor data. For details, see {@link Format}. */
enum Format format;
};
/**
* @brief Converts a sparse representation into a dense tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_SPARSE_TO_DENSE.
*
* Input:
*
* * indices, 2-dimension tensor, represents the position of the element in the sparse tensor.
* * values, 1-dimension Tensor, represents the value corresponding to the position in the indices.
* * sparseShape, a positive int tuple which specifies the shape of sparse tensor,
* should have 2 elements, represent sparse tensor shape is (N, C).
*
* Output:
*
* * Result tensor converted from sparse tensor with dtype samed as values, and the shape is sparseShape.
*
* @since 5.0
* @version 2.1
*/
struct SparseToDense
{
};
/**
* @brief Splits a tensor into multiple tensors along the axis dimension. The number of tensors is
* specified by outputNum.
*
* The {@link NodeType} of this operator is NODE_TYPE_SPLIT.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * An array of n-dimensional tensors, with the same data type and dimensions.
* The data type of each tensor is the same as that of x.
*
* @since 3.2
* @version 2.1
*/
struct Split
{
/** Number of output sensors. */
long outputNum;
/**
* Size of each tensor to output.
* If sizeSplits is empty, x will be evenly split into tensors of the same size.
* In this case, x.shape[axis] must be an integer multiple of outputNum.
* If sizeSplits is not empty, the sum of all elements must be equal to x.shape[axis].
*/
long[] sizeSplits;
/** Target axis on which x is split. The data type is int. */
long axis;
};
/**
* @brief Calculates the square root of a tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_SQRT.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * An n-dimensional tensor, with the same data type and shape as x.
*
* @since 3.2
* @version 2.1
*/
struct Sqrt
{
};
/**
* @brief Calculates the square of a tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_SQUARE.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * An n-dimensional tensor, with the same data type and shape as x.
*
* @since 5.0
* @version 2.1
*/
struct Square
{
};
/**
* @brief Calculates the square of the difference between two tensors.
* The SquaredDifference operator supports subtraction between tensors.
*
* The {@link NodeType} of this operator is NODE_TYPE_SQUEEZE.
*
* Input:
*
* * x, a tensor representing the minuend, which can be a number or a Boolean value.
* * x, a tensor representing the subtrahend, which can be a number or a Boolean value.
*
* Output:
*
* * A tensor obtained. The shape of the output is determined by x and y.
* If x and y are of the same shape, the output shape is the same as that of x and y.
* If x and y are of different types, you need to perform the broadcast operation on
* x and y first.
* The precision of the output is the same as the input tensor with higher precision.
*
* @since 3.2
* @version 2.1
*/
struct SquaredDifference
{
};
/**
* @brief Removes the dimension with length of 1 from the specified axis. The int8 quantization input is supported.
*
* Assume that the shape of x is [2, 1, 1, 2, 2] and axis is [0,1], the shape of the output tensor\n
* must be [2, 1, 2, 2]. That is, the dimension with the length of 1 between the 0th and 1st dimensions is removed.
*
* The {@link NodeType} of this operator is NODE_TYPE_SQUARED_DIFFERENCE.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* *Tensor obtained.
*
* @since 3.2
* @version 2.1
*/
struct Squeeze
{
/** Axis on which the dimension of length 1 is to be removed. The value can be an integer or an array.
* The value range of the integer is [-n, n).
*/
long[] axis;
};
/**
* @brief Stacks multiple tensors along the specified axis. If the number of dimensions of each tensor is n
* before stacking, the number of dimensions of the output tensor is n+1.
*
* The {@link NodeType} of this operator is NODE_TYPE_STACK.
*
* Input:
*
* * Multiple n-dimensional tensors, which are of the same data type and shape.
*
* Output:
*
* * An n+1D tensor along the specified axis, with the same data type and precision as the input tensors.
*
* @since 3.2
* @version 2.1
*/
struct Stack
{
/** An integer that specifies the dimension for tensor stacking. The value range is [-(n+1),(n+1)),
* which means a negative number is allowed.
*/
long axis;
};
/**
* @brief Slices a tensor at the specified intervals.
*
* The {@link NodeType} of this operator is NODE_TYPE_STRIDED_SLICE.
*
* Input:
*
* * x, an n-dimensional tensor.
* * begin, a 1D tensor that specifies the position from which the tensor is sliced.
* The length of begin is n. begin[i] specifies the start point to slice in the ith dimension.
* * end, a 1D tensor that specifies the end to which the tensor is sliced. The length of end is n.
* end[i] specifies the end point to slice in the ith dimension.
* * strides, a 1D tensor that specifies the intervals for slicing. The length of strides is n.
* strides[i] specifies the intervals at which the tensor is sliced in the ith dimension. Negative values are allowed.
*
* For the input tensor, the shapes of begin, end, and strides must be the same.
* The indices of begin and end start from 0. The elements of strides cannot be 0.
*
* Output:
*
* * A tensor, with the same data type as x. The number of dimensions of the output tensor is rank (x[0])+1.
*
* @since 3.2
* @version 2.1
*/
struct StridedSlice
{
/**
* Mask of begin.
* beginMask identifies different dimensions of x in binary code. For example, if bit i of beginMask
* is set to 1, the setting of begin in the ith dimension will be invalid, which means the start index of
* that dimension is 0. The default value is 0.
*/
long beginMask;
/**
* Mask of end. The parameter is similar to beginMask.
* endMask identifies different dimensions of x in binary code. For example, if bit i of endMask is
* set to 1, the setting of end in the ith dimension will be invalid, which means the tensor will be
* sliced till the end in that dimension. The default value is 0.
*/
long endMask;
/**
* An integer used to mask begin and end.
* The tensor does not need to be sliced in the non-zero dimensions.
* ellipsisMask is represented in binary code. If bit i of ellipsisMask is 1, elements are sliced
* from the first element at strides[i] in the ith dimension until the tensor boundary.
*/
long ellipsisMask;
/**
* Used to add a dimension.
* newAxisMask identifies different dimensions of x in binary code. If bit i is 1, the settings of
* begin, end, and strides are invalid for all dimensions, and a dimension with size of 1 is added
* to bit i.
*/
long newAxisMask;
/**
* Used to shrink the specified dimension.
* shrinkAxisMask is represented in binary code. If the ith bit of the shrinkAxisMask is 1, all
* elements in the ith dimension will be discarded, and the length of the ith dimension is shrunk to 1.
*/
long shrinkAxisMask;
};
/**
* @brief Calculates the difference between two tensors.
*
* The {@link NodeType} of this operator is NODE_TYPE_SUB_FUSION.
*
* Input:
*
* * x, the minuend, which is a tensor of the int or float type.
* * y, the subtrahend, which is a tensor of the int or float type.
*
* Output:
*
* * Difference between the two tensors. The output shape is determined byx and y.
* * If x and y are of the same shape, the output tensor has the same shape as x and y.
* If x and y are of different shapes, perform the broadcast operation on x or y first.
* The precision of the output is the same as the input tensor with higher precision.
*
* @since 3.2
* @version 2.1
*/
struct SubFusion
{
/** Activation function type. For details, see {@link ActivationType}. */
enum ActivationType activationType;
};
/**
* @brief Copies a tensor by the specified times.
*
* The {@link NodeType} of this operator is NODE_TYPE_TILE_FUSION.
*
* Input:
*
* * x, an n-dimensional tensor.
* * multiples, a 1D tensor that specifies the number of times that the input tensor is copied
* in each dimension.
* * The length multiples is not less than the number of dimensions of x.
*
* Output:
*
* * An m-dimensional tensor, with the same data type as x. If the length of x is the same as that of
* multiples, the number of dimensions of the output tensor is the same as that of the x, that is,
* an n-dimensional tensor is output.
* If the length of multiples is greater than n, 1s are used to pad the dimensions of x.
* Then, x is copies the specified number of times in each dimension to obtain an m-dimensional tensor.
*
* @since 3.2
* @version 2.1
*/
struct TileFusion
{
/** A 1D tensor that specifies the number of times that data is copied in each dimension. The length m is not
* less than the number of dimensions of x.
*/
long[] dims;
};
/**
* @brief Obtains the first K maximum values along the axis and their indices.
*
* The {@link NodeType} of this operator is NODE_TYPE_TOPK_FUSION.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * output0, the first K maximum values in the axis dimension.
* * output1, indices of the first K maximum values.
*
* @since 3.2
* @version 2.1
*/
struct TopKFusion
{
/** The value true means to sort the elements in descending order; the value false means
* the opposite.
*/
boolean sorted;
/** Specified axis. */
long axis;
};
/**
* @brief Transposes a tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_TRANSPOSE.
*
* Input:
*
* * x, an n-dimensional tensor to transpose.
* * perm, a 1D tensor that specifies the permutation. Its length is the same as the number of dimensions of
* * x.
*
* Output:
*
* * An n-dimensional tensor, which has the same data type and quantization parameters as x.
* The shape is determined by the shape of x and perm.
*
* @since 3.2
* @version 2.1
*/
struct Transpose
{
};
/**
* @brief Adds a dimension based on the value of axis. *
*
* The {@link NodeType} of this operator is NODE_TYPE_UNSQUEEZE.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Tensor output.
*
* @since 3.2
* @version 2.1
*/
struct Unsqueeze
{
/** Dimension to add. The value of axis can be an integer or an array of integers.
* The value range of the integer is [-n, n).
*/
long[] axis;
};
/**
* @brief Unpacks the given dimension of a rank-R tensor into rank-(R-1) tensors.
* Unpacks tensors from x 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.
*
* The {@link NodeType} of this operator is NODE_TYPE_UNSTACK.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Tensor output.
*
* @since 5.0
* @version 2.1
*/
struct Unstack
{
/** The specific axis to apply unstack operation. */
long axis;
};
/**
* @brief Selects elements from x1 or x2 based on condition and returns a tensor.
*
* The {@link NodeType} of this operator is NODE_TYPE_WHERE.
*
* Input:
*
* * condition, A Tensor of type bool.
* * x1, 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.
* * x2, a tensor with the same data type and shape as x1.
* Output:
*
* * Tensor output. Has the same shape as x1.
*
* @since 5.0
* @version 2.1
*/
struct Where
{
};
/**
* @brief Selects elements from x1 or x2, depending on condition.
* The x1 and x2 tensors must all have the same shape, and the output will also have that shape.
* The condition tensor must be a scalar if x1 and x2 are scalars.
* If x and x2 are vectors or higher rank, then condition must be either a scalar,
* a vector with size matching the first dimension of x, or must have the same shape as x.
* The condition tensor acts as a mask that chooses, based on the value at each element,
* whether the corresponding element / row in the output should be taken from x (if true) or y (if false).
*
* The {@link NodeType} of this operator is NODE_TYPE_SELECT.
*
* Input:
*
* * condition, A Tensor of type bool.
* * x1, 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.
* * x2, a tensor with the same data type and shape as x1.
* Output:
*
* * Tensor output. Has the same shape as x1.
*
* @since 5.0
* @version 2.1
*/
struct Select
{
};
/**
* @brief Computes the Gauss error function of x element-wise.
*
* The {@link NodeType} of this operator is NODE_TYPE_ERF.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Tensor output. Has the same data type and shape as x.
*
* @since 5.0
* @version 2.1
*/
struct Erf
{
};
/**
* @brief Computes the log-softmax function to n-dimensional input tensor.
*
* The input is transformed by the Softmax function and then by the log function to lie in range[-inf,0).
*
* The {@link NodeType} of this operator is NODE_TYPE_LOG_SOFTMAX.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Tensor output. Has the same data type and shape as x.
*
* @since 5.0
* @version 2.1
*/
struct LogSoftmax
{
/** The axis to apply LogSoftmax operation, -1 means the last dimension. */
long axis;
};
/**
* @brief Gathers slices from a tensor by indices.
*
* The {@link NodeType} of this operator is NODE_TYPE_GATHER_ND.
*
* Input:
*
* * x, the target tensor to gather values.
* * indices, the index tensor with int32 or int64 data type.
*
* Output:
*
* * Sliced tensor. Has the same type as input_x and the shape is indices_shape[:-1] + x_shape[indices_shape[-1]:].
*
* @since 5.0
* @version 2.1
*/
struct GatherNd
{
};
/**
* @brief Converts the data type.
*
* The {@link NodeType} of this operator is NODE_TYPE_QUANT_DTYPE_CAST_V2.
* The v1 version {@link NodeType} of this operator is NODE_TYPE_QUANT_DTYPE_CAST,
* and the corresponding NodeAttrType is {@link QuantDTypeCast}.
*
* Input:
*
* * x, an n-dimensional tensor.
*
* Output:
*
* * Tensor after the data type conversion.
*
* @since 5.0
* @version 2.1
*/
struct QuantDTypeCastV2
{
/** Data type of the input tensor. */
long srcT;
/** Data type of the output tensor. */
long dstT;
/** The axis to apply QuantDTypeCastV2 operation. */
long axis;
};
/** @} */