Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
75 contributors

Users who have contributed to this file

@houseroad @linkerzhang @spandantiwari @gramalingam @askhade @wschin @bddppq @fumihwh @neginraoof @BowenBao @hariharans29 @liqunfu @skottmckay @jamesr66a @daquexian @zrphercule @raymondxyang @lara-hdr @TMVector @tianleiwu @kit1980 @jeffsaremi @HectorSVC @SherlockNoMad @pk-g @yuslepukhin
14853 lines (10811 sloc) 532 KB

Operator Changelog

This file is automatically generated from the def files via this script. Do not modify directly and instead edit operator definitions.

ai.onnx (default)

Version 1 of the default ONNX operator set

Abs-1

Absolute takes one input data (Tensor) and produces one output data (Tensor) where the absolute is, y = abs(x), is applied to the tensor elementwise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Add-1

Performs element-wise binary addition (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor's shape. The starting of the mutually equal shape is specified by the argument "axis", and if it is not set, suffix matching is assumed. 1-dim expansion doesn't work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor
shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor
shape(A) = (2, 3, 4, 5), shape(B) = (5,)
shape(A) = (2, 3, 4, 5), shape(B) = (4, 5)
shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1
shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int
If set, defines the broadcast dimensions. See doc for details.
broadcast : int (default is 0)
Pass 1 to enable broadcasting
consumed_inputs : list of ints
legacy optimization attribute.

Inputs

A : T
First operand, should share the type with the second operand.
B : T
Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

C : T
Result, has same dimensions and type as A

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

And-1

Returns the tensor resulted from performing the and logical operation elementwise on the input tensors A and B.

If broadcasting is enabled, the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. See the doc of Add for a detailed description of the broadcasting rules.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int
If set, defines the broadcast dimensions.
broadcast : int (default is 0)
Enable broadcasting

Inputs

A : T
Left input tensor for the logical operator.
B : T
Right input tensor for the logical operator.

Outputs

C : T1
Result tensor.

Type Constraints

T : tensor(bool)
Constrains input to boolean tensor.
T1 : tensor(bool)
Constrains output to boolean tensor.

ArgMax-1

Computes the indices of the max elements of the input tensor's element along the provided axis. The resulted tensor has the same rank as the input if keepdims equal 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. The type of the output tensor is integer.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int (default is 0)
The axis in which to compute the arg indices.
keepdims : int (default is 1)
Keep the reduced dimension or not, default 1 mean keep reduced dimension.

Inputs

data : T
An input tensor.

Outputs

reduced : tensor(int64)
Reduced output tensor with integer data type.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to all numeric tensors.

ArgMin-1

Computes the indices of the min elements of the input tensor's element along the provided axis. The resulted tensor has the same rank as the input if keepdims equal 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. The type of the output tensor is integer.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int (default is 0)
The axis in which to compute the arg indices.
keepdims : int (default is 1)
Keep the reduced dimension or not, default 1 mean keep reduced dimension.

Inputs

data : T
An input tensor.

Outputs

reduced : tensor(int64)
Reduced output tensor with integer data type.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to all numeric tensors.

AveragePool-1

AveragePool consumes an input tensor X and applies average pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. average pooling consisting of computing the average on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following:

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - kernel_spatial_shape[i]) / strides_spatial_shape[i] + 1)

* pad_shape[i] is sum of pads along axis i

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - kernel_spatial_shape[i] + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + kernel_spatial_shape[i] - input_spatial_shape[i]

The output of each pooling window is divided by the number of elements exclude pad.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

auto_pad : string (default is NOTSET)
auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding.
kernel_shape : list of ints (required)
The size of the kernel along each axis.
pads : list of ints
Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.
strides : list of ints
Stride along each spatial axis.

Inputs

X : T
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. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE ...].

Outputs

Y : T
Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

BatchNormalization-1

Carries out batch normalization as described in the paper https://arxiv.org/abs/1502.03167. Depending on the mode it is being run, there are multiple cases for the number of outputs, which we list below:

Output case #1: Y, mean, var, saved_mean, saved_var (training mode) Output case #2: Y (test mode)

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints (required)
legacy optimization attribute.
epsilon : float (default is 1e-05)
The epsilon value to use to avoid division by zero, default is 1e-5f.
is_test : int (default is 0)
If set to nonzero, run spatial batch normalization in test mode, default is 0.
momentum : float (default is 0.9)
Factor used in computing the running mean and variance.e.g., running_mean = running_mean * momentum + mean * (1 - momentum), default is 0.9f.
spatial : int (default is 1)
If true, compute the mean and variance across all spatial elements If false, compute the mean and variance across per feature.Default is 1.

Inputs

X : T
The input 4-dimensional tensor of shape NCHW.
scale : T
The scale as a 1-dimensional tensor of size C to be applied to the output.
B : T
The bias as a 1-dimensional tensor of size C to be applied to the output.
mean : T
The running mean (training) or the estimated mean (testing) as a 1-dimensional tensor of size C.
var : T
The running variance (training) or the estimated variance (testing) as a 1-dimensional tensor of size C.

Outputs (1 - 5)

Y : T
The output 4-dimensional tensor of the same shape as X.
mean (optional) : T
The running mean after the BatchNormalization operator. Must be in-place with the input mean. Should not be used for testing.
var (optional) : T
The running variance after the BatchNormalization operator. Must be in-place with the input var. Should not be used for testing.
saved_mean (optional) : T
Saved mean used during training to speed up gradient computation. Should not be used for testing.
saved_var (optional) : T
Saved variance used during training to speed up gradient computation. Should not be used for testing.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Cast-1

The operator casts the elements of a given input tensor to a data type specified by the 'to' argument and returns an output tensor of the same size in the converted type. The 'to' argument must be one of the data types specified in the 'DataType' enum field in the TensorProto message. NOTE: Casting to and from strings is not supported yet.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

to : string (required)
The data type to which the elements of the input tensor are cast. Strictly must be one of the types from DataType enum in TensorProto

Inputs

input : T1
Input tensor to be cast.

Outputs

output : T2
Output tensor with the same shape as input with type specified by the 'to' argument

Type Constraints

T1 : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool)
Constrain input types. Casting from strings and complex are not supported.
T2 : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool)
Constrain output types. Casting to strings and complex are not supported.

Ceil-1

Ceil takes one input data (Tensor) and produces one output data (Tensor) where the ceil is, y = ceil(x), is applied to the tensor elementwise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Clip-1

Clip operator limits the given input within an interval. The interval is specified with arguments 'min' and 'max'. They default to numeric_limits::lowest() and numeric_limits::max() respectively.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.
max : float
Maximum value, above which element is replaced by max
min : float
Minimum value, under which element is replaced by min

Inputs

input : T
Input tensor whose elements to be clipped

Outputs

output : T
Output tensor with clipped input elements

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Concat-1

Concatenate a list of tensors into a single tensor

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int
Which axis to concat on. Default value is 1.

Inputs (1 - ∞)

inputs (variadic) : T
List of tensors for concatenation

Outputs

concat_result : T
Concatenated tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain output types to float tensors.

Constant-1

A constant tensor.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

value : tensor (required)
The value for the elements of the output tensor.

Inputs

Outputs

output : T
Output tensor containing the same value of the provided tensor.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Conv-1

The convolution operator consumes an input tensor and a filter, and computes the output.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

auto_pad : string (default is NOTSET)
auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding.
dilations : list of ints
dilation value along each spatial axis of the filter.
group : int (default is 1)
number of groups input channels and output channels are divided into.
kernel_shape : list of ints
The shape of the convolution kernel. If not present, should be inferred from input W.
pads : list of ints
Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.
strides : list of ints
Stride along each spatial axis.

Inputs (2 - 3)

X : T
Input data tensor from previous layer; has size (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 width. Note that this is for the 2D image. Otherwise the size is (N x C x D1 x D2 ... x Dn). Optionally, if dimension denotation is in effect, the operation expects input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE ...].
W : T
The weight tensor that will be used in the convolutions; has size (M x C/group x kH x kW), where C is the number of channels, and kH and kW are the height and width of the kernel, and M is the number of feature maps. For more than 2 dimensions, the kernel shape will be (M x C/group x k1 x k2 x ... x kn), where (k1 x k2 x ... kn) is the dimension of the kernel. Optionally, if dimension denotation is in effect, the operation expects the weight tensor to arrive with the dimension denotation of [FILTER_OUT_CHANNEL, FILTER_IN_CHANNEL, FILTER_SPATIAL, FILTER_SPATIAL ...]. X.shape[1] == (W.shape[1] * group) == C (assuming zero based indices for the shape array). Or in other words FILTER_IN_CHANNEL should be equal to DATA_CHANNEL.
B (optional) : T
Optional 1D bias to be added to the convolution, has size of M.

Outputs

Y : T
Output data tensor that contains the result of the convolution. The output dimensions are functions of the kernel size, stride size, and pad lengths.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

ConvTranspose-1

The convolution transpose operator consumes an input tensor and a filter, and computes the output.

If the pads parameter is provided the shape of the output is calculated via the following equation:

output_shape[i] = stride[i] * (input_size[i] - 1) + output_padding[i] + ((kernel_shape[i] - 1) * dilations[i] + 1) - pads[start_i] - pads[end_i]

output_shape can also be explicitly specified in which case pads values are auto generated using these equations:

total_padding[i] = stride[i] * (input_size[i] - 1) + output_padding[i] + ((kernel_shape[i] - 1) * dilations[i] + 1) - output_shape[i]
If (auto_pads != SAME_UPPER): pads[start_i] = total_padding[i]/2; pads[end_i] = total_padding[i] - (total_padding[i]/2)
Else: pads[start_i] = total_padding[i] - (total_padding[i]/2); pads[end_i] = (total_padding[i]/2).

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

auto_pad : string (default is NOTSET)
auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding.
dilations : list of ints
dilation value along each spatial axis of the filter.
group : int (default is 1)
number of groups input channels and output channels are divided into.
kernel_shape : list of ints
The shape of the convolution kernel. If not present, should be inferred from input W.
output_padding : list of ints
The zero-padding added to one side of the output. This is also called adjs/adjustment in some frameworks.
output_shape : list of ints
The shape of the output can be explicitly set which will cause pads values to be auto generated. If output_shape is specified pads values are ignored. See doc for details for equations to generate pads
pads : list of ints
Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.
strides : list of ints
Stride along each spatial axis.

Inputs (2 - 3)

