Skip to content

Latest commit

 

History

History
5700 lines (4066 loc) · 151 KB

Operators.md

File metadata and controls

5700 lines (4066 loc) · 151 KB

Operator Schemas

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

ai.onnx (default)

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

Examples

abs
node = onnx.helper.make_node(
    'Abs',
    inputs=['x'],
    outputs=['y'],
)
x = np.random.randn(3, 4, 5).astype(np.float32)
y = np.abs(x)

expect(node, inputs=[x], outputs=[y],
       name='test_abs')

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 size 1 (a scalar value), 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
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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
If set, defines the broadcast dimensions. See doc for details.
broadcast : int
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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Examples

add
node = onnx.helper.make_node(
    'Add',
    inputs=['x', 'y'],
    outputs=['sum'],
)

x = np.random.randn(3, 4, 5).astype(np.float32)
y = np.random.randn(3, 4, 5).astype(np.float32)
expect(node, inputs=[x, y], outputs=[x + y],
       name='test_add')
add_broadcast
node = onnx.helper.make_node(
    'Add',
    inputs=['x', 'y'],
    outputs=['sum'],
    broadcast=1,
)

x = np.random.randn(3, 4, 5).astype(np.float32)
y = np.random.randn(5).astype(np.float32)
expect(node, inputs=[x, y], outputs=[x + y],
       name='test_add_bcast')

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
If set, defines the broadcast dimensions.
broadcast : int
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.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

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

Inputs

data : T
An input tensor.

Outputs

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

Type Constraints

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

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

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

Inputs

data : T
An input tensor.

Outputs

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

Type Constraints

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

AveragePool consumes an input tensor X and applies average pooling across the 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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

auto_pad : string
auto_pad must be either SAME_UPPER, SAME_LOWER or VALID. Where SAME_UPPER or SAME_LOWER mean pad the input so that the ouput size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the begining 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.
pads : list of ints
Padding for the begining 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 begining 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 begining 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 average or max 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.

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)

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

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

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.

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. If the 'to' argument is not provided or is not one of the enumerated types in DataType, Caffe2 throws an Enforce error.

NOTE: Casting to and from strings is not supported yet.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

to : string
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)
Constrain input types to float tensors.
T2 : tensor(float16), tensor(float), tensor(double)
Constrain output types to float tensors.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

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.

Concatenate a list of tensors into a single tensor

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
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(float16), tensor(float), tensor(double)
Constrain output types to float tensors.

A constant tensor.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

value : tensor
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.

Examples

constant
values = np.random.randn(5, 5).astype(np.float32)
node = onnx.helper.make_node(
    'Constant',
    inputs=[],
    outputs=['values'],
    value=onnx.helper.make_tensor(
        name='const_tensor',
        data_type=onnx.TensorProto.FLOAT,
        dims=values.shape,
        vals=values.flatten().astype(float),
    ),
)

expect(node, inputs=[], outputs=[values],
       name='test_constant')

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

auto_pad : string
auto_pad must be either SAME_UPPER, SAME_LOWER or VALID. Where SAME_UPPER or SAME_LOWER mean pad the input so that the ouput size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the begining 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.
dilations : list of ints
dilation value along each axis of the filter.
group : int
number of groups input channels and output channels are divided into
kernel_shape : list of ints
The shape of the convolution kernel.
pads : list of ints
Padding for the begining 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 begining 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 begining 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 (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 D1 x D2 ... x Dn)
W : T
The weight tensor that will be used in the convolutions; has size (M x C 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 x k1 x k2 x ... x kn), where is the dimension of the kernel
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.

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