X : T
Input data tensor from previous layer; has size (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 width. Note that this is for the 2D image. Otherwise the size is (N x C x D1 x D2 ... x Dn)
W : T
The weight tensor that will be used in the convolutions; has size (C x M/group x kH x kW), where C is the number of channels, and kH and kW are the height and width of the kernel, and M is the number of feature maps. For more than 2 dimensions, the weight shape will be (C x M/group x k1 x k2 x ... x kn), where (k1 x k2 x ... x kn) is the dimension of the kernel. The number of channels in the output should be equal to W.shape[1] * group (assuming zero based indices of the shape array)
B (optional) : T
Optional 1D bias to be added to the convolution, has size of M.

Outputs

Y : T
Output data tensor that contains the result of the convolution. The output dimensions are functions of the kernel size, stride size, pad lengths and group count. The number of channels in the output should be equal to W.shape[1] * group (assuming zero based indices of the shape array)

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

DepthToSpace-1

DepthToSpace rearranges (permutes) data from depth into blocks of spatial data. This is the reverse transformation of SpaceToDepth. More specifically, this op outputs a copy of the input tensor where values from the depth dimension are moved in spatial blocks to the height and width dimensions.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

blocksize : int (required)
Blocks of [blocksize, blocksize] are moved.

Inputs

input : T
Input tensor of [N,C,H,W], where N is the batch axis, C is the channel or depth, H is the height and W is the width.

Outputs

output : T
Output tensor of [N, C/(blocksize * blocksize), H * blocksize, W * blocksize].

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output types to all tensor types.

Div-1

Performs element-wise binary division (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor's shape. The starting of the mutually equal shape is specified by the argument "axis", and if it is not set, suffix matching is assumed. 1-dim expansion doesn't work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor
shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor
shape(A) = (2, 3, 4, 5), shape(B) = (5,)
shape(A) = (2, 3, 4, 5), shape(B) = (4, 5)
shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1
shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int
If set, defines the broadcast dimensions. See doc for details.
broadcast : int (default is 0)
Pass 1 to enable broadcasting
consumed_inputs : list of ints
legacy optimization attribute.

Inputs

A : T
First operand, should share the type with the second operand.
B : T
Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

C : T
Result, has same dimensions and type as A

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Dropout-1

Dropout takes one input data (Tensor) and produces two Tensor outputs, output (Tensor) and mask (Tensor). Depending on whether it is in test mode or not, the output Y will either be a random dropout, or a simple copy of the input. Note that our implementation of Dropout does scaling in the training phase, so during testing nothing needs to be done.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.
is_test : int (default is 0)
(int, default 0) if nonzero, run dropout in test mode where the output is simply Y = X.
ratio : float (default is 0.5)
(float, default 0.5) the ratio of random dropout

Inputs

data : T
The input data as Tensor.

Outputs (1 - 2)

output : T
The output.
mask (optional) : T
The output mask. If is_test is nonzero, this output is not filled.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Elu-1

Elu takes one input data (Tensor) and produces one output data (Tensor) where the function f(x) = alpha * (exp(x) - 1.) for x < 0, f(x) = x for x >= 0., is applied to the tensor elementwise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

alpha : float (default is 1.0)
Coefficient of ELU default to 1.0.
consumed_inputs : list of ints
legacy optimization attribute.

Inputs

X : T
1D input tensor

Outputs

Y : T
1D input tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Equal-1

Returns the tensor resulted from performing the equal logical operation elementwise on the input tensors A and B.

If broadcasting is enabled, the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. See the doc of Add for a detailed description of the broadcasting rules.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int
If set, defines the broadcast dimensions.
broadcast : int (default is 0)
Enable broadcasting

Inputs

A : T
Left input tensor for the logical operator.
B : T
Right input tensor for the logical operator.

Outputs

C : T1
Result tensor.

Type Constraints

T : tensor(bool), tensor(int32), tensor(int64)
Constrains input to integral tensors.
T1 : tensor(bool)
Constrains output to boolean tensor.

Exp-1

Calculates the exponential of the given input tensor, element-wise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs

input : T
Input tensor

Outputs

output : T
The exponential of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Flatten-1

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).

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int (default is 1)
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 [0, R], where R is the rank of the input tensor. When axis = 0, the shape of the output tensor is (1, (d_0 X d_1 ... d_n), where the shape of the input tensor is (d_0, d_1, ... d_n).

Inputs

input : T
A tensor of rank >= axis.

Outputs

output : T
A 2D 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.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Floor-1

Floor takes one input data (Tensor) and produces one output data (Tensor) where the floor is, y = floor(x), is applied to the tensor elementwise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

GRU-1

Computes an one-layer GRU. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

X - input tensor

z - update gate

r - reset gate

h - hidden gate

t - time step (t-1 means previous time step)

W[zrh] - W parameter weight matrix for update, reset, and hidden gates

R[zrh] - R recurrence weight matrix for update, reset, and hidden gates

Wb[zrh] - W bias vectors for update, reset, and hidden gates

Rb[zrh] - R bias vectors for update, reset, and hidden gates

WB[zrh] - W parameter weight matrix for backward update, reset, and hidden gates

RB[zrh] - R recurrence weight matrix for backward update, reset, and hidden gates

WBb[zrh] - W bias vectors for backward update, reset, and hidden gates

RBb[zrh] - R bias vectors for backward update, reset, and hidden gates

H - Hidden state

num_directions - 2 if direction == bidirectional else 1

Activation functions:

Relu(x)                - max(0, x)

Tanh(x)                - (1 - e^{-2x})/(1 + e^{-2x})

Sigmoid(x)             - 1/(1 + e^{-x})

(NOTE: Below are optional)

Affine(x)              - alpha*x + beta

LeakyRelu(x)           - x if x >= 0 else alpha * x

ThresholdedRelu(x)     - x if x >= alpha else 0

ScaledTanh(x)          - alpha*Tanh(beta*x)

HardSigmoid(x)         - min(max(alpha*x + beta, 0), 1)

Elu(x)                 - x if x >= 0 else alpha*(e^x - 1)

Softsign(x)            - x/(1 + |x|)

Softplus(x)            - log(1 + e^x)

Equations (Default: f=Sigmoid, g=Tanh):

- zt = f(Xt*(Wz^T) + Ht-1*Rz + Wbz + Rbz)

- rt = f(Xt*(Wr^T) + Ht-1*Rr + Wbr + Rbr)

- ht = g(Xt*(Wh^T) + (rt (.) Ht-1)*Rh + Rbh + Wbh) # default, when linear_before_reset = 0

- ht = g(Xt*(Wh^T) + (rt (.) (Ht-1*Rh + Rbh) + Wbh) # when linear_before_reset != 0

- Ht = (1 - zt) (.) ht + zt (.) Ht-1

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

activation_alpha : list of floats
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM.
activation_beta : list of floats
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM.
activations : list of strings
A list of 2 (or 4 if bidirectional) activation functions for update, reset, and hidden gates. The activation functions must be one of the activation functions specified above. Optional: See the equations for default if not specified.
clip : float
Cell clip threshold. Clipping bounds the elements of a tensor in the range of [-threshold, +threshold] and is applied to the input of activations. No clip if not specified.
direction : string (default is foward)
Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional.
hidden_size : int
Number of neurons in the hidden layer
output_sequence : int (default is 0)
The sequence output for the hidden is optional if 0. Default 0.

Inputs (3 - 6)

X : T
The input sequences packed (and potentially padded) into one 3-D tensor with the shape of `[seq_length, batch_size, input_size]`.
W : T
The weight tensor for the gates. Concatenation of `W[zrh]` and `WB[zrh]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 3*hidden_size, input_size]`.
R : T
The recurrence weight tensor. Concatenation of `R[zrh]` and `RB[zrh]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 3*hidden_size, hidden_size]`.
B (optional) : T
The bias tensor for the gates. Concatenation of `[Wb[zrh], Rb[zrh]]` and `[WBb[zrh], RBb[zrh]]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 6*hidden_size]`. Optional: If not specified - assumed to be 0
sequence_lens (optional) : T1
Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length `seq_length`. It has shape `[batch_size]`.
initial_h (optional) : T
Optional initial value of the hidden. If not specified - assumed to be 0. It has shape `[num_directions, batch_size, hidden_size]`.

Outputs

Y (optional) : T
A tensor that concats all the intermediate output values of the hidden. It has shape `[seq_length, num_directions, batch_size, hidden_size]`. It is optional if `output_sequence` is 0.
Y_h : T
The last output value of the hidden. It has shape `[num_directions, batch_size, hidden_size]`.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
T1 : tensor(int32)
Constrain seq_lens to integer tensor.

Gather-1

Given data tensor of rank r >= 1, and indices tensor of rank q, gather entries of the axis dimension of data (by default outer-most one as axis=0) indexed by indices, and concatenates them in an output tensor of rank q + (r - 1). Example 1:

  data = [
      [1.0, 1.2],
      [2.3, 3.4],
      [4.5, 5.7],
  ]
  indices = [
      [0, 1],
      [1, 2],
  ]
  output = [
      [
          [1.0, 1.2],
          [2.3, 3.4],
      ],
      [
          [2.3, 3.4],
          [4.5, 5.7],
      ],
  ]

Example 2:

  data = [
      [1.0, 1.2, 1.9],
      [2.3, 3.4, 3.9],
      [4.5, 5.7, 5.9],
  ]
  indices = [
      [0, 2],
  ]
  axis = 1,
  output = [
      [
          [1.0, 1.9],
          [2.3, 3.9],
          [4.5, 5.9],
      ],
  ]

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int (default is 0)
Which axis to gather on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1]

Inputs

data : T
Tensor of rank r >= 1.
indices : Tind
Tensor of int32/int64 indices, of any rank q. All index values are expected to be within bounds. It is an error if any of the index values are out of bounds.

Outputs

output : T
Tensor of rank q + (r - 1).

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output types to any tensor type.
Tind : tensor(int32), tensor(int64)
Constrain indices to integer types

Gemm-1

General Matrix multiplication: https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms#Level_3 Compute Y = alpha * A * B + beta * C, where input tensor A has dimension (M X K), input tensor B has dimension (K X N), input tensor C and output tensor Y have dimension (M X N). If attribute broadcast is non-zero, input tensor C will be broadcasted to match the dimension requirement. A will be transposed before doing the computation if attribute transA is non-zero, same for B and transB.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

alpha : float (default is 1.0)
Scalar multiplier for the product of input tensors A * B, the default value is 1.0.
beta : float (default is 1.0)
Scalar multiplier for input tensor C, the default value is 1.0.
broadcast : int (default is 0)
Whether C should be broadcasted
transA : int (default is 0)
Whether A should be transposed
transB : int (default is 0)
Whether B should be transposed

Inputs

A : T
Input tensor A
B : T
Input tensor B
C : T
Input tensor C, can be inplace.

Outputs

Y : T
Output tensor.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

GlobalAveragePool-1

GlobalAveragePool consumes an input tensor X and applies average pooling across the values in the same channel. This is equivalent to AveragePool with kernel size equal to the spatial dimension of input tensor.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Inputs

X : T
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.

Outputs

Y : T
Output data tensor from pooling across the input tensor. The output tensor has the same rank as the input. The first two dimensions of output shape are the same as the input (N x C), while the other dimensions are all 1.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

GlobalLpPool-1

GlobalLpPool consumes an input tensor X and applies lp pool pooling across the the values in the same channel. This is equivalent to LpPool with kernel size equal to the spatial dimension of input tensor.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

p : float (default is 2.0)
p value of the Lp norm used to pool over the input data, default is 2.0.

Inputs

X : T
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 dimension are in the form of (N x C x D1 x D2 ... Dn), where N is the batch size.

Outputs

Y : T
Output data tensor from pooling across the input tensor. Dimensions will be N x C x 1 x 1

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

GlobalMaxPool-1

GlobalMaxPool consumes an input tensor X and applies max pooling across the values in the same channel. This is equivalent to MaxPool with kernel size equal to the spatial dimension of input tensor.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Inputs

X : T
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.

Outputs

Y : T
Output data tensor from pooling across the input tensor. The output tensor has the same rank as the input. The first two dimensions of output shape are the same as the input (N x C), while the other dimensions are all 1.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Greater-1

Returns the tensor resulted from performing the greater logical operation elementwise on the input tensors A and B.

If broadcasting is enabled, the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. See the doc of Add for a detailed description of the broadcasting rules.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int
If set, defines the broadcast dimensions.
broadcast : int (default is 0)
Enable broadcasting

Inputs

A : T
Left input tensor for the logical operator.
B : T
Right input tensor for the logical operator.

Outputs

C : T1
Result tensor.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrains input to float tensors.
T1 : tensor(bool)
Constrains output to boolean tensor.

HardSigmoid-1

HardSigmoid takes one input data (Tensor) and produces one output data (Tensor) where the HardSigmoid function, y = max(0, min(1, alpha * x + beta)), is applied to the tensor elementwise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

alpha : float (default is 0.2)
Value of alpha default to 0.2
beta : float (default is 0.5)
Value of beta default to 0.5
consumed_inputs : list of ints
legacy optimization attribute.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Hardmax-1

The operator computes the hardmax (1 for the first maximum value, and 0 for all others) values for each layer in the batch of the given input. The input is a 2-D tensor (Tensor) of size (batch_size x input_feature_dimensions). The output tensor has the same shape and contains the hardmax values of the corresponding input.

Input does not need to explicitly be a 2D vector; rather, it will be coerced into one. For an arbitrary n-dimensional tensor input \in [a_0, a_1, ..., a_{k-1}, a_k, ..., a_{n-1}] and k is the axis provided, then input will be coerced into a 2-dimensional tensor with dimensions [a_0 * ... * a_{k-1}, a_k * ... * a_{n-1}]. For the default case where axis=1, this means the input tensor will be coerced into a 2D tensor of dimensions [a_0, a_1 * ... * a_{n-1}], where a_0 is often the batch size. In this situation, we must have a_0 = N and a_1 * ... * a_{n-1} = D. Each of these dimensions must be matched correctly, or else the operator will throw errors.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int (default is 1)
Describes the axis of the inputs when coerced to 2D; defaults to one because the 0th axis most likely describes the batch_size

Inputs

input : T
The input tensor that's coerced into a 2D matrix of size (NxD) as described above.

Outputs

output : T
The output values with the same shape as input tensor (the original size without coercion).

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Identity-1

Identity operator

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
Tensor to copy input into.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output types to all tensor types.

If-1

If conditional

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

else_branch : graph (required)
Graph to run if condition is false. Has N outputs: values you wish to be live-out to the enclosing scope. The number of outputs must match the number of outputs in the then_branch.
then_branch : graph (required)
Graph to run if condition is true. Has N outputs: values you wish to be live-out to the enclosing scope. The number of outputs must match the number of outputs in the else_branch.

Inputs

cond : B
Condition for the if

Outputs (1 - ∞)

outputs (variadic, heterogeneous) : V
Values that are live-out to the enclosing scope. The return values in the `then_branch` and `else_branch` must be of the same shape and same data type.

Type Constraints

V : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
All Tensor types
B : tensor(bool)
Only bool

InstanceNormalization-1

Carries out instance normalization as described in the paper https://arxiv.org/abs/1607.08022.

y = scale * (x - mean) / sqrt(variance + epsilon) + B, where mean and variance are computed per instance per channel.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.
epsilon : float (default is 1e-05)
The epsilon value to use to avoid division by zero, default is 1e-5f.

Inputs

input : T
The input 4-dimensional tensor of shape NCHW.
scale : T
The input 1-dimensional scale tensor of size C.
B : T
The input 1-dimensional bias tensor of size C.

Outputs

output : T
The output 4-dimensional tensor of the same shape as input.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

LRN-1

Local Response Normalization proposed in the AlexNet paper. It normalizes over local input regions. The local region is defined across the channels. For an element X[n, c, d1, ..., dk] in a tensor of shape (N x C x D1 x D2, ..., Dk), its region is {X[n, i, d1, ..., dk] | max(0, c - floor((size - 1) / 2)) <= i <= min(C - 1, c + ceil((size - 1) / 2))}.

square_sum[n, c, d1, ..., dk] = sum(X[n, i, d1, ..., dk] ^ 2), where max(0, c - floor((size - 1) / 2)) <= i <= min(C - 1, c + ceil((size - 1) / 2)).

Y[n, c, d1, ..., dk] = X[n, c, d1, ..., dk] / (bias + alpha / size * square_sum[n, c, d1, ..., dk] ) ^ beta

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

alpha : float (default is 0.0001)
Scaling parameter.
beta : float (default is 0.75)
The exponent.
bias : float (default is 1.0)
size : int (required)
The number of channels to sum over

Inputs

X : T
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. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE ...].

Outputs

Y : T
Output tensor, which has the shape and type as input tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

LSTM-1

Computes an one-layer LSTM. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

X - input tensor

i - input gate

o - output gate

f - forget gate

c - cell gate

t - time step (t-1 means previous time step)

W[iofc] - W parameter weight matrix for input, output, forget, and cell gates

R[iofc] - R recurrence weight matrix for input, output, forget, and cell gates

Wb[iofc] - W bias vectors for input, output, forget, and cell gates

Rb[iofc] - R bias vectors for input, output, forget, and cell gates

P[iof] - P peephole weight vector for input, output, and forget gates

WB[iofc] - W parameter weight matrix for backward input, output, forget, and cell gates

RB[iofc] - R recurrence weight matrix for backward input, output, forget, and cell gates

WBb[iofc] - W bias vectors for backward input, output, forget, and cell gates

RBb[iofc] - R bias vectors for backward input, output, forget, and cell gates

PB[iof] - P peephole weight vector for backward input, output, and forget gates

H - Hidden state

num_directions - 2 if direction == bidirectional else 1

Activation functions:

Relu(x)                - max(0, x)

Tanh(x)                - (1 - e^{-2x})/(1 + e^{-2x})

Sigmoid(x)             - 1/(1 + e^{-x})

(NOTE: Below are optional)

Affine(x)              - alpha*x + beta

LeakyRelu(x)           - x if x >= 0 else alpha * x

ThresholdedRelu(x)     - x if x >= alpha else 0

ScaledTanh(x)          - alpha*Tanh(beta*x)

HardSigmoid(x)         - min(max(alpha*x + beta, 0), 1)

Elu(x)                 - x if x >= 0 else alpha*(e^x - 1)

Softsign(x)            - x/(1 + |x|)

Softplus(x)            - log(1 + e^x)

Equations (Default: f=Sigmoid, g=Tanh, h=Tanh):

- it = f(Xt*(Wi^T) + Ht-1*Ri + Pi (.) Ct-1 + Wbi + Rbi)

- ft = f(Xt*(Wf^T) + Ht-1*Rf + Pf (.) Ct-1 + Wbf + Rbf)

- ct = g(Xt*(Wc^T) + Ht-1*Rc + Wbc + Rbc)

- Ct = ft (.) Ct-1 + it (.) ct

- ot = f(Xt*(Wo^T) + Ht-1*Ro + Po (.) Ct + Wbo + Rbo)

- Ht = ot (.) h(Ct)

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

activation_alpha : list of floats
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.For example with LeakyRelu, the default alpha is 0.01.
activation_beta : list of floats
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.
activations : list of strings
A list of 3 (or 6 if bidirectional) activation functions for input, output, forget, cell, and hidden. The activation functions must be one of the activation functions specified above. Optional: See the equations for default if not specified.
clip : float
Cell clip threshold. Clipping bounds the elements of a tensor in the range of [-threshold, +threshold] and is applied to the input of activations. No clip if not specified.
direction : string (default is forward)
Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional.
hidden_size : int
Number of neurons in the hidden layer
input_forget : int (default is 0)
Couple the input and forget gates if 1, default 0.
output_sequence : int (default is 0)
The sequence output for the hidden is optional if 0. Default 0.

Inputs (3 - 8)

X : T
The input sequences packed (and potentially padded) into one 3-D tensor with the shape of `[seq_length, batch_size, input_size]`.
W : T
The weight tensor for the gates. Concatenation of `W[iofc]` and `WB[iofc]` (if bidirectional) along dimension 0. The tensor has shape `[num_directions, 4*hidden_size, input_size]`.
R : T
The recurrence weight tensor. Concatenation of `R[iofc]` and `RB[iofc]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 4*hidden_size, hidden_size]`.
B (optional) : T
The bias tensor for input gate. Concatenation of `[Wb[iofc], Rb[iofc]]`, and `[WBb[iofc], RBb[iofc]]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 8*hidden_size]`. Optional: If not specified - assumed to be 0.
sequence_lens (optional) : T1
Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length `seq_length`. It has shape `[batch_size]`.
initial_h (optional) : T
Optional initial value of the hidden. If not specified - assumed to be 0. It has shape `[num_directions, batch_size, hidden_size]`.
initial_c (optional) : T
Optional initial value of the cell. If not specified - assumed to be 0. It has shape `[num_directions, batch_size, hidden_size]`.
P (optional) : T
The weight tensor for peepholes. Concatenation of `P[iof]` and `PB[iof]` (if bidirectional) along dimension 0. It has shape `[num_directions, 3*hidde_size]`. Optional: If not specified - assumed to be 0.

Outputs (0 - 3)

Y (optional) : T
A tensor that concats all the intermediate output values of the hidden. It has shape `[seq_length, num_directions, batch_size, hidden_size]`. It is optional if `output_sequence` is 0.
Y_h (optional) : T
The last output value of the hidden. It has shape `[num_directions, batch_size, hidden_size]`.
Y_c (optional) : T
The last output value of the cell. It has shape `[num_directions, batch_size, hidden_size]`.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
T1 : tensor(int32)
Constrain seq_lens to integer tensor.

LeakyRelu-1

LeakyRelu takes input data (Tensor) and an argument alpha, and produces one output data (Tensor) where the function f(x) = alpha * x for x < 0, f(x) = x for x >= 0, is applied to the data tensor elementwise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

alpha : float (default is 0.01)
Coefficient of leakage default to 0.01.
consumed_inputs : list of ints
legacy optimization attribute.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Less-1

Returns the tensor resulted from performing the less logical operation elementwise on the input tensors A and B.

If broadcasting is enabled, the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. See the doc of Add for a detailed description of the broadcasting rules.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int
If set, defines the broadcast dimensions.
broadcast : int (default is 0)
Enable broadcasting

Inputs

A : T
Left input tensor for the logical operator.
B : T
Right input tensor for the logical operator.

Outputs

C : T1
Result tensor.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrains input to float tensors.
T1 : tensor(bool)
Constrains output to boolean tensor.

Log-1

Calculates the natural log of the given input tensor, element-wise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs

input : T
Input tensor

Outputs

output : T
The natural log of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

LogSoftmax-1

The operator computes the logsoftmax (log of softmax) values for each layer in the batch of the given input. The input is a 2-D tensor (Tensor) of size (batch_size x input_feature_dimensions). The output tensor has the same shape and contains the logsoftmax values of the corresponding input.

Input does not need to explicitly be a 2D vector; rather, it will be coerced into one. For an arbitrary n-dimensional tensor input \in [a_0, a_1, ..., a_{k-1}, a_k, ..., a_{n-1}] and k is the axis provided, then input will be coerced into a 2-dimensional tensor with dimensions [a_0 * ... * a_{k-1}, a_k * ... * a_{n-1}]. For the default case where axis=1, this means the input tensor will be coerced into a 2D tensor of dimensions [a_0, a_1 * ... * a_{n-1}], where a_0 is often the batch size. In this situation, we must have a_0 = N and a_1 * ... * a_{n-1} = D. Each of these dimensions must be matched correctly, or else the operator will throw errors.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int (default is 1)
Describes the axis of the inputs when coerced to 2D; defaults to one because the 0th axis most likely describes the batch_size

Inputs

input : T
The input tensor that's coerced into a 2D matrix of size (NxD) as described above.

Outputs

output : T
The output values with the same shape as input tensor (the original size without coercion).

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Loop-1

Generic Looping construct. This loop has multiple termination conditions:

  1. Trip count. Iteration count specified at runtime. Set by specifying the input M. Optional. Set to empty string to omit. Note that a static trip count (specified at graph construction time) can be specified by passing in a constant node for input M.
  2. Loop termination condition. This is an input to the op that determines whether to run the first iteration and also a loop-carried dependency for the body graph. The body graph must yield a value for the condition variable, whether this input is provided or not.

This table summarizes the operating modes of this operator with equivalent C-style code:

  Operator inputs defined as (max_trip_count, condition_var).

  input ("", ""):
      for (int i=0; ; ++i) {
        cond = ... // Note this value is ignored, but is required in the body
      }

  input ("", cond) // Note this is analogous to a while loop
      bool cond = ...;
      for (int i=0; cond; ++i) {
        cond = ...;
      }

  input ("", 1) // Note this is analogous to a do-while loop
      bool cond = true
      for (int i=0; cond; ++i) {
        cond = ...;
      }

  input (trip_count, "") // Note this is analogous to a for loop
      int trip_count = ...
      for (int i=0; i < trip_count; ++i) {
        cond = ...; // ignored
      }

  input (trip_count, cond)
      int trip_count = ...;
      bool cond = ...;
      for (int i=0; i < trip_count && cond; ++i) {
        cond = ...;
      }

Sample usage - cond as well as trip count

  graph predict-net {
    %a = Constant[value = <Scalar Tensor [3]>]()
    %b = Constant[value = <Scalar Tensor [6]>]()
    %keepgoing = Constant[value = <Scalar Tensor [1]>]()
    %max_trip_count = Constant[value = <Scalar Tensor [10]>]()
    %keepgoing_out, %b_out, %user_defined_vals = Loop[body = <graph body-net>](%max_trip_count, %keepgoing, %b)
    return
  }

  graph body-net (
    %i[INT32, scalar]
    %keepgoing[BOOL, scalar]
    %b[INT32, scalar]
  ) {
    %my_local = Add(%a, %b)
    %b_out = Sub(%a, %b)
    %keepgoing_out = Greater(%my_local, %b_out)
    %user_defined_vals = Add(%b, %b)
    return %keepgoing_out, %b_out, %user_defined_vals
  }

Sample equivalent C code

  {
    /* User-defined code (enclosing scope) */
    int a = 3, b = 6;
    bool keepgoing = true; // Analogous to input cond
    /* End user-defined code */

    /* Implicitly-defined code */
    const int max_trip_count = 10; // Analogous to input M
    int user_defined_vals[]; // Imagine this is resizable
    /* End implicitly-defined code */
    for (int i=0; i < max_trip_count && keepgoing; ++i) {
      /* User-defined code (loop body) */
      int my_local = a + b; // Reading values in the enclosing scope is fine
      b = a - b; // writes fine if we specify b as a loop-carried dependency
      keepgoing = my_local > b; // keepgoing is a loop-carried dependency
      user_defined_vals[i] = b + b;
      /* End user-defined code */
    }
    // my_local = 123; // Can't do this. my_local was defined in the the body

    // These below values are live-out from the loop and therefore accessible
    b_out; user_defined_vals; keepgoing_out;
  }

There are several things of note in this code snippet:

  1. Values from the enclosing scope (i.e. variable a here) are in scope and can be referenced in the inputs of the loop.
  2. Any variables which you wish to make available in the enclosing scope (i.e. the variables b and keepgoing) must be declared as either loop-carried dependencies (both at the op inputs and output and at the body net input and output) or scan_outputs.
  3. Values created in the body cannot be accessed in the enclosing scope.

Note that the semantics of this op support "diagonal" or "wavefront" execution. (See Step 3 here for an example: https://devblogs.nvidia.com/optimizing-recurrent-neural-networks-cudnn-5/). Frontends should emit multi-layer RNNs as a series of While operators (with time being the inner looping dimension), with each successive layer consuming the scan_outputs from the previous layer, possibly going through several point-wise operators (e.g. dropout, residual connections, linear layer).

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

body : graph (required)
The graph run each iteration. It has 2+N inputs: (iteration_num, condition, loop carried dependencies...). It has 1+N+K outputs: (condition, loop carried dependencies..., scan_outputs...). Each scan_output is created by concatenating the value of the specified output value at the end of each iteration of the loop. It is an error if the dimensions or data type of these scan_outputs change across loop iterations.

Inputs (3 - ∞)

M (optional) : I
A maximum trip-count for the loop specified at runtime. Optional. Pass empty string to skip.
cond (optional) : B
A boolean termination condition. Optional. Pass empty string to skip.
v_initial (variadic, heterogeneous) : V
The initial values of any loop-carried dependencies (values that change across loop iterations)

Outputs (1 - ∞)

v_final_and_scan_outputs (variadic, heterogeneous) : V
Final N loop carried dependency values then K scan_outputs

Type Constraints

V : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
All Tensor types
I : tensor(int64)
tensor of int64, which should be a scalar.
B : tensor(bool)
tensor of bool, which should be a scalar.

LpNormalization-1

Given a matrix, apply Lp-normalization along the provided axis.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int (default is -1)
The axis on which to apply normalization, -1 mean last axis.
p : int (default is 2)
The order of the normalization, only 1 or 2 are supported.

Inputs

input : T
Input matrix

Outputs

output : T
Matrix after normalization

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

LpPool-1

LpPool consumes an input tensor X and applies Lp pooling across the the tensor according to kernel sizes, stride sizes, and pad lengths. Lp pooling consisting of computing the Lp norm on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

auto_pad : string (default is NOTSET)
auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding. DEPRECATION NOTE: auto_pad is only intended to support legacy uses, and for framework authors, one is explicitly encouraged to use explicit padding specified in the pads attribute.
kernel_shape : list of ints
The size of the kernel along each axis.
p : float (default is 2.0)
p value of the Lp norm used to pool over the input data, default is 2.0.
pads : list of ints
Padding for the beginning and ending along each axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`. This attribute cannot be used simultaneously with auto_pad attribute.
strides : list of ints
Stride along each axis.

Inputs

X : T
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 dimension are in the form of (N x C x D1 x D2 ... Dn), where N is the batch size.

Outputs

Y : T
Output data tensor from Lp pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

MatMul-1

Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Inputs

A : T
N-dimensional matrix A
B : T
N-dimensional matrix B

Outputs

Y : T
Matrix multiply results from A * B

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Max-1

Element-wise max of each of the input tensors. All inputs and outputs must have the same shape and data type.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs (1 - ∞)

data_0 (variadic) : T
List of tensors for Max.

Outputs

max : T
Output tensor. Same dimension as inputs.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

MaxPool-1

MaxPool consumes an input tensor X and applies max pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. max pooling consisting of computing the max on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following:

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - kernel_spatial_shape[i]) / strides_spatial_shape[i] + 1)

* pad_shape[i] is sum of pads along axis i

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - kernel_spatial_shape[i] + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + kernel_spatial_shape[i] - input_spatial_shape[i]

The output of each pooling window is maximum number of elements exclude pad.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

auto_pad : string (default is NOTSET)
auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding.
kernel_shape : list of ints (required)
The size of the kernel along each axis.
pads : list of ints
Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.
strides : list of ints
Stride along each spatial axis.

Inputs

X : T
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. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE ...].

Outputs

Y : T
Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

MaxRoiPool-1

ROI max pool consumes an input tensor X and region of interests (RoIs) to apply max pooling across each RoI, to produce output 4-D tensor of shape (num_rois, channels, pooled_shape[0], pooled_shape[1]).

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

pooled_shape : list of ints (required)
ROI pool output shape (height, width).
spatial_scale : float (default is 1.0)
Multiplicative spatial scale factor to translate ROI coordinates from their input scale to the scale used when pooling.

Inputs

X : T
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.
rois : T
RoIs (Regions of Interest) to pool over. Should be a 2-D tensor of shape (num_rois, 5) given as [[batch_id, x1, y1, x2, y2], ...].

Outputs

Y : T
RoI pooled output 4-D tensor of shape (num_rois, channels, pooled_shape[0], pooled_shape[1]).

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Mean-1

Element-wise mean of each of the input tensors. All inputs and outputs must have the same shape and data type.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs (1 - ∞)

data_0 (variadic) : T
List of tensors for Mean.

Outputs

mean : T
Output tensor. Same dimension as inputs.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Min-1

Element-wise min of each of the input tensors. All inputs and outputs must have the same shape and data type.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs (1 - ∞)

data_0 (variadic) : T
List of tensors for Min

Outputs

min : T
Output tensor. Same dimension as inputs.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Mul-1

Performs element-wise binary multiplication (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor's shape. The starting of the mutually equal shape is specified by the argument "axis", and if it is not set, suffix matching is assumed. 1-dim expansion doesn't work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor
shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor
shape(A) = (2, 3, 4, 5), shape(B) = (5,)
shape(A) = (2, 3, 4, 5), shape(B) = (4, 5)
shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1
shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int
If set, defines the broadcast dimensions. See doc for details.
broadcast : int (default is 0)
Pass 1 to enable broadcasting
consumed_inputs : list of ints
legacy optimization attribute.

Inputs

A : T
First operand, should share the type with the second operand.
B : T
Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

C : T
Result, has same dimensions and type as A

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Neg-1

Neg takes one input data (Tensor) and produces one output data (Tensor) where each element flipped sign, y = -x, is applied to the tensor elementwise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Not-1

Returns the negation of the input tensor element-wise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(bool)
Constrains input/output to boolean tensors.

Or-1

Returns the tensor resulted from performing the or logical operation elementwise on the input tensors A and B.

If broadcasting is enabled, the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. See the doc of Add for a detailed description of the broadcasting rules.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int
If set, defines the broadcast dimensions.
broadcast : int (default is 0)
Enable broadcasting

Inputs

A : T
Left input tensor for the logical operator.
B : T
Right input tensor for the logical operator.

Outputs

C : T1
Result tensor.

Type Constraints

T : tensor(bool)
Constrains input to boolean tensor.
T1 : tensor(bool)
Constrains output to boolean tensor.

PRelu-1

PRelu takes input data (Tensor) and slope tensor as input, and produces one output data (Tensor) where the function f(x) = slope * x for x < 0, f(x) = x for x >= 0., is applied to the data tensor elementwise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs

X : T
Input tensor
slope : T
Slope tensor. If `Slope` is of size 1, the value is sharedacross different channels

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Pad-1

Given data tensor, paddings, mode, and value. Example: Insert 0 paddings to the beginning of the second dimension. data = [ [1.0, 1.2], [2.3, 3.4], [4.5, 5.7], ] paddings = [0, 0, 2, 0] output = [ [ [0.0, 0.0, 1.0, 1.2], [0.0, 0.0, 2.3, 3.4], [0.0, 0.0, 4.5, 5.7], ], ]

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

mode : string (default is constant)
Three modes: constant(default), reflect, edge
paddings : list of ints (required)
List of integers indicate the padding element count at the beginning and end of each axis, for 2D it is the number of pixel. `paddings` rank should be double of the input's rank. `paddings` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`.
value : float (default is 0.0)
One float, indicates the value to be filled, default is 0

Inputs

data : T
Input tensor.

Outputs

output : T
Tensor after padding.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Pow-1

Pow takes input data (Tensor) and exponent Tensor, and produces one output data (Tensor) where the function f(x) = x^exponent, is applied to the data tensor elementwise.

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor's shape. The starting of the mutually equal shape is specified by the argument "axis", and if it is not set, suffix matching is assumed. 1-dim expansion doesn't work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor
shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor
shape(A) = (2, 3, 4, 5), shape(B) = (5,)
shape(A) = (2, 3, 4, 5), shape(B) = (4, 5)
shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1
shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int
If set, defines the broadcast dimensions. See doc for details.
broadcast : int (default is 0)
Pass 1 to enable broadcasting

Inputs

X : T
Input tensor of any shape, base of the exponent.
Y : T
Input tensor of any shape broadcastable to X shape, the exponent component.

Outputs

Z : T
Output tensor (same size as X)

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

RNN-1

Computes an one-layer simple RNN. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

X - input tensor

i - input gate

t - time step (t-1 means previous time step)

Wi - W parameter weight matrix for input gate

Ri - R recurrence weight matrix for input gate

Wbi - W parameter bias vector for input gate

Rbi - R parameter bias vector for input gate

WBi - W parameter weight matrix for backward input gate

RBi - R recurrence weight matrix for backward input gate

WBbi - WR bias vectors for backward input gate

RBbi - RR bias vectors for backward input gate

H - Hidden state

num_directions - 2 if direction == bidirectional else 1

Activation functions:

Relu(x)                - max(0, x)

Tanh(x)                - (1 - e^{-2x})/(1 + e^{-2x})

Sigmoid(x)             - 1/(1 + e^{-x})

(NOTE: Below are optional)

Affine(x)              - alpha*x + beta

LeakyRelu(x)           - x if x >= 0 else alpha * x

ThresholdedRelu(x)     - x if x >= alpha else 0

ScaledTanh(x)          - alpha*Tanh(beta*x)

HardSigmoid(x)         - min(max(alpha*x + beta, 0), 1)

Elu(x)                 - x if x >= 0 else alpha*(e^x - 1)

Softsign(x)            - x/(1 + |x|)

Softplus(x)            - log(1 + e^x)

Equations (Default: f=Tanh):

- Ht = f(Xt*(Wi^T) + Ht-1*Ri + Wbi + Rbi)

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

activation_alpha : list of floats
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.For example with LeakyRelu, the default alpha is 0.01.
activation_beta : list of floats
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.
activations : list of strings (default is ['Tanh', 'Tanh'])
One (or two if bidirectional) activation function for input gate. The activation function must be one of the activation functions specified above. Optional: Default `Tanh` if not specified.
clip : float
Cell clip threshold. Clipping bounds the elements of a tensor in the range of [-threshold, +threshold] and is applied to the input of activations. No clip if not specified.
direction : string (default is forward)
Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional.
hidden_size : int
Number of neurons in the hidden layer
output_sequence : int (default is 0)
The sequence output for the hidden is optional if 0. Default 0.

Inputs (3 - 6)

X : T
The input sequences packed (and potentially padded) into one 3-D tensor with the shape of `[seq_length, batch_size, input_size]`.
W : T
The weight tensor for input gate. Concatenation of `Wi` and `WBi` (if bidirectional). The tensor has shape `[num_directions, hidden_size, input_size]`.
R : T
The recurrence weight tensor. Concatenation of `Ri` and `RBi` (if bidirectional). The tensor has shape `[num_directions, hidden_size, hidden_size]`.
B (optional) : T
The bias tensor for input gate. Concatenation of `[Wbi, Rbi]` and `[WBbi, RBbi]` (if bidirectional). The tensor has shape `[num_directions, 2*hidden_size]`. Optional: If not specified - assumed to be 0.
sequence_lens (optional) : T1
Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length `seq_length`. It has shape `[batch_size]`.
initial_h (optional) : T
Optional initial value of the hidden. If not specified - assumed to be 0. It has shape `[num_directions, batch_size, hidden_size]`.

Outputs (0 - 2)

Y (optional) : T
A tensor that concats all the intermediate output values of the hidden. It has shape `[seq_length, num_directions, batch_size, hidden_size]`. It is optional if `output_sequence` is 0.
Y_h (optional) : T
The last output value of the hidden. It has shape `[num_directions, batch_size, hidden_size]`.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
T1 : tensor(int32)
Constrain seq_lens to integer tensor.

RandomNormal-1

Generate a tensor with random values drawn from a normal distribution. The shape of the tensor is specified by the shape argument and the parameter of the normal distribution specified by mean and scale.

The data type is specified by the 'dtype' argument. The 'dtype' argument must be one of the data types specified in the 'DataType' enum field in the TensorProto message.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

dtype : int (default is 1)
The data type for the elements of the output tensor. Default is TensorProto::FLOAT.
mean : float (default is 0.0)
The mean of the normal distribution.
scale : float (default is 1.0)
The standard deviation of the normal distribution.
seed : float
(Optional) Seed to the random generator, if not specified we will auto generate one.
shape : list of ints (required)
The shape of the output tensor.

Inputs

Outputs

output : T
Output tensor of random values drawn from normal distribution

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain output types to float tensors.

RandomNormalLike-1

Generate a tensor with random values drawn from a normal distribution. The shape of the output tensor is copied from the shape of the input tensor, and the parameters of the normal distribution are specified by mean and scale.

The data type is specified by the 'dtype' argument, or copied from the input tensor if not provided. The 'dtype' argument must be one of the data types specified in the 'DataType' enum field in the TensorProto message, and be valid as an output type.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

dtype : int
(Optional) The data type for the elements of the output tensor, if not specified, we will use the data type of the input tensor.
mean : float (default is 0.0)
The mean of the normal distribution.
scale : float (default is 1.0)
The standard deviation of the normal distribution.
seed : float
(Optional) Seed to the random generator, if not specified we will auto generate one.

Inputs

input : T1
Input tensor to copy shape and optionally type information from.

Outputs

output : T2
Output tensor of random values drawn from normal distribution

Type Constraints

T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain to any tensor type. If the dtype attribute is not provided this must be a valid output type.
T2 : tensor(float16), tensor(float), tensor(double)
Constrain output types to float tensors.

RandomUniform-1

Generate a tensor with random values drawn from a uniform distribution. The shape of the tensor is specified by the shape argument and the range by low and high.

The data type is specified by the 'dtype' argument. The 'dtype' argument must be one of the data types specified in the 'DataType' enum field in the TensorProto message.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

dtype : int (default is 1)
The data type for the elements of the output tensor. If not specified, default is TensorProto::FLOAT.
high : float (default is 1.0)
Upper boundary of the output values.
low : float (default is 0.0)
Lower boundary of the output values.
seed : float
(Optional) Seed to the random generator, if not specified we will auto generate one.
shape : list of ints (required)
The shape of the output tensor.

Inputs

Outputs

output : T
Output tensor of random values drawn from uniform distribution

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain output types to float tensors.

RandomUniformLike-1

Generate a tensor with random values drawn from a uniform distribution. The shape of the output tensor is copied from the shape of the input tensor, and the parameters of the uniform distribution are specified by low and high.

The data type is specified by the 'dtype' argument, or copied from the input tensor if not provided. The 'dtype' argument must be one of the data types specified in the 'DataType' enum field in the TensorProto message and be valid as an output type.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

dtype : int
(Optional) The data type for the elements of the output tensor, if not specified, we will use the data type of the input tensor.
high : float (default is 1.0)
Upper boundary of the output values.
low : float (default is 0.0)
Lower boundary of the output values.
seed : float
(Optional) Seed to the random generator, if not specified we will auto generate one.

Inputs

input : T1
Input tensor to copy shape and optionally type information from.

Outputs

output : T2
Output tensor of random values drawn from uniform distribution

Type Constraints

T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain to any tensor type. If the dtype attribute is not provided this must be a valid output type.
T2 : tensor(float16), tensor(float), tensor(double)
Constrain output types to float tensors.

Reciprocal-1

Reciprocal takes one input data (Tensor) and produces one output data (Tensor) where the reciprocal is, y = 1/x, is applied to the tensor elementwise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

ReduceL1-1

Computes the L1 norm of the input tensor's element along the provided axes. The resulted tensor has the same rank as the input if keepdims equal 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy default keepdims to False instead of True.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axes : list of ints
A list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor.
keepdims : int (default is 1)
Keep the reduced dimension or not, default 1 mean keep reduced dimension.

Inputs

data : T
An input tensor.

Outputs

reduced : T
Reduced output tensor.

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

ReduceL2-1

Computes the L2 norm of the input tensor's element along the provided axes. The resulted tensor has the same rank as the input if keepdims equal 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy default keepdims to False instead of True.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axes : list of ints
A list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor.
keepdims : int (default is 1)
Keep the reduced dimension or not, default 1 mean keep reduced dimension.

Inputs

data : T
An input tensor.

Outputs

reduced : T
Reduced output tensor.

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

ReduceLogSum-1

Computes the log sum of the input tensor's element along the provided axes. The resulted tensor has the same rank as the input if keepdims equal 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy default keepdims to False instead of True.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axes : list of ints
A list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor.
keepdims : int (default is 1)
Keep the reduced dimension or not, default 1 mean keep reduced dimension.

Inputs

data : T
An input tensor.

Outputs

reduced : T
Reduced output tensor.

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

ReduceLogSumExp-1

Computes the log sum exponent of the input tensor's element along the provided axes. The resulted tensor has the same rank as the input if keepdims equal 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy default keepdims to False instead of True.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axes : list of ints
A list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor.
keepdims : int (default is 1)
Keep the reduced dimension or not, default 1 mean keep reduced dimension.

Inputs

data : T
An input tensor.

Outputs

reduced : T
Reduced output tensor.

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

ReduceMax-1

Computes the max of the input tensor's element along the provided axes. The resulted tensor has the same rank as the input if keepdims equal 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy default keepdims to False instead of True.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axes : list of ints
A list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor.
keepdims : int (default is 1)
Keep the reduced dimension or not, default 1 mean keep reduced dimension.

Inputs

data : T
An input tensor.

Outputs

reduced : T
Reduced output tensor.

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

ReduceMean-1

Computes the mean of the input tensor's element along the provided axes. The resulted tensor has the same rank as the input if keepdims equal 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy default keepdims to False instead of True.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axes : list of ints
A list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor.
keepdims : int (default is 1)
Keep the reduced dimension or not, default 1 mean keep reduced dimension.

Inputs

data : T
An input tensor.

Outputs

reduced : T
Reduced output tensor.

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

ReduceMin-1

Computes the min of the input tensor's element along the provided axes. The resulted tensor has the same rank as the input if keepdims equal 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy default keepdims to False instead of True.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axes : list of ints
A list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor.
keepdims : int (default is 1)
Keep the reduced dimension or not, default 1 mean keep reduced dimension.

Inputs

data : T
An input tensor.

Outputs

reduced : T
Reduced output tensor.

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

ReduceProd-1

Computes the product of the input tensor's element along the provided axes. The resulted tensor has the same rank as the input if keepdims equal 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy default keepdims to False instead of True.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axes : list of ints
A list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor.
keepdims : int (default is 1)
Keep the reduced dimension or not, default 1 mean keep reduced dimension.

Inputs

data : T
An input tensor.

Outputs

reduced : T
Reduced output tensor.

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

ReduceSum-1

Computes the sum of the input tensor's element along the provided axes. The resulted tensor has the same rank as the input if keepdims equal 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy default keepdims to False instead of True.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axes : list of ints
A list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor.
keepdims : int (default is 1)
Keep the reduced dimension or not, default 1 mean keep reduced dimension.

Inputs

data : T
An input tensor.

Outputs

reduced : T
Reduced output tensor.

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

ReduceSumSquare-1

Computes the sum square of the input tensor's element along the provided axes. The resulted tensor has the same rank as the input if keepdims equal 1. If keepdims equal 0, then the resulted tensor have the reduced dimension pruned.

The above behavior is similar to numpy, with the exception that numpy default keepdims to False instead of True.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axes : list of ints
A list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor.
keepdims : int (default is 1)
Keep the reduced dimension or not, default 1 mean keep reduced dimension.

Inputs

data : T
An input tensor.

Outputs

reduced : T
Reduced output tensor.

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

Relu-1

Relu takes one input data (Tensor) and produces one output data (Tensor) where the rectified linear function, y = max(0, x), is applied to the tensor elementwise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Reshape-1

Reshape the input tensor similar to numpy.reshape. It takes a tensor as input and an argument shape. It outputs the reshaped tensor. At most one dimension of the new shape can be -1. In this case, the value is inferred from the size of the tensor and the remaining dimensions. A dimension could also be 0, in which case the actual dimension value is unchanged (i.e. taken from the input tensor).

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.
shape : list of ints
New shape

Inputs

data : T
An input tensor.

Outputs

reshaped : T
Reshaped data.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Selu-1

Selu takes one input data (Tensor) and produces one output data (Tensor) where the scaled exponential linear unit function, y = gamma * (alpha * e^x - alpha) for x <= 0, y = gamma * x for x > 0, is applied to the tensor elementwise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

alpha : float (default is 1.6732)
Coefficient of SELU default to 1.6732.
consumed_inputs : list of ints
legacy optimization attribute.
gamma : float (default is 1.0507)
Coefficient of SELU default to 1.0507.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Shape-1

Takes a tensor as input and outputs an 1D int64 tensor containing the shape of the input tensor.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Inputs

data : T
An input tensor.

Outputs

shape : T1
Shape of the input tensor

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Input tensor can be of arbitrary type.
T1 : tensor(int64)
Constrain output to int64 tensor.

Sigmoid-1

Sigmoid takes one input data (Tensor) and produces one output data (Tensor) where the sigmoid function, y = 1 / (1 + exp(-x)), is applied to the tensor elementwise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Size-1

Takes a tensor as input and outputs a int64 scalar that equals to the total number of elements of the input tensor.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Inputs

data : T
An input tensor.

Outputs

size : T1
Total number of elements of the input tensor

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Input tensor can be of arbitrary type.
T1 : tensor(int64)
Constrain output to int64 tensor, which should be a scalar though.

Slice-1

Produces a slice of the input tensor along multiple axes. Similar to numpy: https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html Slices uses axes, starts and ends attributes to specify the start and end dimension for each axis in the list of axes, it uses this information to slice the input data tensor. If a negative value is passed for any of the start or end indices, it represent number of elements before the end of that dimension. If the value passed to start or end is larger than the n (the number of elements in this dimension), it represents n. For slicing to the end of a dimension with unknown size, it is recommended to pass in INT_MAX. If axes are omitted, they are set to [0, ..., ndim-1]. Example 1: data = [ [1, 2, 3, 4], [5, 6, 7, 8], ] axes = [0, 1] starts = [1, 0] ends = [2, 3] result = [ [5, 6, 7], ] Example 2: data = [ [1, 2, 3, 4], [5, 6, 7, 8], ] starts = [0, 1] ends = [-1, 1000] result = [ [2, 3, 4], ]

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axes : list of ints
Axes that `starts` and `ends` apply to. It's optional. If not present, will be treated as [0, 1, ..., len(`starts`) - 1].
ends : list of ints (required)
Ending indices (exclusive) of corresponding axis in axes`
starts : list of ints (required)
Starting indices of corresponding axis in `axes`

Inputs

data : T
Tensor of data to extract slices from.

Outputs

output : T
Sliced data tensor.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output types to all tensor types.

Softmax-1

The operator computes the softmax (normalized exponential) values for each layer in the batch of the given input. The input is a 2-D tensor (Tensor) of size (batch_size x input_feature_dimensions). The output tensor has the same shape and contains the softmax values of the corresponding input.

Input does not need to explicitly be a 2D vector; rather, it will be coerced into one. For an arbitrary n-dimensional tensor input \in [a_0, a_1, ..., a_{k-1}, a_k, ..., a_{n-1}] and k is the axis provided, then input will be coerced into a 2-dimensional tensor with dimensions [a_0 * ... * a_{k-1}, a_k * ... * a_{n-1}]. For the default case where axis=1, this means the input tensor will be coerced into a 2D tensor of dimensions [a_0, a_1 * ... * a_{n-1}], where a_0 is often the batch size. In this situation, we must have a_0 = N and a_1 * ... * a_{n-1} = D. Each of these dimensions must be matched correctly, or else the operator will throw errors.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int (default is 1)
Describes the axis of the inputs when coerced to 2D; defaults to one because the 0th axis most likely describes the batch_size

Inputs

input : T
The input tensor that's coerced into a 2D matrix of size (NxD) as described above.

Outputs

output : T
The output values with the same shape as input tensor (the original size without coercion).

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Softplus-1

Softplus takes one input data (Tensor) and produces one output data (Tensor) where the softplus function, y = ln(exp(x) + 1), is applied to the tensor elementwise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Inputs

X : T
1D input tensor

Outputs

Y : T
1D input tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Softsign-1

Calculates the softsign (x/(1+|x|)) of the given input tensor element-wise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The softsign (x/(1+|x|)) values of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

SpaceToDepth-1

SpaceToDepth rearranges blocks of spatial data into depth. More specifically, this op outputs a copy of the input tensor where values from the height and width dimensions are moved to the depth dimension.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

blocksize : int (required)
Blocks of [blocksize, blocksize] are moved.

Inputs

input : T
Input tensor of [N,C,H,W], where N is the batch axis, C is the channel or depth, H is the height and W is the width.

Outputs

output : T
Output tensor of [N, C * blocksize * blocksize, H/blocksize, W/blocksize].

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output types to all tensor types.

Split-1

Split a tensor into a list of tensors, along the specified 'axis'. The lengths of the split can be specified using argument 'axis' or optional second input blob to the operator. Otherwise, the tensor is split to equal sized parts.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int
Which axis to split on
split : list of ints
length of each output

Inputs (1 - 2)

input : T
The tensor to split
split (optional) : T
Optional list of output lengths (see also arg 'split')

Outputs (1 - ∞)

outputs... (variadic) : T
One or more outputs forming list of tensors after splitting

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input types to float tensors.

Sqrt-1

Square root takes one input data (Tensor) and produces one output data (Tensor) where the square root is, y = x^0.5, is applied to the tensor elementwise. If x is negative, then it will return NaN.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Squeeze-1

Remove single-dimensional entries from the shape of a tensor. Takes a parameter axes with a list of axes to squeeze. If axes is not provided, all the single dimensions will be removed from the shape. If an axis is selected with shape entry not equal to one, an error is raised.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axes : list of ints
List of non-negative integers, indicate the dimensions to squeeze.

Inputs

data : T
Tensors with at least max(dims) dimensions.

Outputs

squeezed : T
Reshaped tensor with same data as input.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output types to all tensor types.

Sub-1

Performs element-wise binary subtraction (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor's shape. The starting of the mutually equal shape is specified by the argument "axis", and if it is not set, suffix matching is assumed. 1-dim expansion doesn't work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor
shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor
shape(A) = (2, 3, 4, 5), shape(B) = (5,)
shape(A) = (2, 3, 4, 5), shape(B) = (4, 5)
shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1
shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int
If set, defines the broadcast dimensions. See doc for details.
broadcast : int (default is 0)
Pass 1 to enable broadcasting
consumed_inputs : list of ints
legacy optimization attribute.

Inputs

A : T
First operand, should share the type with the second operand.
B : T
Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

C : T
Result, has same dimensions and type as A

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Sum-1

Element-wise sum of each of the input tensors. All inputs and outputs must have the same shape and data type.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs (1 - ∞)

data_0 (variadic) : T
List of tensors for Sum.

Outputs

sum : T
Output tensor. Same dimension as inputs.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Tanh-1

Calculates the hyperbolic tangent of the given input tensor element-wise.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

consumed_inputs : list of ints
legacy optimization attribute.

Inputs

input : T
1-D input tensor

Outputs

output : T
The hyperbolic tangent values of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Tile-1

Repeat the elements of a tensor along an axis.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Inputs

input : T
Input tensor of any shape.
tiles : T
Number of repeated copies to make of the input tensor.
axis : T
Axis along which to repeat.

Outputs

output : T
Output tensor of same shape and type as input.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input types to float tensors.
T1 : tensor(int64)
Constrain tiles and axis's type to int64 tensors.

TopK-1

Retrieve the top-K elements along a specified axis. Given an input tensor of shape [a_1, a_2, ..., a_n, r] and integer argument k, return two outputs: -Value tensor of shape [a_1, a_2, ..., a_{axis-1}, k, a_{axis+1}, ... a_n] which contains the values of the top k elements along the specified axis -Index tensor of shape [a_1, a_2, ..., a_{axis-1}, k, a_{axis+1}, ... a_n] which contains the indices of the top k elements (original indices from the input tensor). Given two equivalent values, this operator uses the indices along the axis as a tiebreaker. That is, the element with the lower index will appear first.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int (default is -1)
Dimension on which to do the sort.
k : int (required)
Number of top elements to retrieve

Inputs

X : T
Tensor of shape [a_1, a_2, ..., a_n, r]

Outputs

Values : T
Tensor of shape [a_1, a_2, ..., a_{axis-1}, k, a_{axis+1}, ... a_n] containing top K values from the input tensor
Indices : I
Tensor of shape [a_1, a_2, ..., a_{axis-1}, k, a_{axis+1}, ... a_n] containing the corresponding input tensor indices for the top K values.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
I : tensor(int64)
Constrain index tensor to int64

Transpose-1

Transpose the input tensor similar to numpy.transpose. For example, when perm=(1, 0, 2), given an input tensor of shape (1, 2, 3), the output shape will be (2, 1, 3).

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

perm : list of ints
A list of integers. By default, reverse the dimensions, otherwise permute the axes according to the values given.

Inputs

data : T
An input tensor.

Outputs

transposed : T
Transposed output.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output types to all tensor types.

Unsqueeze-1

Insert single-dimensional entries to the shape of a tensor. Takes one required argument axes, a list of dimensions that will be inserted. Dimension indices in axes are as seen in the output tensor. For example: Given a tensor such that tensor with shape [3, 4, 5], then Unsqueeze(tensor, axes=[0, 4]) has shape [1, 3, 4, 5, 1]

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axes : list of ints (required)
List of non-negative integers, indicate the dimensions to be inserted

Inputs

data : T
Original tensor

Outputs

expanded : T
Reshaped tensor with same data as input.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output types to all tensor types.

Upsample-1

Upsample the input tensor. The width and height of the output tensor are: output_width = floor(input_width * width_scale), output_height = floor(input_height * height_scale). Example: Given data tensor, width_scale, height_scale, mode, Upsample the input 4-D tensor in nearest mode: data = [[[ [1, 2], [3, 4] ]]] width_scale = 2 height_scale = 2 mode = "nearest" output = [[[ [1, 1, 2, 2], [1, 1, 2, 2], [3, 3, 4, 4], [3, 3, 4, 4] ]]]

Version

No versioning maintained for experimental ops.

Attributes

height_scale : float (required)
The scale along height dimension. It takes value greater than or equal to 1.
mode : string (default is nearest)
Two interpolation modes: nearest(default), bilinear
width_scale : float (required)
The scale along width dimension. It takes value greater than or equal to 1.

Inputs

X : T
4-D tensor, [N,C,H,W]

Outputs

Y : T
4-D tensor after resizing, [N,C,H,W]

Type Constraints

T : tensor(bool), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain output types to bool, int32, int64, float16, float, double tensors.

Xor-1

Returns the tensor resulted from performing the xor logical operation elementwise on the input tensors A and B.

If broadcasting is enabled, the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. See the doc of Add for a detailed description of the broadcasting rules.

Version

This version of the operator has been available since version 1 of the default ONNX operator set.

Attributes

axis : int
If set, defines the broadcast dimensions.
broadcast : int (default is 0)
Enable broadcasting

Inputs

A : T
Left input tensor for the logical operator.
B : T
Right input tensor for the logical operator.

Outputs

C : T1
Result tensor.

Type Constraints

T : tensor(bool)
Constrains input to boolean tensor.
T1 : tensor(bool)
Constrains output to boolean tensor.

Version 2 of the default ONNX operator set

GlobalLpPool-2

GlobalLpPool consumes an input tensor X and applies lp pool pooling across the values in the same channel. This is equivalent to LpPool with kernel size equal to the spatial dimension of input tensor.

Version

This version of the operator has been available since version 2 of the default ONNX operator set.

Attributes

p : int (default is 2)
p value of the Lp norm used to pool over the input data.

Inputs

X : T
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.

Outputs

Y : T
Output data tensor from pooling across the input tensor. The output tensor has the same rank as the input. The first two dimensions of output shape are the same as the input (N x C), while the other dimensions are all 1.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

LpPool-2

LpPool consumes an input tensor X and applies Lp pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. Lp pooling consisting of computing the Lp norm on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing.

Version

This version of the operator has been available since version 2 of the default ONNX operator set.

Attributes

auto_pad : string (default is NOTSET)
auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding.
kernel_shape : list of ints (required)
The size of the kernel along each axis.
p : int (default is 2)
p value of the Lp norm used to pool over the input data.
pads : list of ints
Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.
strides : list of ints
Stride along each spatial axis.

Inputs

X : T
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.

Outputs

Y : T
Output data tensor from Lp pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Pad-2

Given data tensor, pads, mode, and value. Example: Insert 0 pads to the beginning of the second dimension. data = [ [1.0, 1.2], [2.3, 3.4], [4.5, 5.7], ] pads = [0, 2, 0, 0] output = [ [ [0.0, 0.0, 1.0, 1.2], [0.0, 0.0, 2.3, 3.4], [0.0, 0.0, 4.5, 5.7], ], ]

Version

This version of the operator has been available since version 2 of the default ONNX operator set.

Attributes

mode : string (default is constant)
Three modes: constant(default), reflect, edge
pads : list of ints (required)
List of integers indicating the number of padding elements to add or remove (if negative) at the beginning and end of each axis. For 2D it is the number of pixels. `pads` rank should be double of the input's rank. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`.
value : float (default is 0.0)
One float, indicates the value to be filled.

Inputs

data : T
Input tensor.

Outputs

output : T
Tensor after padding.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Split-2

Split a tensor into a list of tensors, along the specified 'axis'. Lengths of the parts can be specified using argument 'split'. Otherwise, the tensor is split to equal sized parts.

Version

This version of the operator has been available since version 2 of the default ONNX operator set.

Attributes

axis : int (default is 0)
Which axis to split on.
split : list of ints
length of each output

Inputs

input : T
The tensor to split

Outputs (1 - ∞)

outputs (variadic) : T
One or more outputs forming list of tensors after splitting

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output types to all tensor types.

Version 3 of the default ONNX operator set

GRU-3

Computes an one-layer GRU. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

X - input tensor

z - update gate

r - reset gate

h - hidden gate

t - time step (t-1 means previous time step)

W[zrh] - W parameter weight matrix for update, reset, and hidden gates

R[zrh] - R recurrence weight matrix for update, reset, and hidden gates

Wb[zrh] - W bias vectors for update, reset, and hidden gates

Rb[zrh] - R bias vectors for update, reset, and hidden gates

WB[zrh] - W parameter weight matrix for backward update, reset, and hidden gates

RB[zrh] - R recurrence weight matrix for backward update, reset, and hidden gates

WBb[zrh] - W bias vectors for backward update, reset, and hidden gates

RBb[zrh] - R bias vectors for backward update, reset, and hidden gates

H - Hidden state

num_directions - 2 if direction == bidirectional else 1

Activation functions:

Relu(x)                - max(0, x)

Tanh(x)                - (1 - e^{-2x})/(1 + e^{-2x})

Sigmoid(x)             - 1/(1 + e^{-x})

(NOTE: Below are optional)

Affine(x)              - alpha*x + beta

LeakyRelu(x)           - x if x >= 0 else alpha * x

ThresholdedRelu(x)     - x if x >= alpha else 0

ScaledTanh(x)          - alpha*Tanh(beta*x)

HardSigmoid(x)         - min(max(alpha*x + beta, 0), 1)

Elu(x)                 - x if x >= 0 else alpha*(e^x - 1)

Softsign(x)            - x/(1 + |x|)

Softplus(x)            - log(1 + e^x)

Equations (Default: f=Sigmoid, g=Tanh):

- zt = f(Xt*(Wz^T) + Ht-1*Rz + Wbz + Rbz)

- rt = f(Xt*(Wr^T) + Ht-1*Rr + Wbr + Rbr)

- ht = g(Xt*(Wh^T) + (rt (.) Ht-1)*Rh + Rbh + Wbh) # default, when linear_before_reset = 0

- ht = g(Xt*(Wh^T) + (rt (.) (Ht-1*Rh + Rbh) + Wbh) # when linear_before_reset != 0

- Ht = (1 - zt) (.) ht + zt (.) Ht-1

Version

This version of the operator has been available since version 3 of the default ONNX operator set.

Attributes

activation_alpha : list of floats
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.For example with LeakyRelu, the default alpha is 0.01.
activation_beta : list of floats
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.
activations : list of strings
A list of 2 (or 4 if bidirectional) activation functions for update, reset, and hidden gates. The activation functions must be one of the activation functions specified above. Optional: See the equations for default if not specified.
clip : float
Cell clip threshold. Clipping bounds the elements of a tensor in the range of [-threshold, +threshold] and is applied to the input of activations. No clip if not specified.
direction : string (default is forward)
Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional.
hidden_size : int
Number of neurons in the hidden layer
linear_before_reset : int (default is 0)
When computing the output of the hidden gate, apply the linear transformation before multiplying by the output of the reset gate.
output_sequence : int (default is 0)
The sequence output for the hidden is optional if 0. Default 0.

Inputs (3 - 6)

X : T
The input sequences packed (and potentially padded) into one 3-D tensor with the shape of `[seq_length, batch_size, input_size]`.
W : T
The weight tensor for the gates. Concatenation of `W[zrh]` and `WB[zrh]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 3*hidden_size, input_size]`.
R : T
The recurrence weight tensor. Concatenation of `R[zrh]` and `RB[zrh]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 3*hidden_size, hidden_size]`.
B (optional) : T
The bias tensor for the gates. Concatenation of `[Wb[zrh], Rb[zrh]]` and `[WBb[zrh], RBb[zrh]]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 6*hidden_size]`. Optional: If not specified - assumed to be 0
sequence_lens (optional) : T1
Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length `seq_length`. It has shape `[batch_size]`.
initial_h (optional) : T
Optional initial value of the hidden. If not specified - assumed to be 0. It has shape `[num_directions, batch_size, hidden_size]`.

Outputs (0 - 2)

Y (optional) : T
A tensor that concats all the intermediate output values of the hidden. It has shape `[seq_length, num_directions, batch_size, hidden_size]`. It is optional if `output_sequence` is 0.
Y_h (optional) : T
The last output value of the hidden. It has shape `[num_directions, batch_size, hidden_size]`.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
T1 : tensor(int32)
Constrain seq_lens to integer tensor.

Version 4 of the default ONNX operator set

Concat-4

Concatenate a list of tensors into a single tensor

Version

This version of the operator has been available since version 4 of the default ONNX operator set.

Attributes

axis : int (required)
Which axis to concat on

Inputs (1 - ∞)

inputs (variadic) : T
List of tensors for concatenation

Outputs

concat_result : T
Concatenated tensor

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain output types to any tensor type.

Version 5 of the default ONNX operator set

Reshape-5

Reshape the input tensor similar to numpy.reshape. First input is the data tensor, second input is a shape tensor which specifies the output shape. It outputs the reshaped tensor. At most one dimension of the new shape can be -1. In this case, the value is inferred from the size of the tensor and the remaining dimensions. A dimension could also be 0, in which case the actual dimension value is unchanged (i.e. taken from the input tensor).

Version

This version of the operator has been available since version 5 of the default ONNX operator set.

Inputs

data : T
An input tensor.
shape : tensor(int64)
Specified shape for output.

Outputs

reshaped : T
Reshaped data.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output types to all tensor types.

Version 6 of the default ONNX operator set

Abs-6

Absolute takes one input data (Tensor) and produces one output data (Tensor) where the absolute is, y = abs(x), is applied to the tensor elementwise.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to all numeric tensors.

Add-6

Performs element-wise binary addition (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor's shape. The starting of the mutually equal shape is specified by the argument "axis", and if it is not set, suffix matching is assumed. 1-dim expansion doesn't work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor
shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor
shape(A) = (2, 3, 4, 5), shape(B) = (5,)
shape(A) = (2, 3, 4, 5), shape(B) = (4, 5)
shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1
shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Attributes

axis : int
If set, defines the broadcast dimensions. See doc for details.
broadcast : int (default is 0)
Pass 1 to enable broadcasting

Inputs

A : T
First operand, should share the type with the second operand.
B : T
Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

C : T
Result, has same dimensions and type as A

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

BatchNormalization-6

Carries out batch normalization as described in the paper https://arxiv.org/abs/1502.03167. Depending on the mode it is being run, there are multiple cases for the number of outputs, which we list below:

Output case #1: Y, mean, var, saved_mean, saved_var (training mode) Output case #2: Y (test mode)

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Attributes

epsilon : float (default is 1e-05)
The epsilon value to use to avoid division by zero, default is 1e-5f.
is_test : int (default is 0)
If set to nonzero, run spatial batch normalization in test mode, default is 0.
momentum : float (default is 0.9)
Factor used in computing the running mean and variance.e.g., running_mean = running_mean * momentum + mean * (1 - momentum), default is 0.9f.
spatial : int (default is 1)
If true, compute the mean and variance across all spatial elements If false, compute the mean and variance across per feature.Default is 1.

Inputs

X : T
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.
scale : T
The scale as a 1-dimensional tensor of size C to be applied to the output.
B : T
The bias as a 1-dimensional tensor of size C to be applied to the output.
mean : T
The running mean (training) or the estimated mean (testing) as a 1-dimensional tensor of size C.
var : T
The running variance (training) or the estimated variance (testing) as a 1-dimensional tensor of size C.

Outputs (1 - 5)

Y : T
The output tensor of the same shape as X.
mean (optional) : T
The running mean after the BatchNormalization operator. Must be in-place with the input mean. Should not be used for testing.
var (optional) : T
The running variance after the BatchNormalization operator. Must be in-place with the input var. Should not be used for testing.
saved_mean (optional) : T
Saved mean used during training to speed up gradient computation. Should not be used for testing.
saved_var (optional) : T
Saved variance used during training to speed up gradient computation. Should not be used for testing.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Cast-6

The operator casts the elements of a given input tensor to a data type specified by the 'to' argument and returns an output tensor of the same size in the converted type. The 'to' argument must be one of the data types specified in the 'DataType' enum field in the TensorProto message. NOTE: Casting to and from strings is not supported yet.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Attributes

to : int (required)
The data type to which the elements of the input tensor are cast. Strictly must be one of the types from DataType enum in TensorProto

Inputs

input : T1
Input tensor to be cast.

Outputs

output : T2
Output tensor with the same shape as input with type specified by the 'to' argument

Type Constraints

T1 : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool)
Constrain input types. Casting from strings and complex are not supported.
T2 : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool)
Constrain output types. Casting to strings and complex are not supported.

Ceil-6

Ceil takes one input data (Tensor) and produces one output data (Tensor) where the ceil is, y = ceil(x), is applied to the tensor elementwise.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Clip-6

Clip operator limits the given input within an interval. The interval is specified with arguments 'min' and 'max'. They default to numeric_limits::lowest() and numeric_limits::max() respectively.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Attributes

max : float (default is (3.402823e+38))
Maximum value, above which element is replaced by max
min : float (default is (-3.402823e+38))
Minimum value, under which element is replaced by min

Inputs

input : T
Input tensor whose elements to be clipped

Outputs

output : T
Output tensor with clipped input elements

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Div-6

Performs element-wise binary division (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor's shape. The starting of the mutually equal shape is specified by the argument "axis", and if it is not set, suffix matching is assumed. 1-dim expansion doesn't work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor
shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor
shape(A) = (2, 3, 4, 5), shape(B) = (5,)
shape(A) = (2, 3, 4, 5), shape(B) = (4, 5)
shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1
shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Attributes

axis : int
If set, defines the broadcast dimensions. See doc for details.
broadcast : int (default is 0)
Pass 1 to enable broadcasting

Inputs

A : T
First operand, should share the type with the second operand.
B : T
Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

C : T
Result, has same dimensions and type as A

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

Dropout-6

Dropout takes one input data (Tensor) and produces two Tensor outputs, output (Tensor) and mask (Tensor). Depending on whether it is in test mode or not, the output Y will either be a random dropout, or a simple copy of the input. Note that our implementation of Dropout does scaling in the training phase, so during testing nothing needs to be done.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Attributes

is_test : int (default is 0)
(int, default 0) if nonzero, run dropout in test mode where the output is simply Y = X.
ratio : float (default is 0.5)
(float, default 0.5) the ratio of random dropout

Inputs

data : T
The input data as Tensor.

Outputs (1 - 2)

output : T
The output.
mask (optional) : T
The output mask. If is_test is nonzero, this output is not filled.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Elu-6

Elu takes one input data (Tensor) and produces one output data (Tensor) where the function f(x) = alpha * (exp(x) - 1.) for x < 0, f(x) = x for x >= 0., is applied to the tensor elementwise.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Attributes

alpha : float (default is 1.0)
Coefficient of ELU.

Inputs

X : T
1D input tensor

Outputs

Y : T
1D input tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Exp-6

Calculates the exponential of the given input tensor, element-wise.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The exponential of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Floor-6

Floor takes one input data (Tensor) and produces one output data (Tensor) where the floor is, y = floor(x), is applied to the tensor elementwise.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Gemm-6

General Matrix multiplication: https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms#Level_3 Compute Y = alpha * A * B + beta * C, where input tensor A has dimension (M X K), input tensor B has dimension (K X N), input tensor C and output tensor Y have dimension (M X N). If attribute broadcast is non-zero, input tensor C will be broadcasted to match the dimension requirement. A will be transposed before doing the computation if attribute transA is non-zero, same for B and transB.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Attributes

alpha : float (default is 1.0)
Scalar multiplier for the product of input tensors A * B, the default value is 1.0.
beta : float (default is 1.0)
Scalar multiplier for input tensor C, the default value is 1.0.
broadcast : int (default is 0)
Whether C should be broadcasted
transA : int (default is 0)
Whether A should be transposed
transB : int (default is 0)
Whether B should be transposed

Inputs

A : T
Input tensor A
B : T
Input tensor B
C : T
Input tensor C

Outputs

Y : T
Output tensor.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

HardSigmoid-6

HardSigmoid takes one input data (Tensor) and produces one output data (Tensor) where the HardSigmoid function, y = max(0, min(1, alpha * x + beta)), is applied to the tensor elementwise.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Attributes

alpha : float (default is 0.2)
Value of alpha.
beta : float (default is 0.5)
Value of beta.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

InstanceNormalization-6

Carries out instance normalization as described in the paper https://arxiv.org/abs/1607.08022.

y = scale * (x - mean) / sqrt(variance + epsilon) + B, where mean and variance are computed per instance per channel.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Attributes

epsilon : float (default is 1e-05)
The epsilon value to use to avoid division by zero.

Inputs

input : T
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.
scale : T
The input 1-dimensional scale tensor of size C.
B : T
The input 1-dimensional bias tensor of size C.

Outputs

output : T
The output tensor of the same shape as input.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

LeakyRelu-6

LeakyRelu takes input data (Tensor) and an argument alpha, and produces one output data (Tensor) where the function f(x) = alpha * x for x < 0, f(x) = x for x >= 0, is applied to the data tensor elementwise.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Attributes

alpha : float (default is 0.01)
Coefficient of leakage.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Log-6

Calculates the natural log of the given input tensor, element-wise.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The natural log of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Max-6

Element-wise max of each of the input tensors. All inputs and outputs must have the same shape and data type.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs (1 - ∞)

data_0 (variadic) : T
List of tensors for Max.

Outputs

max : T
Output tensor. Same dimension as inputs.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Mean-6

Element-wise mean of each of the input tensors. All inputs and outputs must have the same shape and data type.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs (1 - ∞)

data_0 (variadic) : T
List of tensors for Mean.

Outputs

mean : T
Output tensor. Same dimension as inputs.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Min-6

Element-wise min of each of the input tensors. All inputs and outputs must have the same shape and data type.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs (1 - ∞)

data_0 (variadic) : T
List of tensors for Min

Outputs

min : T
Output tensor. Same dimension as inputs.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Mul-6

Performs element-wise binary multiplication (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor's shape. The starting of the mutually equal shape is specified by the argument "axis", and if it is not set, suffix matching is assumed. 1-dim expansion doesn't work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor
shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor
shape(A) = (2, 3, 4, 5), shape(B) = (5,)
shape(A) = (2, 3, 4, 5), shape(B) = (4, 5)
shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1
shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Attributes

axis : int
If set, defines the broadcast dimensions. See doc for details.
broadcast : int (default is 0)
Pass 1 to enable broadcasting

Inputs

A : T
First operand, should share the type with the second operand.
B : T
Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

C : T
Result, has same dimensions and type as A

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

Neg-6

Neg takes one input data (Tensor) and produces one output data (Tensor) where each element flipped sign, y = -x, is applied to the tensor elementwise.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float), tensor(int32), tensor(int8), tensor(int16), tensor(int64), tensor(float16), tensor(double)
Constrain input and output types to signed numeric tensors.

PRelu-6

PRelu takes input data (Tensor) and slope tensor as input, and produces one output data (Tensor) where the function f(x) = slope * x for x < 0, f(x) = x for x >= 0., is applied to the data tensor elementwise.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs

X : T
Input tensor
slope : T
Slope tensor. If `Slope` is of size 1, the value is sharedacross different channels

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Reciprocal-6

Reciprocal takes one input data (Tensor) and produces one output data (Tensor) where the reciprocal is, y = 1/x, is applied to the tensor elementwise.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Relu-6

Relu takes one input data (Tensor) and produces one output data (Tensor) where the rectified linear function, y = max(0, x), is applied to the tensor elementwise.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Selu-6

Selu takes one input data (Tensor) and produces one output data (Tensor) where the scaled exponential linear unit function, y = gamma * (alpha * e^x - alpha) for x <= 0, y = gamma * x for x > 0, is applied to the tensor elementwise.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Attributes

alpha : float (default is 1.67326)
Coefficient of SELU default to 1.67326319217681884765625 (i.e., float32 approximation of 1.6732632423543772848170429916717).
gamma : float (default is 1.0507)
Coefficient of SELU default to 1.05070102214813232421875 (i.e., float32 approximation of 1.0507009873554804934193349852946).

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Sigmoid-6

Sigmoid takes one input data (Tensor) and produces one output data (Tensor) where the sigmoid function, y = 1 / (1 + exp(-x)), is applied to the tensor elementwise.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Sqrt-6

Square root takes one input data (Tensor) and produces one output data (Tensor) where the square root is, y = x^0.5, is applied to the tensor elementwise. If x is negative, then it will return NaN.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Sub-6

Performs element-wise binary subtraction (with limited broadcast support).

If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor's shape. The starting of the mutually equal shape is specified by the argument "axis", and if it is not set, suffix matching is assumed. 1-dim expansion doesn't work yet.

For example, the following tensor shapes are supported (with broadcast=1):

shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor
shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor
shape(A) = (2, 3, 4, 5), shape(B) = (5,)
shape(A) = (2, 3, 4, 5), shape(B) = (4, 5)
shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1
shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0

Attribute broadcast=1 needs to be passed to enable broadcasting.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Attributes

axis : int
If set, defines the broadcast dimensions. See doc for details.
broadcast : int (default is 0)
Pass 1 to enable broadcasting

Inputs

A : T
First operand, should share the type with the second operand.
B : T
Second operand. With broadcasting can be of smaller size than A. If broadcasting is disabled it should be of the same size.

Outputs

C : T
Result, has same dimensions and type as A

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

Sum-6

Element-wise sum of each of the input tensors. All inputs and outputs must have the same shape and data type.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs (1 - ∞)

data_0 (variadic) : T
List of tensors for Sum.

Outputs

sum : T
Output tensor. Same dimension as inputs.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Tanh-6

Calculates the hyperbolic tangent of the given input tensor element-wise.

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The hyperbolic tangent values of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Tile-6

Constructs a tensor by tiling a given tensor. This is the same as function tile in Numpy, but no broadcast. For example A = [[1, 2], [3, 4]], B = [1, 2], tile(A, B) = [[1, 2, 1, 2], [3, 4, 3, 4]]

Version

This version of the operator has been available since version 6 of the default ONNX operator set.

Inputs

input : T
Input tensor of any shape.
repeats : T1
1D int64 tensor of the same length as input's dimension number, includes numbers of repeated copies along input's dimensions.

Outputs

output : T
Output tensor of the same dimension and type as tensor input. output_dim[i] = input_dim[i] * repeats[i]

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output types to all tensor types.
T1 : tensor(int64)
Constrain repeat's type to int64 tensors.

Version 7 of the default ONNX operator set

Acos-7

Calculates the arccosine (inverse of cosine) of the given input tensor, element-wise.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The arccosine of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Add-7

Performs element-wise binary addition (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

A : T
First operand.
B : T
Second operand.

Outputs

C : T
Result, has same element type as two inputs

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

And-7

Returns the tensor resulted from performing the and logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

A : T
First input operand for the logical operator.
B : T
Second input operand for the logical operator.

Outputs

C : T1
Result tensor.

Type Constraints

T : tensor(bool)
Constrains input to boolean tensor.
T1 : tensor(bool)
Constrains output to boolean tensor.

Asin-7

Calculates the arcsine (inverse of sine) of the given input tensor, element-wise.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The arcsine of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Atan-7

Calculates the arctangent (inverse of tangent) of the given input tensor, element-wise.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The arctangent of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

AveragePool-7

AveragePool consumes an input tensor X and applies average pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. average pooling consisting of computing the average on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following:

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - kernel_spatial_shape[i]) / strides_spatial_shape[i] + 1)

* pad_shape[i] is sum of pads along axis i

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - kernel_spatial_shape[i] + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + kernel_spatial_shape[i] - input_spatial_shape[i]

The output of each pooling window is divided by the number of elements (exclude pad when attribute count_include_pad is zero).

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Attributes

auto_pad : string (default is NOTSET)
auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding.
count_include_pad : int (default is 0)
Whether include pad pixels when calculating values for the edges. Default is 0, doesn't count include pad.
kernel_shape : list of ints (required)
The size of the kernel along each axis.
pads : list of ints
Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.
strides : list of ints
Stride along each spatial axis.

Inputs

X : T
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. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE ...].

Outputs

Y : T
Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

BatchNormalization-7

Carries out batch normalization as described in the paper https://arxiv.org/abs/1502.03167. Depending on the mode it is being run, there are multiple cases for the number of outputs, which we list below:

  Output case #1: Y, mean, var, saved_mean, saved_var (training mode)
  Output case #2: Y (test mode)
      This operator has **optional** inputs/outputs. See [the doc](IR.md) for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument's name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Attributes

epsilon : float (default is 1e-05)
The epsilon value to use to avoid division by zero.
momentum : float (default is 0.9)
Factor used in computing the running mean and variance.e.g., running_mean = running_mean * momentum + mean * (1 - momentum).
spatial : int (default is 1)
If true, compute the mean and variance across per activation. If false, compute the mean and variance across per feature over each mini-batch.

Inputs

X : T
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.
scale : T
If spatial is true, the dimension of scale is (C). If spatial is false, the dimensions of scale are (C x D1 x ... x Dn)
B : T
If spatial is true, the dimension of bias is (C). If spatial is false, the dimensions of bias are (C x D1 x ... x Dn)
mean : T
If spatial is true, the dimension of the running mean (training) or the estimated mean (testing) is (C). If spatial is false, the dimensions of the running mean (training) or the estimated mean (testing) are (C x D1 x ... x Dn).
var : T
If spatial is true, the dimension of the running variance(training) or the estimated variance (testing) is (C). If spatial is false, the dimensions of the running variance(training) or the estimated variance (testing) are (C x D1 x ... x Dn).

Outputs (1 - 5)

Y : T
The output tensor of the same shape as X
mean (optional) : T
The running mean after the BatchNormalization operator.
var (optional) : T
The running variance after the BatchNormalization operator.
saved_mean (optional) : T
Saved mean used during training to speed up gradient computation.
saved_var (optional) : T
Saved variance used during training to speed up gradient computation.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Cos-7

Calculates the cosine of the given input tensor, element-wise.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The cosine of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Div-7

Performs element-wise binary division (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

A : T
First operand.
B : T
Second operand.

Outputs

C : T
Result, has same element type as two inputs

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

Dropout-7

Dropout takes one input data (Tensor) and produces two Tensor outputs, output (Tensor) and mask (Tensor). Depending on whether it is in test mode or not, the output Y will either be a random dropout, or a simple copy of the input. Note that our implementation of Dropout does scaling in the training phase, so during testing nothing needs to be done. This operator has optional inputs/outputs. See the doc for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument's name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Attributes

ratio : float (default is 0.5)
The ratio of random dropout

Inputs

data : T
The input data as Tensor.

Outputs (1 - 2)

output : T
The output.
mask (optional) : T
The output mask.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Equal-7

Returns the tensor resulted from performing the equal logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

A : T
First input operand for the logical operator.
B : T
Second input operand for the logical operator.

Outputs

C : T1
Result tensor.

Type Constraints

T : tensor(bool), tensor(int32), tensor(int64)
Constrains input to integral tensors.
T1 : tensor(bool)
Constrains output to boolean tensor.

GRU-7

Computes an one-layer GRU. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

X - input tensor

z - update gate

r - reset gate

h - hidden gate

t - time step (t-1 means previous time step)

W[zrh] - W parameter weight matrix for update, reset, and hidden gates

R[zrh] - R recurrence weight matrix for update, reset, and hidden gates

Wb[zrh] - W bias vectors for update, reset, and hidden gates

Rb[zrh] - R bias vectors for update, reset, and hidden gates

WB[zrh] - W parameter weight matrix for backward update, reset, and hidden gates

RB[zrh] - R recurrence weight matrix for backward update, reset, and hidden gates

WBb[zrh] - W bias vectors for backward update, reset, and hidden gates

RBb[zrh] - R bias vectors for backward update, reset, and hidden gates

H - Hidden state

num_directions - 2 if direction == bidirectional else 1

Activation functions:

Relu(x)                - max(0, x)

Tanh(x)                - (1 - e^{-2x})/(1 + e^{-2x})

Sigmoid(x)             - 1/(1 + e^{-x})

(NOTE: Below are optional)

Affine(x)              - alpha*x + beta

LeakyRelu(x)           - x if x >= 0 else alpha * x

ThresholdedRelu(x)     - x if x >= alpha else 0

ScaledTanh(x)          - alpha*Tanh(beta*x)

HardSigmoid(x)         - min(max(alpha*x + beta, 0), 1)

Elu(x)                 - x if x >= 0 else alpha*(e^x - 1)

Softsign(x)            - x/(1 + |x|)

Softplus(x)            - log(1 + e^x)

Equations (Default: f=Sigmoid, g=Tanh):

- zt = f(Xt*(Wz^T) + Ht-1*(Rz^T) + Wbz + Rbz)

- rt = f(Xt*(Wr^T) + Ht-1*(Rr^T) + Wbr + Rbr)

- ht = g(Xt*(Wh^T) + (rt (.) Ht-1)*(Rh^T) + Rbh + Wbh) # default, when linear_before_reset = 0

- ht = g(Xt*(Wh^T) + (rt (.) (Ht-1*(Rh^T) + Rbh)) + Wbh) # when linear_before_reset != 0

- Ht = (1 - zt) (.) ht + zt (.) Ht-1

This operator has optional inputs/outputs. See the doc for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument's name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Attributes

activation_alpha : list of floats
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.For example with LeakyRelu, the default alpha is 0.01.
activation_beta : list of floats
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.
activations : list of strings
A list of 2 (or 4 if bidirectional) activation functions for update, reset, and hidden gates. The activation functions must be one of the activation functions specified above. Optional: See the equations for default if not specified.
clip : float
Cell clip threshold. Clipping bounds the elements of a tensor in the range of [-threshold, +threshold] and is applied to the input of activations. No clip if not specified.
direction : string (default is forward)
Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional.
hidden_size : int
Number of neurons in the hidden layer
linear_before_reset : int (default is 0)
When computing the output of the hidden gate, apply the linear transformation before multiplying by the output of the reset gate.

Inputs (3 - 6)

X : T
The input sequences packed (and potentially padded) into one 3-D tensor with the shape of `[seq_length, batch_size, input_size]`.
W : T
The weight tensor for the gates. Concatenation of `W[zrh]` and `WB[zrh]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 3*hidden_size, input_size]`.
R : T
The recurrence weight tensor. Concatenation of `R[zrh]` and `RB[zrh]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 3*hidden_size, hidden_size]`.
B (optional) : T
The bias tensor for the gates. Concatenation of `[Wb[zrh], Rb[zrh]]` and `[WBb[zrh], RBb[zrh]]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 6*hidden_size]`. Optional: If not specified - assumed to be 0
sequence_lens (optional) : T1
Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length `seq_length`. It has shape `[batch_size]`.
initial_h (optional) : T
Optional initial value of the hidden. If not specified - assumed to be 0. It has shape `[num_directions, batch_size, hidden_size]`.

Outputs (0 - 2)

Y (optional) : T
A tensor that concats all the intermediate output values of the hidden. It has shape `[seq_length, num_directions, batch_size, hidden_size]`.
Y_h (optional) : T
The last output value of the hidden. It has shape `[num_directions, batch_size, hidden_size]`.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
T1 : tensor(int32)
Constrain seq_lens to integer tensor.

Gemm-7

General Matrix multiplication: https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms#Level_3

A' = transpose(A) if transA else A

B' = transpose(B) if transB else B

Compute Y = alpha * A' * B' + beta * C, where input tensor A has shape (M, K) or (K, M), input tensor B has shape (K, N) or (N, K), input tensor C is broadcastable to shape (M, N), and output tensor Y has shape (M, N). A will be transposed before doing the computation if attribute transA is non-zero, same for B and transB. This operator supports unidirectional broadcasting (tensor C should be unidirectional broadcastable to tensor A * B); for more details please check the doc.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Attributes

alpha : float (default is 1.0)
Scalar multiplier for the product of input tensors A * B.
beta : float (default is 1.0)
Scalar multiplier for input tensor C.
transA : int (default is 0)
Whether A should be transposed
transB : int (default is 0)
Whether B should be transposed

Inputs

A : T
Input tensor A. The shape of A should be (M, K) if transA is 0, or (K, M) if transA is non-zero.
B : T
Input tensor B. The shape of B should be (K, N) if transB is 0, or (N, K) if transB is non-zero.
C : T
Input tensor C. The shape of C should be unidirectional broadcastable to (M, N).

Outputs

Y : T
Output tensor of shape (M, N).

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Greater-7

Returns the tensor resulted from performing the greater logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

A : T
First input operand for the logical operator.
B : T
Second input operand for the logical operator.

Outputs

C : T1
Result tensor.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrains input to float tensors.
T1 : tensor(bool)
Constrains output to boolean tensor.

LSTM-7

Computes an one-layer LSTM. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

X - input tensor

i - input gate

o - output gate

f - forget gate

c - cell gate

t - time step (t-1 means previous time step)

W[iofc] - W parameter weight matrix for input, output, forget, and cell gates

R[iofc] - R recurrence weight matrix for input, output, forget, and cell gates

Wb[iofc] - W bias vectors for input, output, forget, and cell gates

Rb[iofc] - R bias vectors for input, output, forget, and cell gates

P[iof] - P peephole weight vector for input, output, and forget gates

WB[iofc] - W parameter weight matrix for backward input, output, forget, and cell gates

RB[iofc] - R recurrence weight matrix for backward input, output, forget, and cell gates

WBb[iofc] - W bias vectors for backward input, output, forget, and cell gates

RBb[iofc] - R bias vectors for backward input, output, forget, and cell gates

PB[iof] - P peephole weight vector for backward input, output, and forget gates

H - Hidden state

num_directions - 2 if direction == bidirectional else 1

Activation functions:

Relu(x)                - max(0, x)

Tanh(x)                - (1 - e^{-2x})/(1 + e^{-2x})

Sigmoid(x)             - 1/(1 + e^{-x})

(NOTE: Below are optional)

Affine(x)              - alpha*x + beta

LeakyRelu(x)           - x if x >= 0 else alpha * x

ThresholdedRelu(x)     - x if x >= alpha else 0

ScaledTanh(x)          - alpha*Tanh(beta*x)

HardSigmoid(x)         - min(max(alpha*x + beta, 0), 1)

Elu(x)                 - x if x >= 0 else alpha*(e^x - 1)

Softsign(x)            - x/(1 + |x|)

Softplus(x)            - log(1 + e^x)

Equations (Default: f=Sigmoid, g=Tanh, h=Tanh):

- it = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Pi (.) Ct-1 + Wbi + Rbi)

- ft = f(Xt*(Wf^T) + Ht-1*(Rf^T) + Pf (.) Ct-1 + Wbf + Rbf)

- ct = g(Xt*(Wc^T) + Ht-1*(Rc^T) + Wbc + Rbc)

- Ct = ft (.) Ct-1 + it (.) ct

- ot = f(Xt*(Wo^T) + Ht-1*(Ro^T) + Po (.) Ct + Wbo + Rbo)

- Ht = ot (.) h(Ct)

This operator has optional inputs/outputs. See the doc for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument's name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Attributes

activation_alpha : list of floats
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.For example with LeakyRelu, the default alpha is 0.01.
activation_beta : list of floats
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.
activations : list of strings
A list of 3 (or 6 if bidirectional) activation functions for input, output, forget, cell, and hidden. The activation functions must be one of the activation functions specified above. Optional: See the equations for default if not specified.
clip : float
Cell clip threshold. Clipping bounds the elements of a tensor in the range of [-threshold, +threshold] and is applied to the input of activations. No clip if not specified.
direction : string (default is forward)
Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional.
hidden_size : int
Number of neurons in the hidden layer
input_forget : int (default is 0)
Couple the input and forget gates if 1.

Inputs (3 - 8)

X : T
The input sequences packed (and potentially padded) into one 3-D tensor with the shape of `[seq_length, batch_size, input_size]`.
W : T
The weight tensor for the gates. Concatenation of `W[iofc]` and `WB[iofc]` (if bidirectional) along dimension 0. The tensor has shape `[num_directions, 4*hidden_size, input_size]`.
R : T
The recurrence weight tensor. Concatenation of `R[iofc]` and `RB[iofc]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 4*hidden_size, hidden_size]`.
B (optional) : T
The bias tensor for input gate. Concatenation of `[Wb[iofc], Rb[iofc]]`, and `[WBb[iofc], RBb[iofc]]` (if bidirectional) along dimension 0. This tensor has shape `[num_directions, 8*hidden_size]`. Optional: If not specified - assumed to be 0.
sequence_lens (optional) : T1
Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length `seq_length`. It has shape `[batch_size]`.
initial_h (optional) : T
Optional initial value of the hidden. If not specified - assumed to be 0. It has shape `[num_directions, batch_size, hidden_size]`.
initial_c (optional) : T
Optional initial value of the cell. If not specified - assumed to be 0. It has shape `[num_directions, batch_size, hidden_size]`.
P (optional) : T
The weight tensor for peepholes. Concatenation of `P[iof]` and `PB[iof]` (if bidirectional) along dimension 0. It has shape `[num_directions, 3*hidde_size]`. Optional: If not specified - assumed to be 0.

Outputs (0 - 3)

Y (optional) : T
A tensor that concats all the intermediate output values of the hidden. It has shape `[seq_length, num_directions, batch_size, hidden_size]`.
Y_h (optional) : T
The last output value of the hidden. It has shape `[num_directions, batch_size, hidden_size]`.
Y_c (optional) : T
The last output value of the cell. It has shape `[num_directions, batch_size, hidden_size]`.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
T1 : tensor(int32)
Constrain seq_lens to integer tensor.

Less-7

Returns the tensor resulted from performing the less logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

A : T
First input operand for the logical operator.
B : T
Second input operand for the logical operator.

Outputs

C : T1
Result tensor.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrains input to float tensors.
T1 : tensor(bool)
Constrains output to boolean tensor.

Mul-7

Performs element-wise binary multiplication (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

A : T
First operand.
B : T
Second operand.

Outputs

C : T
Result, has same element type as two inputs

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

Multinomial-7

Generate a tensor of samples from a multinomial distribution according to the probabilities of each of the possible outcomes.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Attributes

dtype : int (default is 6)
(Optional) The data type for the elements of the output tensor, if not specified, we will use int32.
sample_size : int (default is 1)
Number of times to sample.
seed : float
(Optional) Seed to the random generator, if not specified we will auto generate one.

Inputs

input : T1
Input tensor with shape [batch_size, class_size], where class_size is the number of all possible outcomes. Each value along the axis zero represents the unnormalized log-probability of each corresponding outcome in a batch.

Outputs

output : T2
Output tensor with shape [batch_size, sample_size], where sample_size is the number of times to sample. Each value along the axis zero represents the outcome of the corresponding sample in a batch.

Type Constraints

T1 : tensor(float16), tensor(float), tensor(double)
Constrain input types to float tensors.
T2 : tensor(int32), tensor(int64)
Constrain output types to integral tensors.

Or-7

Returns the tensor resulted from performing the or logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

A : T
First input operand for the logical operator.
B : T
Second input operand for the logical operator.

Outputs

C : T1
Result tensor.

Type Constraints

T : tensor(bool)
Constrains input to boolean tensor.
T1 : tensor(bool)
Constrains output to boolean tensor.

PRelu-7

PRelu takes input data (Tensor) and slope tensor as input, and produces one output data (Tensor) where the function f(x) = slope * x for x < 0, f(x) = x for x >= 0., is applied to the data tensor elementwise. This operator supports unidirectional broadcasting (tensor slope should be unidirectional broadcastable to input tensor X); for more details please check the doc.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

X : T
Input tensor
slope : T
Slope tensor. The shape of slope can be smaller then first input X; if so, its shape must be unidirectional broadcastable to X

Outputs

Y : T
Output tensor (same size as X)

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Pow-7

Pow takes input data (Tensor) and exponent Tensor, and produces one output data (Tensor) where the function f(x) = x^exponent, is applied to the data tensor elementwise. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

X : T
First operand, base of the exponent.
Y : T
Second operand, power of the exponent.

Outputs

Z : T
Output tensor (same size as X)

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

RNN-7

Computes an one-layer simple RNN. This operator is usually supported via some custom implementation such as CuDNN.

Notations:

X - input tensor

i - input gate

t - time step (t-1 means previous time step)

Wi - W parameter weight matrix for input gate

Ri - R recurrence weight matrix for input gate

Wbi - W parameter bias vector for input gate

Rbi - R parameter bias vector for input gate

WBi - W parameter weight matrix for backward input gate

RBi - R recurrence weight matrix for backward input gate

WBbi - WR bias vectors for backward input gate

RBbi - RR bias vectors for backward input gate

H - Hidden state

num_directions - 2 if direction == bidirectional else 1

Activation functions:

Relu(x)                - max(0, x)

Tanh(x)                - (1 - e^{-2x})/(1 + e^{-2x})

Sigmoid(x)             - 1/(1 + e^{-x})

(NOTE: Below are optional)

Affine(x)              - alpha*x + beta

LeakyRelu(x)           - x if x >= 0 else alpha * x

ThresholdedRelu(x)     - x if x >= alpha else 0

ScaledTanh(x)          - alpha*Tanh(beta*x)

HardSigmoid(x)         - min(max(alpha*x + beta, 0), 1)

Elu(x)                 - x if x >= 0 else alpha*(e^x - 1)

Softsign(x)            - x/(1 + |x|)

Softplus(x)            - log(1 + e^x)

Equations (Default: f=Tanh):

- Ht = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Wbi + Rbi)

This operator has optional inputs/outputs. See the doc for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument's name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Attributes

activation_alpha : list of floats
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.For example with LeakyRelu, the default alpha is 0.01.
activation_beta : list of floats
Optional scaling values used by some activation functions. The values are consumed in the order of activation functions, for example (f, g, h) in LSTM. Default values are the same as of corresponding ONNX operators.
activations : list of strings (default is ['Tanh', 'Tanh'])
One (or two if bidirectional) activation function for input gate. The activation function must be one of the activation functions specified above. Optional: Default `Tanh` if not specified.
clip : float
Cell clip threshold. Clipping bounds the elements of a tensor in the range of [-threshold, +threshold] and is applied to the input of activations. No clip if not specified.
direction : string (default is forward)
Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward (default), reverse, or bidirectional.
hidden_size : int
Number of neurons in the hidden layer

Inputs (3 - 6)

X : T
The input sequences packed (and potentially padded) into one 3-D tensor with the shape of `[seq_length, batch_size, input_size]`.
W : T
The weight tensor for input gate. Concatenation of `Wi` and `WBi` (if bidirectional). The tensor has shape `[num_directions, hidden_size, input_size]`.
R : T
The recurrence weight tensor. Concatenation of `Ri` and `RBi` (if bidirectional). The tensor has shape `[num_directions, hidden_size, hidden_size]`.
B (optional) : T
The bias tensor for input gate. Concatenation of `[Wbi, Rbi]` and `[WBbi, RBbi]` (if bidirectional). The tensor has shape `[num_directions, 2*hidden_size]`. Optional: If not specified - assumed to be 0.
sequence_lens (optional) : T1
Optional tensor specifying lengths of the sequences in a batch. If not specified - assumed all sequences in the batch to have length `seq_length`. It has shape `[batch_size]`.
initial_h (optional) : T
Optional initial value of the hidden. If not specified - assumed to be 0. It has shape `[num_directions, batch_size, hidden_size]`.

Outputs (0 - 2)

Y (optional) : T
A tensor that concats all the intermediate output values of the hidden. It has shape `[seq_length, num_directions, batch_size, hidden_size]`.
Y_h (optional) : T
The last output value of the hidden. It has shape `[num_directions, batch_size, hidden_size]`.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
T1 : tensor(int32)
Constrain seq_lens to integer tensor.

Sin-7

Calculates the sine of the given input tensor, element-wise.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The sine of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Sub-7

Performs element-wise binary subtraction (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

A : T
First operand.
B : T
Second operand.

Outputs

C : T
Result, has same element type as two inputs

Type Constraints

T : tensor(uint32), tensor(uint64), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to high-precision numeric tensors.

Tan-7

Calculates the tangent of the given input tensor, element-wise.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The tangent of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Upsample-7

Upsample the input tensor. Each dimension value of the output tensor is: output_dimension = floor(input_dimension * scale).

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Attributes

mode : string (default is nearest)
Two interpolation modes: nearest (default), and linear (including bilinear, trilinear, etc)
scales : list of floats (required)
The scale array along each dimension. It takes value greater than or equal to 1. The number of elements of 'scales' should be the same as the rank of input 'X'.

Inputs

X : T
N-D tensor

Outputs

Y : T
N-D tensor after resizing

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output types to all tensor types.

Xor-7

Returns the tensor resulted from performing the xor logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 7 of the default ONNX operator set.

Inputs

A : T
First input operand for the logical operator.
B : T
Second input operand for the logical operator.

Outputs

C : T1
Result tensor.

Type Constraints

T : tensor(bool)
Constrains input to boolean tensor.
T1 : tensor(bool)
Constrains output to boolean tensor.

Version 8 of the default ONNX operator set

Expand-8

Broadcast the input tensor following the given shape and the broadcast rule. The broadcast rule is similar to numpy.array(input) * numpy.ones(shape): Dimensions are right alignment; Two corresponding dimension must have the same value, or one of them is equal to 1. Also, this operator is similar to numpy.broadcast_to(input, shape), but the major difference is numpy.broadcast_to() does not allow shape to be smaller than input.size(). It is possible that the output.shape is not equal to shape, when some dimensions in shape is equal to 1, or the shape.ndim < input.shape.ndim.

Version

This version of the operator has been available since version 8 of the default ONNX operator set.

Inputs

input : T
Input tensor
shape : tensor(int64)
A 1-D tensor indicates the shape you want to expand to, following the broadcast rule

Outputs

output : T
Output tensor

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output types to all tensors.

Max-8

Element-wise max of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 8 of the default ONNX operator set.

Inputs (1 - ∞)

data_0 (variadic) : T
List of tensors for max.

Outputs

max : T
Output tensor.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

MaxPool-8

MaxPool consumes an input tensor X and applies max pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. max pooling consisting of computing the max on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following:

output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - kernel_spatial_shape[i]) / strides_spatial_shape[i] + 1)

* pad_shape[i] is sum of pads along axis i

auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following:

VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - kernel_spatial_shape[i] + 1) / strides_spatial_shape[i])
SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i])

And pad shape will be following if SAME_UPPER or SAME_LOWER:

pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + kernel_spatial_shape[i] - input_spatial_shape[i]

The output of each pooling window is maximum number of elements exclude pad.

Version

This version of the operator has been available since version 8 of the default ONNX operator set.

Attributes

auto_pad : string (default is NOTSET)
auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that the output spatial size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the beginning for SAME_LOWER. VALID mean no padding.
kernel_shape : list of ints (required)
The size of the kernel along each axis.
pads : list of ints
Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.
storage_order : int (default is 0)
The storage order of the tensor. 0 is row major, and 1 is column major.
strides : list of ints
Stride along each spatial axis.

Inputs

X : T
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. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE ...].

Outputs (1 - 2)

Y : T
Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used
Indices (optional) : I
Indices tensor from max pooling across the input tensor. The dimensions of indices are the same as output tensor. The values in indices of are the indices of the selected values during pooling. The indices are computed as flatten 1-D tensor, and the indices do not consider padding. So the values in indices are in [0, N x C x D1 x ... x Dn).

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
I : tensor(int64)
Constrain index tensor to int64

Mean-8