auto_pad : string
auto_pad must be either SAME_UPPER, SAME_LOWER or VALID. Where SAME_UPPER or SAME_LOWER mean pad the input so that the ouput size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the begining 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.
dilations : list of ints
dilation value along each axis of the filter.
group : int
number of groups input channels and output channels are divided into
kernel_shape : list of ints
The shape of the convolution kernel.
output_shape : list of ints
The shape of the output.
pads : list of ints
Padding for the begining 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 begining 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 begining 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 (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 D1 x D2 ... x Dn)
W : T
The weight tensor that will be used in the convolutions; has size (C x M 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 (C x M x k1 x k2 x ... x kn), where is the dimension of the kernel
B (optional) : T
Optional 1D bias to be added to the convolution, has size of C.

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.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

blocksize : int
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(float16), tensor(float), tensor(double)
Constrain input types to float tensors.

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 size 1 (a scalar value), 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
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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
If set, defines the broadcast dimensions. See doc for details.
broadcast : int
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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

is_test : int
(int, default 0) if nonzero, run dropout in test mode where the output is simply Y = X.
ratio : float
(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 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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

alpha : float
Coefficient of ELU default to 1.0.

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.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
If set, defines the broadcast dimensions.
broadcast : int
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.

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
(Default to 1) Indicate up to which input dimensions (exclusive) should be flattened to the outer dimension of the output

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 takes one input data (Tensor) and produces one output data (Tensor) where the floor is, y = floor(x), is applied to the tensor elementwise.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

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)

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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

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], ], ]

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

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

Inputs

data : T
Tensor of rank r >= 1.
indices : Tind
Tensor of int32/int64 indices, of any rank q.

Outputs

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

Type Constraints

T : tensor(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.
Tind : tensor(int32), tensor(int64)
Constrain indices to integer types

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. If A can be transposed before doing the computation if attribute transA is non-zero, same for B and transB.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

alpha : float
Scalar multiplier for the product of input tensors A * B
beta : float
Scalar multiplier for input tensor C
broadcast : int
Whether C should be broadcasted
transA : int
Whether A should be transposed
transB : int
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 consumes an input tensor X and applies average pooling across the the values in the same channel. This is equivalent to AveragePool with kernel size equal to the spatial dimension of input tensor.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 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 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.

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.

Versioning

This operator is used if you are using version 2 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 2
}

Other versions of this operator: GlobalLpPool-1

Attributes

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

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 consumes an input tensor X and applies max pooling across the the values in the same channel. This is equivalent to MaxPool with kernel size equal to the spatial dimension of input tensor.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 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 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.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
If set, defines the broadcast dimensions.
broadcast : int
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 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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

alpha : float
Value of alpha
beta : float
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.

The operator computes the hardmax normalized 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 normalized values of the corresponding input.

X does not need to explicitly be a 2D vector; rather, it will be coerced into one. For an arbitrary n-dimensional tensor X \in [a_0, a_1, ..., a_{k-1}, a_k, ..., a_{n-1}] and k is the axis provided, then X 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 X 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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
(int) default to 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 softmax normalized output values with the same shape as input tensor.

Type Constraints

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

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 B are computed per instance per channel.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

epsilon : float
The epsilon value to use to avoid division by zero.

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.

Local Response Normalization. It normalizes over local input regions. Each input value is divided by (bias+(alpha/size)*sum(xi^2 for every xi in the local region))^beta.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

alpha : float (required)
Scaling parameter
beta : float (required)
The exponent
bias : float
Default to 1
size : int (required)
The number of channels to sum over

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.

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)

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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 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
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
Couple the input and forget gates if 1, default 0.
output_sequence : int
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

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.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

alpha : float
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.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
If set, defines the broadcast dimensions.
broadcast : int
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.

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

The operator computes the logsoftmax normalized 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 normalized values of the corresponding input.

X does not need to explicitly be a 2D vector; rather, it will be coerced into one. For an arbitrary n-dimensional tensor X \in [a_0, a_1, ..., a_{k-1}, a_k, ..., a_{n-1}] and k is the axis provided, then X 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 X 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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
(int) default to 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 softmax normalized output values with the same shape as input tensor.

Type Constraints

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

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
(int64, default -1) the axis on which to apply normalization, -1 mean last axis.
p : int
(int64, default 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 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.

Versioning

This operator is used if you are using version 2 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 2
}

Other versions of this operator: LpPool-1

Attributes