Element-wise mean of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 8 of the default ONNX operator set.

Inputs (1 - ∞)

data_0 (variadic) : T
List of tensors for mean.

Outputs

mean : T
Output tensor.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Min-8

Element-wise min of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 8 of the default ONNX operator set.

Inputs (1 - ∞)

data_0 (variadic) : T
List of tensors for min.

Outputs

min : T
Output tensor.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Scan-8

Scan can be used to iterate over one or more scan_input tensors, constructing zero or more scan_output tensors. It combines ideas from general recurrences, functional programming constructs such as scan, fold, map, and zip and is intended to enable generalizations of RNN-like constructs for sequence-to-sequence processing. Other tensors (referred to as state_variables here) can be used to carry a state when iterating from one element to another (similar to hidden-state in RNNs, also referred to as loop-carried dependences in the context of loops). All these tensors are required to have the same shape in each iteration of the loop (a restriction imposed to enable efficient memory allocation). Many common usages involve a single scan_input tensor (where functionality similar to scan, fold and map can be obtained). When more than one scan_input is used, a behavior similar to zip is obtained.

The attribute body must be a graph, specifying the computation to be performed in every iteration. It takes as input the current values of the state_variables and the current iterated element of the scan_inputs. It must return the (updated) values of the state_variables and zero or more scan_output_element tensors. The values of the scan_output_element tensors are concatenated over all the iterations to produce the scan_output values of the scan construct (similar to the concatenated intermediate hidden-state values of RNN-like constructs).