auto_pad : string
auto_pad must be either SAME_UPPER, SAME_LOWER or VALID. Where SAME_UPPER or SAME_LOWER mean pad the input so that the ouput size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the begining 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 : int
p value of the Lp norm used to pool over the input data, default is 2.
pads : list of ints
Padding for the begining 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 begining 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 begining 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.

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

Examples

matmul
node = onnx.helper.make_node(
    'MatMul',
    inputs=['a', 'b'],
    outputs=['c'],
)

# 2d
a = np.random.randn(3, 4).astype(np.float32)
b = np.random.randn(4, 3).astype(np.float32)
c = np.matmul(a, b)
expect(node, inputs=[a, b], outputs=[c],
       name='test_matmul_2d')

# 3d
a = np.random.randn(2, 3, 4).astype(np.float32)
b = np.random.randn(2, 4, 3).astype(np.float32)
c = np.matmul(a, b)
expect(node, inputs=[a, b], outputs=[c],
       name='test_matmul_3d')

# 4d
a = np.random.randn(1, 2, 3, 4).astype(np.float32)
b = np.random.randn(1, 2, 4, 3).astype(np.float32)
c = np.matmul(a, b)
expect(node, inputs=[a, b], outputs=[c],
       name='test_matmul_4d')

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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 consumes an input tensor X and applies max pooling across the 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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

auto_pad : string
auto_pad must be either SAME_UPPER, SAME_LOWER or VALID. Where SAME_UPPER or SAME_LOWER mean pad the input so that the ouput size match the input.In case of odd number add the extra padding at the end for SAME_UPPER and at the begining 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.
pads : list of ints
Padding for the begining 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 begining 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 begining 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 average or max 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.

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

pooled_shape : list of ints
ROI pool output shape (height, width).
spatial_scale : float
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.

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

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 size 1 (a scalar value), 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
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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
If set, defines the broadcast dimensions. See doc for details.
broadcast : int
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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

Returns the negation of the input tensor element-wise.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Inputs

X : T
Input tensor

Outputs

Y : T
Output tensor

Type Constraints

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

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
If set, defines the broadcast dimensions.
broadcast : int
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 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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

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],
    ],
]

Versioning

This operator is used if you are using version 2 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 2
}

Other versions of this operator: Pad-1

Attributes