The scan operation returns the final values of the state_variables as well as the scan_outputs.

The operation supports batching, and the batch-axis is required to be 0. When multiple scan_input tensors are used, they must all have the same batch-size, and they must all have the same maximum-sequence-length (the dimensionality of the sequence axis or scan axis). The sequence axis or scan axis is required to be 1.

The operation has an optional sequence_lens input (of shape [BATCH_SIZE]) to allow variable length sequences of length <= the maximum-sequence-length. If this input is not specified, all sequences are assumed to be of length equal to maximum-sequence-length. For variable length input sequences, the scan_outputs will consist of a sequence of same length as the input, padded to the maximum-sequence-length.

The optional attribute directions can be used to scan a sequence in the reverse direction. If this attribute is omitted, all sequences are scanned in the forward direction. A bidirectional scan be performed by specifying the same tensor input twice in the scan_inputs, once with a forward direction, and once with a backward direction.

Note that because of the ONNX restriction that only the last parameter of an operator can be variadic, the initial-states and scan-inputs are listed together as one input parameter. Similarly, the final-states and scan-outputs are listed together as one output parameter. The attribute num_scan_inputs indicates the number M of scan-inputs.

The behavior of

  Scan <
      num_scan_inputs = m,
      body = loop-body
  > (sequence_lengths, init_1, ..., init_n, scan_1, ..., scan_m)

is equivalent to the following pseudo-code:

  // T.shape[0] denotes the batch-size of T
  // The batch-size of scan_1, ..., scan_m are all required to be equal
  batch_size = scan_1.shape[0];

  // scan_i.shape[1] denotes the (max) sequence-length of scan_i
  // scan_i.shape[1] is required to be equal to scan_j.shape[1] for all i,j.
  max_sequence_length = scan_1.shape[1];

  for (int batch = 0; batch < batch_size; ++batch) {
      // initialize state-variables
      st_1 = init_1; ... st_n = init_n;
      // initialize scan-output variables: [] denotes an empty tensor
      scan_out_1 = []; ...; scan_out_k = [];
      // identify number of iterations:
      N = (sequence_lengths specified) ? sequence_lengths[batch] : max_sequence_length;

      // execute loop
      for (int t = 0; t < N; ++t) {
          // generate the scan-input elements: the notation T<axis=k>[t] indicates the sub-tensor
          // of rank one less than T obtained by indexing T at position t along axis k.
          si_1 = (scan_1<axis=0>[batch])<axis=1>[t];
          ... ;
          si_m = (scan_m<axis=0>[batch])<axis=1>[t];
          // execute loop-body
          st_1, ..., st_n, so_1, ..., so_k = loop-body(st_1, ..., st_n, si_1, ..., si_m)
          // accumulate the scan-output elements
          scan_out_1 = Concat<axis=0>(scan_out_1, so_1); ... ; scan_out_k = Concat<axis=0>(scan_out_k, so_k);
      }
      // accumulate the outputs for this batch:
      bst_1[batch] = st_1; ..., bst_n[batch] = st_n;
      // Note scan-outputs will have size max_sequence_length, but only first N values will be meaningful.
      // The remaining values have an undefined value.
      b_scan_out_1[batch] = scan_out_1; ...; b_scan_out_k[batch] = scan_out_k;
  }
  return bst_1, ..., bst_n, b_scan_out_1, ..., b_scan_out_k;