mode : string
Three modes: constant(default), reflect, edge
pads : list of ints (required)
List of integers indicate the padding element count at the begining and end of each axis, for 2D it is the number of pixel. `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 begining of axis `i` and xi_end, the number of pixels added at the end of axis `i`.
value : float
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.

Examples

constant_pad
node = onnx.helper.make_node(
    'Pad',
    inputs=['x'],
    outputs=['y'],
    mode='constant',
    value=1.2,
    pads=[0, 0, 1, 3, 0, 0, 2, 4],
)
x = np.random.randn(1, 3, 4, 5).astype(np.float32)
y = np.pad(
    x,
    pad_width=((0, 0), (0, 0), (1, 2), (3, 4)),
    mode='constant',
    constant_values=1.2,
)

expect(node, inputs=[x], outputs=[y],
       name='test_constant_pad')
reflection_and_edge_pad
for mode in ['edge', 'reflect']:
    node = onnx.helper.make_node(
        'Pad',
        inputs=['x'],
        outputs=['y'],
        mode=mode,
        pads=[0, 0, 1, 1, 0, 0, 1, 1]
    )
    x = np.random.randn(1, 3, 4, 5).astype(np.float32)
    y = np.pad(
        x,
        pad_width=((0, 0), (0, 0), (1, 1), (1, 1)),
        mode=mode,
    )

    expect(node, inputs=[x], outputs=[y],
           name='test_{}_pad'.format(mode))

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

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)

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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

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.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

dtype : int
The data type for the elements of the output tensor.
mean : float
The mean of the normal distribution.
scale : float
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
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 input and output types to float tensors.

Generate a tensor with random values drawn from a normal distribution. The shape of the tensor is computed from the input 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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

dtype : int
(Optional) The data type for the elements of the output tensor, if not specified, we will usethe data type of the input tensor.
mean : float
The mean of the normal distribution.
scale : float
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 : T
Input tensor to provide shape information.

Outputs

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

Type Constraints

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

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

dtype : int
The data type for the elements of the output tensor.
high : float
Upper boundary of the output values.
low : float
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
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 input and output types to float tensors.

Generate a tensor with random values drawn from a uniform distribution. The shape of the tensor is computed from the input 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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

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

Inputs

input : T
Input tensor to provide shape information.

Outputs

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

Type Constraints

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

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axes : list of ints
A list of integers, along which to reduce.
keepdims : int
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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axes : list of ints
A list of integers, along which to reduce.
keepdims : int
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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axes : list of ints
A list of integers, along which to reduce.
keepdims : int
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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axes : list of ints
A list of integers, along which to reduce.
keepdims : int
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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axes : list of ints
A list of integers, along which to reduce.
keepdims : int
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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axes : list of ints
A list of integers, along which to reduce.
keepdims : int
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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axes : list of ints
A list of integers, along which to reduce.
keepdims : int
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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axes : list of ints
A list of integers, along which to reduce.
keepdims : int
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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axes : list of ints
A list of integers, along which to reduce.
keepdims : int
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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axes : list of ints
A list of integers, along which to reduce.
keepdims : int
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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

Examples

relu
node = onnx.helper.make_node(
    'Relu',
    inputs=['x'],
    outputs=['y'],
)
x = np.random.randn(3, 4, 5).astype(np.float32)
y = np.clip(x, 0, np.inf)

expect(node, inputs=[x], outputs=[y],
       name='test_relu')

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 going to be copied from the shape argument.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

alpha : float
Coefficient of SELU default to 1.6732.
gamma : float
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.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

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.

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]
ends = [-1]

result = [
    [1, 2, 3, 4],
]

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

Examples

slice
node = onnx.helper.make_node(
    'Slice',
    inputs=['x'],
    outputs=['y'],
    axes=[0, 1],
    starts=[0, 0],
    ends=[3, 10],
)

x = np.random.randn(20, 10, 5).astype(np.float32)
y = x[0:3, 0:10]

expect(node, inputs=[x], outputs=[y],
       name='test_slice')
slice_default_axes
node = onnx.helper.make_node(
    'Slice',
    inputs=['x'],
    outputs=['y'],
    starts=[0, 0, 3],
    ends=[20, 10, 4],
)

x = np.random.randn(20, 10, 5).astype(np.float32)
y = x[:, :, 3:4]

expect(node, inputs=[x], outputs=[y],
       name='test_default_axes')
slice_neg
node = onnx.helper.make_node(
    'Slice',
    inputs=['x'],
    outputs=['y'],
    axes=[1],
    starts=[0],
    ends=[-1],
)

x = np.random.randn(20, 10, 5).astype(np.float32)
y = x[:, 0:-1]

expect(node, inputs=[x], outputs=[y],
       name='test_slice_neg')

The operator computes the softmax normalized 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 normalized values of the corresponding input.

X does not need to explicitly be a 2D vector; rather, it will be coerced into one. For an arbitrary n-dimensional tensor X \in [a_0, a_1, ..., a_{k-1}, a_k, ..., a_{n-1}] and k is the axis provided, then X 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 X 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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
(int) default to 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 softmax normalized output values with the same shape as input tensor.

Type Constraints

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

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Inputs

input : T
1-D 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 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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

blocksize : int
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(float16), tensor(float), tensor(double)
Constrain input types to float tensors.

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.

Versioning

This operator is used if you are using version 2 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 2
}

Other versions of this operator: Split-1

Attributes

axis : int
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(float16), tensor(float), tensor(double)
Constrain input types to float tensors.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

Remove single-dimensional entries from the shape of a tensor. Takes a parameter axes with a list of axes to squeeze.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axes : list of ints (required)
List of positive 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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

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 size 1 (a scalar value), 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
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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
If set, defines the broadcast dimensions. See doc for details.
broadcast : int
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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

Repeat the elements of a tensor along an axis.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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.

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

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(float16), tensor(float), tensor(double)
Constrain input and output types to float tensors.

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.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
If set, defines the broadcast dimensions.
broadcast : int
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.

experimental ATen

Experimental allowing ATen operations to be accessed directly from Caffe2 to allow for quick prototyping when ONNX is missing standard versions of and op

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Inputs (1 - ∞)

input (variadic) : T
Arbitrary input

Outputs (1 - ∞)

output (variadic) : T
Arbitrary output

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.

experimental Affine

Affine takes one input data (Tensor) and produces one output data (Tensor) where the affine function, y = alpha * x + beta, is applied to the tensor elementwise.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

alpha : float
Value of alpha
beta : float
Value of beta

Inputs

X : T
1D input tensor

Outputs

Y : T
1D output tensor

Type Constraints

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

experimental ConstantFill

The operator fills the elements of the output tensor with a constant value specified by the 'value' attribute.

The data type is specified by the 'dtype' attribute. The 'dtype' attribute must be one of the data types specified in the 'DataType' enum field in the TensorProto message. If the 'dtype' attribute is not provided, the data type of 'value' is used.

The output tensor shape is specified by the 'shape' attribute. If the number of input is 1, the shape will be identical to that of the input at run time with optional additional dimensions appended at the end as specified by 'extra_shape' attribute. In that case the 'shape' attribute should not be set.

If input_as_shape is set to true, then the input should be a 1D tensor containing the desired output shape (the dimensions specified in extra_shape will also be appended)

NOTE: Currently, it supports data type of float, int32, int64, and bool.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

dtype : int
The data type for the elements of the output tensor.Strictly must be one of the types from DataType enum in TensorProto.
extra_shape : list of ints
The additional dimensions appended at the end of the shape indicatedby the input blob.Cannot set the extra_shape argument when there is no input blob.
input_as_shape : int
1D tensor containing the desired output shape. First input must be in CPU context.
shape : list of ints
The shape of the output tensor.Cannot set the shape argument and pass in an input at the same time.
value : float
The value for the elements of the output tensor.

Inputs (0 - 1)

input (optional) : T1
Input tensor (optional) to provide shape information.

Outputs

output : T2
Output tensor of constant values specified by 'value'argument and its type is specified by the 'dtype' argument

Type Constraints

T1 : tensor(float), tensor(int32), tensor(int64), tensor(bool)
Constrain input types to float, int32, int64, bool tensors.
T2 : tensor(float), tensor(int32), tensor(int64), tensor(bool)
Constrain output types to float, int32, int64, bool tensors.

experimental Crop

Crop and image to the specified spatial dimensions. If scale is given, then optionally start the crop offset by the left/top border amounts. If scale is not provided, crop the borders as provided.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

border : list of ints
A 1-D values of (leftBorder, topBorder, rightBorder, bottomBorder).
scale : list of ints
A 1-D values of (height, width).

Inputs

input : T
Input tensor of shape [N,C,H,W]

Outputs

output : T
Result, has same type as input, with H and W dimensions reduced.

Type Constraints

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

experimental Embedding

Turns positive integers (indexes) into dense vectors of fixed size.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

input_dim : int
Size of the input vocabulary.
output_dim : int
Dimension of the embedding output vectors.
weights : tensor
2-D tensor of weights [O,I].

Inputs

input : tensor(int64)
1-D tensor of integers representing indices in the embedding dictionary with length [N] and values [0, input_dim -1]

Outputs

output : T
Output tensor of computed features [N, O].

Type Constraints

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

experimental FC

Computes the result of passing an input vector X into a fully connected layer with 2D weight matrix W and 1D bias vector b. That is, the layer computes Y = X * W^T + b, where X has size (M x K), W has size (N x K), b has size (N), and Y has size (M x N), where M is often the batch size. NOTE: X does not need to explicitly be a 2D vector; rather, it will be coerced into one. For an arbitrary n-dimensional tensor X \in [a_0, a_1, ...,a_{k-1}, a_k, ..., a_{n-1}] where a_i \in N+ and k is the axis provided, then X 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 X 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 = M and a_1 * ... * a_{n-1} = K. Lastly, even though b is a 1D vector of size N, it is copied/resized to be size (M x N) implicitly and added to each vector in the batch. Each of these dimensions must be matched correctly, or else the operator will throw errors.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

axis : int
(int32_t) default to 1; describes the axis of the inputs; defaults to one because the 0th axis most likely describes the batch_size
axis_w : int
(int32_t) default to 1; describes the axis of the weights; defaults to one because the 0th axis most likely describes the batch_size

Inputs

X : T
input tensor that's coerced into a 2D matrix of size (MxK) as described above
W : T
2D blob of size (KxN) containing fully connected weight matrix
B : T
1D blob containing bias vector

Outputs

Y : T
2D output tensor

Type Constraints

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

experimental GRUUnit

GRUUnit computes the activations of a standard GRU, in a sequence-length aware fashion. Concretely, given the (fused) inputs X (TxNxD), the previous hidden state (NxD), and the sequence lengths (N), computes the GRU activations, avoiding computation if the input is invalid (as in, the value at X[t][n] >= seqLengths[n].

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

drop_states : int
Bool to determine if hidden state is zeroes or passed along for timesteps past the given sequence_length.

Inputs

hidden_prev : T
The previous GRU hidden state.
gates : T
Unactivated gate outputs from forget, update, and output gates, pre-activation.
seq_lengths : T
Array of sequence lengths. len(seq_lengths) should equal batch size N.
t : T
The timestep for this operation.

Outputs

hidden : T
The new GRU hidden state calculated by this op.

Type Constraints

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

experimental GivenTensorFill

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

extra_shape : list of ints
input_as_shape : int
shape : list of ints
values : list of floats

Inputs (0 - 1)

shape (optional) : T
The shape of filled tensor

Outputs

X : T
The filled tensor

Type Constraints

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

experimental Identity

Identity operator

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Inputs

input : T
Input tensor

Outputs

output : T
Tensor to copy input into.

Type Constraints

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

experimental ImageScaler

Scale and bias the input image. Bias values are stored in the same ordering as the image pixel format.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

bias : list of floats
Bias applied to each channel, same size as C.
scale : float
(float, default 1.0) the scale to apply.

Inputs

input : T
Input tensor of shape [N,C,H,W]

Outputs

output : T
Result, has same shape and type as input

Type Constraints

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

Perform mean variance normalization.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

across_channels : int
If 1, mean and variance are computed across channels. Default is 0.
normalize_variance : int
If 0, normalize the mean only. Default is 1.

Inputs

input : T
Input tensor of shape [N,C,H,W]

Outputs

output : T
Result, has same shape and type as input

Type Constraints

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

experimental ParametricSoftplus

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

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

alpha : float
Value of alpha
beta : float
Value of beta

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.

experimental Scale

Scale takes one input data (Tensor) and produces one output data (Tensor) whose value is the input data tensor scaled element-wise.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

scale : float
(float, default 1.0) the scale to apply.

Inputs

input : T
Input data to be scaled

Outputs

output : T
Output data after scaling

Type Constraints

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

experimental ScaledTanh

Calculates the scaled hyperbolic tangent of the given input tensor element-wise, alpha * tanh(beta * x). This operation can be done in an in-place fashion too, by providing the same input and output blobs.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

alpha : float
Scaling value
beta : float
Scaling value

Inputs

input : T
1-D input tensor

Outputs

output : T
The scaled 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.

experimental ThresholdedRelu

ThresholdedRelu takes one input data (Tensor) and produces one output data (Tensor) where the rectified linear function, y = x for x > alpha, y = 0 otherwise, is applied to the tensor elementwise.

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

alpha : float
Threshold value

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.

experimental Upsample

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

Exmpale: 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]
]]]

Versioning

This operator is used if you are using version 1 of the default ONNX operator set until the next BC-breaking change to this operator; e.g., it will be used if your protobuf has:

opset_import {
  version = 1
}

Attributes

height_scale : float (required)
The scale along height dimension. It takes value greater than or equal to 1.
mode : string
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.