Sample usage: Encoding RNN using a Scan

The following example shows how a simple RNN over an input tensor %X, with weight tensor %Wi, recurrence weight tensor %Ri, bias tensors %Wbi and %Rbi, and initial hidden-state %H_0 can be encoded as a ScanLoop. Note that the loop-body is a nested graph, and it directly computes %Wi, %Ri, %Wbi, and %Rbi (typically constants or initializers in the body graph). If these values are computed in the outer graph, they need to be passed in as extra state_variables.

  graph rnn-encoding {
    %H_0 = ... 
    %X = ...
    %Y_h, %Y = Scan[body = <graph rnn-cell-1>, num_scan_inputs=1]("", %H_0, %X)
    return %Y, %Y_h
  }

  graph rnn-cell-1 (
    %H_tminus1[FLOAT, tensor]
    %X_t[FLOAT, tensor]
  ) {
    %Wi = ...
    %Ri = ...
    %Wbi = ...
    %Rbi = ...
    %t1 = X_t * (Wi^T)
    %t2 = H_tminus1*(Ri^T)
    %t3 = Add(%t1, %t2)
    %t4 = Add(%t3, %Wbi)
    %t5 = Add(%t4, %Rbi)
    %Ht = Tanh(%t5)
    %Accumulate = Identity(%Ht)
    return %Ht, %Accumulate
  }

Version

This version of the operator has been available since version 8 of the default ONNX operator set.

Attributes

body : graph (required)
The graph run each iteration. It has N+M inputs: (loop state variables..., scan_input_elts...). It has N+K outputs: (loop state variables..., scan_output_elts...). Each scan_output is created by concatenating the value of the specified scan_output_elt value at the end of each iteration of the loop. It is an error if the dimensions of these values change across loop iterations.
directions : list of ints
An optional list of M flags. The i-th element of the list specifies the direction to be scanned for the i-th scan_input tensor: 0 indicates forward direction and 1 indicates reverse direction. If omitted, all scan_input tensors will be scanned in the forward direction.
num_scan_inputs : int (required)
An attribute specifying the number of scan_inputs M.

Inputs (2 - ∞)

sequence_lens (optional) : I
Optional tensor specifying lengths of the sequences in a batch. If this input is not specified, all sequences are assumed to be of the maximum sequence length (the dimension of the sequence axis of the scan_input tensors).
initial_state_and_scan_inputs (variadic, heterogeneous) : V
Initial values of the loop's N state variables followed by M scan_inputs

Outputs (1 - ∞)

final_state_and_scan_outputs (variadic, heterogeneous) : V
Final values of the loop's N state variables followed by K scan_outputs

Type Constraints

I : tensor(int64)
Int64 tensor
V : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
All Tensor types

Sum-8

Element-wise sum of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 8 of the default ONNX operator set.

Inputs (1 - ∞)

data_0 (variadic) : T
List of tensors for sum.

Outputs

sum : T
Output tensor.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Version 9 of the default ONNX operator set

Acosh-9

Calculates the hyperbolic arccosine of the given input tensor element-wise.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The hyperbolic arccosine values of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Asinh-9

Calculates the hyperbolic arcsine of the given input tensor element-wise.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The hyperbolic arcsine values of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Atanh-9

Calculates the hyperbolic arctangent of the given input tensor element-wise.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The hyperbolic arctangent values of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

BatchNormalization-9

Carries out batch normalization as described in the paper https://arxiv.org/abs/1502.03167. Depending on the mode it is being run, there are multiple cases for the number of outputs, which we list below:

Output case #1: Y, mean, var, saved_mean, saved_var (training mode) Output case #2: Y (test mode)

For previous (depreciated) non-spatial cases, implementors are suggested to flatten the input shape to (N x CD1D2 ..*Dn) before a BatchNormalization Op. This operator has optional inputs/outputs. See the doc for more details about the representation of optional arguments. An empty string may be used in the place of an actual argument's name to indicate a missing argument. Trailing optional arguments (those not followed by an argument that is present) may also be simply omitted.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

epsilon : float (default is 1e-05)
The epsilon value to use to avoid division by zero.
momentum : float (default is 0.9)
Factor used in computing the running mean and variance.e.g., running_mean = running_mean * momentum + mean * (1 - momentum).

Inputs

X : T
Input data tensor from the previous operator; dimensions are in the form of (N x C x D1 x D2 ... Dn), where N is the batch size, C is the number of channels. Statistics are computed for every channel of C over N and D1 to Dn dimensions. For image data, input dimensions become (N x C x H x W). The op also accepts single dimension input of size N in which case C is assumed to be 1
scale : T
Scale tensor of shape (C).
B : T
Bias tensor of shape (C).
mean : T
running (training) or estimated (testing) mean tensor of shape (C).
var : T
running (training) or estimated (testing) variance tensor of shape (C).

Outputs (1 - 5)

Y : T
The output tensor of the same shape as X
mean (optional) : T
The running mean after the BatchNormalization operator.
var (optional) : T
The running variance after the BatchNormalization operator.
saved_mean (optional) : T
Saved mean used during training to speed up gradient computation.
saved_var (optional) : T
Saved variance used during training to speed up gradient computation.

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Cast-9

The operator casts the elements of a given input tensor to a data type specified by the 'to' argument and returns an output tensor of the same size in the converted type. The 'to' argument must be one of the data types specified in the 'DataType' enum field in the TensorProto message.

Casting from string tensor in plain (e.g., "3.14" and "1000") and scientific numeric representations (e.g., "1e-5" and "1E8") to float types is supported. For example, converting string "100.5" to an integer may result 100. There are some string literals reserved for special floating-point values; "+INF" (and "INF"), "-INF", and "NaN" are positive infinity, negative infinity, and not-a-number, respectively. Any string which can exactly match "+INF" in a case-insensitive way would be mapped to positive infinite. Similarly, this case-insensitive rule is applied to "INF" and "NaN". When casting from numeric tensors to string tensors, plain floating-point representation (such as "314.15926") would be used. Converting non-numerical-literal string such as "Hello World!" is an undefined behavior. Cases of converting string representing floating-point arithmetic value, such as "2.718", to INT is an undefined behavior.

Conversion from a numerical type to any numerical type is always allowed. User must be aware of precision loss and value change caused by range difference between two types. For example, a 64-bit float 3.1415926459 may be round to a 32-bit float 3.141592. Similarly, converting an integer 36 to Boolean may produce 1 because we truncate bits which can't be stored in the targeted type.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

to : int (required)
The data type to which the elements of the input tensor are cast. Strictly must be one of the types from DataType enum in TensorProto

Inputs

input : T1
Input tensor to be cast.

Outputs

output : T2
Output tensor with the same shape as input with type specified by the 'to' argument

Type Constraints

T1 : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string)
Constrain input types. Casting from complex is not supported.
T2 : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool), tensor(string)
Constrain output types. Casting to complex is not supported.

Compress-9

Selects slices from an input tensor along a given axis where condition evaluates to True for each axis index. In case axis is not provided, input is flattened before elements are selected. Compress behaves like numpy.compress: https://docs.scipy.org/doc/numpy/reference/generated/numpy.compress.html

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

axis : int
(Optional) Axis along which to take slices. If not specified, input is flattened before elements being selected.

Inputs

input : T
Tensor of rank r >= 1.
condition : T1
Rank 1 tensor of booleans to indicate which slices or data elements to be selected. Its length can be less than the input length alone the axis or the flattened input size if axis is not specified. In such cases data slices or elements exceeding the condition length are discarded.

Outputs

output : T
Tensor of rank r if axis is specified. Otherwise output is a Tensor of rank 1.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output types to all tensor types.
T1 : tensor(bool)
Constrains to boolean tensors.

Constant-9

A constant tensor.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

value : tensor (required)
The value for the elements of the output tensor.

Inputs

Outputs

output : T
Output tensor containing the same value of the provided tensor.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output types to all tensor types.

ConstantOfShape-9

Generate a tensor with given value and shape.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

value : tensor
(Optional) The value of the output elements.Should be a one-element tensor. If not specified, it defaults to a tensor of value 0 and datatype float32

Inputs

input : T1
1D tensor. The shape of the expected output tensor. If empty tensor is given, the output would be a scalar. All values must be >= 0.

Outputs

output : T2
Output tensor of shape specified by 'input'.If attribute 'value' is specified, the value and datatype of the output tensor is taken from 'value'.If attribute 'value' is not specified, the value in the output defaults to 0, and the datatype defaults to float32.

Type Constraints

T1 : tensor(int64)
Constrain input types.
T2 : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool)
Constrain output types to be numerics.

Cosh-9

Calculates the hyperbolic cosine of the given input tensor element-wise.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The hyperbolic cosine values of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Erf-9

Computes the error function of the given input tensor element-wise.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The error function of the input tensor computed element-wise. It has the same shape and type of the input.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to all numeric tensors.

EyeLike-9

Generate a 2D tensor (matrix) with ones on the diagonal and zeros everywhere else. Only 2D tensors are supported, i.e. input T1 must be of rank 2. The shape of the output tensor is the same as the input tensor. The data type can be specified by the 'dtype' argument. If 'dtype' is not specified, then the type of input tensor is used. By default, the main diagonal is populated with ones, but attribute 'k' can be used to populate upper or lower diagonals. The 'dtype' argument must be one of the data types specified in the 'DataType' enum field in the TensorProto message and be valid as an output type.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

dtype : int
(Optional) The data type for the elements of the output tensor. If not specified,the data type of the input tensor T1 is used. If input tensor T1 is also notspecified, then type defaults to 'float'.
k : int (default is 0)
(Optional) Index of the diagonal to be populated with ones. Default is 0. If T2 is the output, this op sets T2[i, i+k] = 1. k = 0 populates the main diagonal, k > 0 populates an upper diagonal, and k < 0 populates a lower diagonal.

Inputs

input : T1
2D input tensor to copy shape, and optionally, type information from.

Outputs

output : T2
Output tensor, same shape as input tensor T1.

Type Constraints

T1 : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool)
Constrain input types. Strings and complex are not supported.
T2 : tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(bool)
Constrain output types. Strings and complex are not supported.

Flatten-9

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).

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

axis : int (default is 1)
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 [0, R], where R is the rank of the input tensor. When axis = 0, the shape of the output tensor is (1, (d_0 X d_1 ... d_n), where the shape of the input tensor is (d_0, d_1, ... d_n).

Inputs

input : T
A tensor of rank >= axis.

Outputs

output : T
A 2D 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.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input and output to all tensor types.

Gemm-9

General Matrix multiplication: https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms#Level_3

A' = transpose(A) if transA else A

B' = transpose(B) if transB else B

Compute Y = alpha * A' * B' + beta * C, where input tensor A has shape (M, K) or (K, M), input tensor B has shape (K, N) or (N, K), input tensor C is broadcastable to shape (M, N), and output tensor Y has shape (M, N). A will be transposed before doing the computation if attribute transA is non-zero, same for B and transB. This operator supports unidirectional broadcasting (tensor C should be unidirectional broadcastable to tensor A * B); for more details please check the doc.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

alpha : float (default is 1.0)
Scalar multiplier for the product of input tensors A * B.
beta : float (default is 1.0)
Scalar multiplier for input tensor C.
transA : int (default is 0)
Whether A should be transposed
transB : int (default is 0)
Whether B should be transposed

Inputs

A : T
Input tensor A. The shape of A should be (M, K) if transA is 0, or (K, M) if transA is non-zero.
B : T
Input tensor B. The shape of B should be (K, N) if transB is 0, or (N, K) if transB is non-zero.
C : T
Input tensor C. The shape of C should be unidirectional broadcastable to (M, N).

Outputs

Y : T
Output tensor of shape (M, N).

Type Constraints

T : tensor(float16), tensor(float), tensor(double), tensor(uint32), tensor(uint64), tensor(int32), tensor(int64)
Constrain input and output types to float/int tensors.

Greater-9

Returns the tensor resulted from performing the greater logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Inputs

A : T
First input operand for the logical operator.
B : T
Second input operand for the logical operator.

Outputs

C : T1
Result tensor.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrains input types to all numeric tensors.
T1 : tensor(bool)
Constrains output to boolean tensor.

IsNaN-9

Returns which elements of the input are NaN.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Inputs

X : T1
input

Outputs

Y : T2
output

Type Constraints

T1 : tensor(float16), tensor(float), tensor(double)
Constrain input types to float tensors.
T2 : tensor(bool)
Constrain output types to boolean tensors.

Less-9

Returns the tensor resulted from performing the less logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Inputs

A : T
First input operand for the logical operator.
B : T
Second input operand for the logical operator.

Outputs

C : T1
Result tensor.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrains input types to all numeric tensors.
T1 : tensor(bool)
Constrains output to boolean tensor.

MatMul-9

Matrix product that behaves like numpy.matmul: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.matmul.html

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Inputs

A : T
N-dimensional matrix A
B : T
N-dimensional matrix B

Outputs

Y : T
Matrix multiply results from A * B

Type Constraints

T : tensor(float16), tensor(float), tensor(double), tensor(uint32), tensor(uint64), tensor(int32), tensor(int64)
Constrain input and output types to float/int tensors.

MaxUnpool-9

MaxUnpool essentially computes the partial inverse of the MaxPool op. The input information to this op is typically the the output information from a MaxPool op. The first input tensor X is the tensor that needs to be unpooled, which is typically the pooled tensor (first output) from MaxPool. The second input tensor, I, contains the indices to the (locally maximal) elements corrsponding to the elements in the first input tensor X. Input tensor I is typically the second output of the MaxPool op. The third (optional) input is a tensor that specifies the output size of the unpooling operation.

MaxUnpool is intended to do 'partial' inverse of the MaxPool op. 'Partial' because all the non-maximal values from the original input to MaxPool are set to zero in the output of the MaxUnpool op. Pooling the result of an unpooling operation should give back the original input to the unpooling op.

MaxUnpool can produce the same output size for several input sizes, which makes unpooling op ambiguous. The third input argument, output_size, is meant to disambiguate the op and produce output tensor of known/predictable size.

In addition to the inputs, MaxUnpool takes three attributes, namely kernel_shape, strides, and pads, which define the exact unpooling op. The attributes typically have the same values as the corrsponding pooling op that the unpooling op is trying to invert.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

kernel_shape : list of ints (required)
The size of the kernel along each axis.
pads : list of ints
Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. `pads` format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axis `i` and xi_end, the number of pixels added at the end of axis `i`. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.
strides : list of ints
Stride along each spatial axis.

Inputs (2 - 3)

X : T1
Input data tensor that has to be unpooled. This tensor is typically the first output of the MaxPool op.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. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE ...].
I : T2
Input data tensor containing the indices corresponding to elements in the first input tensor X.This tensor is typically the second output of the MaxPool op.Dimensions must be the same as input tensor X. The indices are linear, i.e. computed considering the tensor as flattened 1-D tensor, assuming row-major storage. Also, the linear indices should not consider padding. So the values in indices are in the range [0, N x C x D1 x ... x Dn).
output_shape (optional) : T2
The shape of the output can be explicitly set which will cause pads values to be auto generated. If 'output_shape' is specified, 'pads' values are ignored.

Outputs

output : T1
Output data tensor that contains the result of the unpooling.

Type Constraints

T1 : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
T2 : tensor(int64)
Constrain index tensor to int64

MeanVarianceNormalization-9

A MeanVarianceNormalization Function: Perform mean variance normalization on the input tensor X using formula:
(X-EX)/sqrt(E(X-EX)^2)

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

axes : list of ints (default is ['0', '2', '3'])
A list of integers, along which to reduce. The default is to caculate along axes [0,2,3] for calculating mean and variance along each channel. Two variables with the same C-coordinate are associated with the same mean and variance.

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to all numeric tensors.

NonZero-9

Returns the indices of the elements that are non-zero (in row-major order - by dimension). NonZero behaves similar to numpy.nonzero: https://docs.scipy.org/doc/numpy/reference/generated/numpy.nonzero.html

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Inputs

X : T
input

Outputs

Y : tensor(int64)
output

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain to all tensor types.

OneHot-9

Produces a one-hot tensor based on inputs. The locations represented by the index values in the 'indices' input tensor will have 'on_value' and the other locations will have 'off_value' in the output tensor, where 'on_value' and 'off_value' are specified as part of required input argument 'values', which is a two-element tensor of format [off_value, on_value]. The rank of the output tensor will be one greater than the rank of the input tensor. The additional dimension is for one-hot representation. The additional dimension will be inserted at the position specified by 'axis'. If 'axis' is not specified then then additional dimension will be inserted as the innermost dimension, i.e. axis=-1. The size of the additional dimension is specified by required scalar input 'depth'. The type of the output tensor is the same as the type of the 'values' input. Any entries in the 'indices' input tensor with values outside the range [0, depth) will result in one-hot representation with all 'off_value' values in the output tensor.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

axis : int (default is -1)
(Optional) Axis along which one-hot representation in added. Default: axis=-1. axis=-1 means that the additional dimension will be inserted as the innermost/last dimension in the output tensor.

Inputs

indices : T1
Input tensor containing indices. The values must be non-negative integers. Any entries in the 'indices' input tensor with values outside the range [0, depth) will result in one-hot representation with all 'off_value' values in the output tensor.In case 'indices' is of non-integer type, the values will be casted to int64 before use.
depth : T2
Scalar specifying the number of classes in one-hot tensor. This is also the size of the one-hot dimension (specified by 'axis' attribute) added on in the output tensor. The values in the 'indices' input tensor are expected to be in the range [0, depth). In case 'depth' is of non-integer type, it will be casted to int64 before use.
values : T3
Rank 1 tensor containing exactly two elements, in the format [off_value, on_value], where 'on_value' is the value used for filling locations specified in 'indices' input tensor, and 'off_value' is the value used for filling locations other than those specified in 'indices' input tensor.

Outputs

output : T3
Tensor of rank one greater than input tensor 'indices', i.e. rank(output) = rank(indices) + 1. The data type for the elements of the output tensor is the same as the type of input 'values' is used.

Type Constraints

T1 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrains input to only numeric types.
T2 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrains input to only numeric types.
T3 : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain to any tensor type.

PRelu-9

PRelu takes input data (Tensor) and slope tensor as input, and produces one output data (Tensor) where the function f(x) = slope * x for x < 0, f(x) = x for x >= 0., is applied to the data tensor elementwise. This operator supports unidirectional broadcasting (tensor slope should be unidirectional broadcastable to input tensor X); for more details please check the doc.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Inputs

X : T
Input tensor
slope : T
Slope tensor. The shape of slope can be smaller then first input X; if so, its shape must be unidirectional broadcastable to X

Outputs

Y : T
Output tensor (same size as X)

Type Constraints

T : tensor(float16), tensor(float), tensor(double), tensor(uint32), tensor(uint64), tensor(int32), tensor(int64)
Constrain input and output types to float/int tensors.

Scan-9

Scan can be used to iterate over one or more scan_input tensors, constructing zero or more scan_output tensors. It combines ideas from general recurrences, functional programming constructs such as scan, fold, map, and zip and is intended to enable generalizations of RNN-like constructs for sequence-to-sequence processing. Other tensors (referred to as state_variables here) can be used to carry a state when iterating from one element to another (similar to hidden-state in RNNs, also referred to as loop-carried dependences in the context of loops). Many common usages involve a single scan_input tensor (where functionality similar to scan, fold and map can be obtained). When more than one scan_input is used, a behavior similar to zip is obtained.

The attribute body must be a graph, specifying the computation to be performed in every iteration. It takes as input the current values of the state_variables and the current iterated element of the scan_inputs. It must return the (updated) values of the state_variables and zero or more scan_output_element tensors. The values of the scan_output_element tensors are concatenated over all the iterations to produce the scan_output values of the scan construct (similar to the concatenated intermediate hidden-state values of RNN-like constructs). All the output tensors (state_variables as well as scan_output_element tensors) are required to have the same shape in each iteration of the loop (a restriction imposed to enable efficient memory allocation).

Note that the iterated element passed to the body subgraph does not have a sequence axis. It will have a rank one less than the rank of the corresponding scan_input.

The scan operation returns the final values of the state_variables as well as the scan_outputs.

The optional attribute scan_input_directions specifies the direction (forward or backward) for each scan input. If this attribute is omitted, all sequences are scanned in the forward direction. A bidirectional scan may be performed by specifying the same tensor input twice in the scan_inputs, once with a forward direction, and once with a backward direction.

The scan_output of the operation is produced by concatenating the scan_output_element values produced by the body in each iteration. The optional attribute scan_output_directions specifies the direction in which scan_output is constructed (by appending or prepending the scan_output_element to scan_output in each iteration) for each scan_output. If this attribute is omitted, the scan_output_element is appended to the scan_output in each iteration.

The optional attribute scan_input_axes specifies the axis to be scanned for each scan_input. If omitted, every scan_input will be scanned in axis 0. For example, if axis 0 is the batch axis and axis 1 is the time axis (to be scanned), specify an axis value of 1. Note that scanning a non-zero axis may be less efficient than scanning axis zero.

The optional attribute scan_output_axes specifies the axis along which the scan_outputs are accumulated for each scan_output. For example, if axis 1 is the time axis (to be scanned) for both inputs and outputs, specify a scan_input axis and scan_output axis value of 1.

Note that because of the ONNX restriction that only the last parameter of an operator can be variadic, the initial-states and scan-inputs are listed together as one input parameter. Similarly, the final-states and scan-outputs are listed together as one output parameter. The attribute num_scan_inputs indicates the number M of scan-inputs.

The behavior of

  Scan <
      num_scan_inputs = m,
      body = loop-body,
      scan_input_axes = [axis_1, ..., axis_m]
  > (init_1, ..., init_n, scan_1, ..., scan_m)

is equivalent to the following pseudo-code:

  // scan_i.shape[axis_i] denotes the (max) sequence-length of scan_i
  // scan_i.shape[axis_i] is required to be equal to scan_j.shape[axis_j] for all i,j.
  sequence_length = scan_1.shape[axis_1];

  // initialize state-variables
  st_1 = init_1; ... st_n = init_n;
  // initialize scan-output variables: [] denotes an empty tensor
  scan_out_1 = []; ...; scan_out_k = [];
  // identify number of iterations:

  // execute loop
  for (int t = 0; t < sequence_length; ++t) {
      // generate the scan-input elements: the notation T<axis=k>[t] indicates the sub-tensor
      // of rank one less than T obtained by indexing T at position t along axis k.
      si_1 = scan_1<axis=axis_1>[t];
      ... ;
      si_m = scan_m<axis=axis_m>[t];
      // execute loop-body
      st_1, ..., st_n, so_1, ..., so_k = loop-body(st_1, ..., st_n, si_1, ..., si_m)
      // accumulate the scan-output elements
      scan_out_1 = Concat<axis=0>(scan_out_1, so_1); ... ; scan_out_k = Concat<axis=0>(scan_out_k, so_k);
  }

  return st_1, ..., st_n, scan_out_1, ..., scan_out_k;

Sample usage: Encoding RNN using a Scan

The following example shows how a simple RNN over an input tensor %X, with weight tensor %Wi, recurrence weight tensor %Ri, bias tensors %Wbi and %Rbi, and initial hidden-state %H_0 can be encoded as a ScanLoop. Note that the loop-body is a nested graph, and it directly computes %Wi, %Ri, %Wbi, and %Rbi (typically constants or initializers in the body graph). If these values are computed in the outer graph, they need to be passed in as extra state_variables.

  graph rnn-encoding {
    %H_0 = ...
    %X = ...
    %Y_h, %Y = Scan[body = <graph rnn-cell-1>, num_scan_inputs=1](%H_0, %X)
    return %Y, %Y_h
  }

  graph rnn-cell-1 (
    %H_tminus1[FLOAT, tensor]
    %X_t[FLOAT, tensor]
  ) {
    %Wi = ...
    %Ri = ...
    %Wbi = ...
    %Rbi = ...
    %t1 = X_t * (Wi^T)
    %t2 = H_tminus1*(Ri^T)
    %t3 = Add(%t1, %t2)
    %t4 = Add(%t3, %Wbi)
    %t5 = Add(%t4, %Rbi)
    %Ht = Tanh(%t5)
    %Accumulate = Identity(%Ht)
    return %Ht, %Accumulate
  }

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

body : graph (required)
The graph run each iteration. It has N+M inputs: (loop state variables..., scan_input_elts...). It has N+K outputs: (loop state variables..., scan_output_elts...). Each scan_output is created by concatenating the value of the specified scan_output_elt value at the end of each iteration of the loop. It is an error if the dimensions of these values change across loop iterations.
num_scan_inputs : int (required)
An attribute specifying the number of scan_inputs M.
scan_input_axes : list of ints
An optional list of M flags. The i-th element of the list specifies the axis to be scanned (the sequence axis) for the i-th scan_input. If omitted, 0 will be used as the scan axis for every scan_input.
scan_input_directions : list of ints
An optional list of M flags. The i-th element of the list specifies the direction to be scanned for the i-th scan_input tensor: 0 indicates forward direction and 1 indicates reverse direction. If omitted, all scan_input tensors will be scanned in the forward direction.
scan_output_axes : list of ints
An optional list of K flags. The i-th element of the list specifies the axis for the i-th scan_output. The scan outputs are accumulated along the specified axis. If omitted, 0 will be used as the scan axis for every scan_output.
scan_output_directions : list of ints
An optional list of K flags, one for each scan_output. The i-th element of the list specifies whether the i-th scan_output should be constructed by appending or prepending a new value in each iteration: 0 indicates appending and 1 indicates prepending. If omitted, all scan_output tensors will be produced by appending a value in each iteration.

Inputs (1 - ∞)

initial_state_and_scan_inputs (variadic, heterogeneous) : V
Initial values of the loop's N state variables followed by M scan_inputs

Outputs (1 - ∞)

final_state_and_scan_outputs (variadic, heterogeneous) : V
Final values of the loop's N state variables followed by K scan_outputs

Type Constraints

I : tensor(int64)
Int64 tensor
V : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
All Tensor types

Scatter-9

Given data, updates and indices input tensors of rank r >= 1, write the values provided by updates into the first input, data, along axis dimension of data (by default outer-most one as axis=0) at corresponding indices. For each entry in updates, the target index in data is specified by corresponding entry in indices for dimension = axis, and index in source for dimension != axis. For instance, in a 2-D tensor case, data[indices[i][j]][j] = updates[i][j] if axis = 0, or data[i][indices[i][j]] = updates[i][j] if axis = 1, where i and j are loop counters from 0 up to the respective size in updates - 1. Example 1: data = [ [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], ] indices = [ [1, 0, 2], [0, 2, 1], ] updates = [ [1.0, 1.1, 1.2], [2.0, 2.1, 2.2], ] output = [ [2.0, 1.1, 0.0] [1.0, 0.0, 2.2] [0.0, 2.1, 1.2] ] Example 2: data = [[1.0, 2.0, 3.0, 4.0, 5.0]] indices = [[1, 3]] updates = [[1.1, 2.1]] axis = 1 output = [[1.0, 1.1, 3.0, 2.1, 5.0]]

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

axis : int (default is 0)
Which axis to scatter on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1]

Inputs

data : T
Tensor of rank r >= 1.
indices : Tind
Tensor of int32/int64 indices, of r >= 1 (same rank as input).
updates : T
Tensor of rank r >=1 (same rank and shape as indices)

Outputs

output : T
Tensor of rank r >= 1 (same rank as input).

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Input and output types can be of any tensor type.
Tind : tensor(int32), tensor(int64)
Constrain indices to integer types

Shrink-9

Shrink takes one input data (Tensor) and produces one Tensor output, having same datatype and shape with input. It has two attributes, lambd and bias. The formula of this operator is: If x < -lambd, y = x + bias; If x > lambd, y = x - bias; Otherwise, y = 0.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

bias : float (default is 0.0)
The bias value added to output. Default is 0.
lambd : float (default is 0.5)
The lambd value for the Shrink formulation. Default is 0.5.

Inputs

input : T
The input data as Tensor.

Outputs

output : T
The output.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrains input to only numeric types.

Sign-9

Calculate the sign of the given input tensor element-wise. If input > 0, output 1. if input < 0, output -1. if input == 0, output 0.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The sign of the input tensor computed element-wise. It has the same shape and type of the input.

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double)
Constrain input and output types to all numeric tensors.

Sinh-9

Calculates the hyperbolic sine of the given input tensor element-wise.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Inputs

input : T
Input tensor

Outputs

output : T
The hyperbolic sine values of the input tensor computed element-wise

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

TfIdfVectorizer-9

This transform extracts n-grams from the input sequence and save them as a vector. Input can be either a 1-D or 2-D tensor. For 1-D input, output is the n-gram representation of that input. For 2-D input, the output is also a 2-D tensor whose i-th row is the n-gram representation of the i-th input row. More specifically, if input shape is [C], the corresponding output shape would be [max(ngram_indexes) + 1]. If input shape is [N, C], this operator produces a [N, max(ngram_indexes) + 1]-tensor.

In contrast to standard n-gram extraction, here, the indexes of extracting an n-gram from the original sequence are not necessarily consecutive numbers. The discontinuity between indexes are controlled by the number of skips. If the number of skips is 2, we should skip two tokens when scanning through the original sequence. Let's consider an example. Assume that input sequence is [94, 17, 36, 12, 28] and the number of skips is 2. The associated 2-grams are [94, 12] and [17, 28] respectively indexed by [0, 3] and [1, 4]. If the number of skips becomes 0, the 2-grams generated are [94, 17], [17, 36], [36, 12], [12, 28] indexed by [0, 1], [1, 2], [2, 3], [3, 4], respectively.

The output vector (denoted by Y) stores the count of each n-gram; Y[ngram_indexes[i]] indicates the times that the i-th n-gram is found. The attribute ngram_indexes is used to determine the mapping between index i and the corresponding n-gram's output coordinate. If pool_int64s is [94, 17, 17, 36], ngram_indexes is [1, 0], ngram_counts=[0, 0], then the Y[0] (first element in Y) and Y[1] (second element in Y) are the counts of [17, 36] and [94, 17], respectively. An n-gram which cannot be found in pool_strings/pool_int64s should be ignored and has no effect on the output. Note that we may consider all skips up to S when generating the n-grams.

The examples used above are true if mode is "TF". If mode is "IDF", all the counts larger than 1 would be truncated to 1 and the i-th element in weights would be used to scale (by multiplication) the count of the i-th n-gram in pool. If mode is "TFIDF", this operator first computes the counts of all n-grams and then scale them by the associated values in the weights attribute.

Only one of pool_strings and pool_int64s can be set. If pool_int64s is set, the input should be an integer tensor. If pool_strings is set, the input must be a string tensor.

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

max_gram_length : int (required)
Maximum n-gram length. If this value is 3, 3-grams will be used to generate the output.
max_skip_count : int (required)
Maximum number of items (integers/strings) to be skipped when constructing an n-gram from X. If max_skip_count=1, min_gram_length=2, max_gram_length=3, this operator may generate 2-grams with skip_count=0 and skip_count=1, and 3-grams with skip_count=0 and skip_count=1
min_gram_length : int (required)
Minimum n-gram length. If this value is 2 and max_gram_length is 3, output may contain counts of 2-grams and 3-grams.
mode : string (required)
The weighting criteria. It can be one of "TF" (term frequency), "IDF" (inverse document frequency), and "TFIDF" (the combination of TF and IDF)
ngram_counts : list of ints (required)
The starting indexes of 1-grams, 2-grams, and so on in pool. It is useful when determining the boundary between two consecutive collections of n-grams. For example, if ngram_counts is [0, 17, 36], the first index (zero-based) of 1-gram/2-gram/3-gram in pool are 0/17/36. This format is essentially identical to CSR (or CSC) sparse matrix format, and we choose to use this due to its popularity.
ngram_indexes : list of ints (required)
list of int64s (type: AttributeProto::INTS). This list is parallel to the specified 'pool_*' attribute. The i-th element in ngram_indexes indicate the coordinate of the i-th n-gram in the output tensor.
pool_int64s : list of ints
List of int64 n-grams learned from the training set. Either this or pool_strings attributes must be present but not both. It's an 1-D tensor starting with the collections of all 1-grams and ending with the collections of n-grams. The i-th element in pool stores the n-gram that should be mapped to coordinate ngram_indexes[i] in the output vector.
pool_strings : list of strings
List of strings n-grams learned from the training set. Either this or pool_int64s attributes must be present but not both. It's an 1-D tensor starting with the collections of all 1-grams and ending with the collections of n-grams. The i-th element in pool stores the n-gram that should be mapped to coordinate ngram_indexes[i] in the output vector.
weights : list of floats
list of floats. This attribute stores the weight of each n-gram in pool. The i-th element in weights is the weight of the i-th n-gram in pool. Its length equals to the size of ngram_indexes. By default, weights is an all-one tensor.This attribute is used when mode is "IDF" or "TFIDF" to scale the associated word counts.

Inputs

X : T
Input for n-gram extraction

Outputs

Y : T1
Ngram results

Type Constraints

T : tensor(string), tensor(int32), tensor(int64)
Input is ether string UTF-8 or int32/int64
T1 : tensor(float)
1-D tensor of floats

Upsample-9

Upsample the input tensor. Each dimension value of the output tensor is: output_dimension = floor(input_dimension * scale).

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Attributes

mode : string (default is nearest)
Two interpolation modes: nearest (default), and linear (including bilinear, trilinear, etc)

Inputs

X : T
N-D tensor
scales : tensor(float)
The scale array along each dimension. It takes value greater than or equal to 1. The number of elements of 'scales' should be the same as the rank of input 'X'.

Outputs

Y : T
N-D tensor after resizing

Type Constraints

T : tensor(uint8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(int8), tensor(int16), tensor(int32), tensor(int64), tensor(float16), tensor(float), tensor(double), tensor(string), tensor(bool), tensor(complex64), tensor(complex128)
Constrain input 'X' and output 'Y' to all tensor types.

Where-9

Return elements, either from X or Y, depending on condition (with Numpy-style broadcasting support). Where behaves like numpy.where with three parameters: https://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html

Version

This version of the operator has been available since version 9 of the default ONNX operator set.

Inputs

condition : B
When True (nonzero), yield X, otherwise yield Y
X : T
values selected at indices where condition is True
Y : T
values selected at indices where condition is False