module onnxrt.ops_cpu.op_max_pool
#
Short summary#
module mlprodict.onnxrt.ops_cpu.op_max_pool
Runtime operator.
Classes#
class |
truncated documentation |
---|---|
MaxPool ======= MaxPool consumes an input tensor X and applies max pooling across the tensor according to kernel sizes, … |
Functions#
function |
truncated documentation |
---|---|
Properties#
property |
truncated documentation |
---|---|
|
Returns the list of arguments as well as the list of parameters with the default values (close to the signature). … |
|
Returns the list of modified parameters. |
|
Returns the list of optional arguments. |
|
Returns the list of optional arguments. |
|
Returns all parameters in a dictionary. |
Methods#
method |
truncated documentation |
---|---|
Documentation#
Runtime operator.
- class mlprodict.onnxrt.ops_cpu.op_max_pool.MaxPool(onnx_node, desc=None, **options)#
Bases:
OpRun
MaxPool consumes an input tensor X and applies max pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. max pooling consisting of computing the max on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following: `` output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1)) / strides_spatial_shape[i] + 1) `` or `` output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1)) / strides_spatial_shape[i] + 1) `` if ceil_mode is enabled
`` * pad_shape[i] is sum of pads along axis i ``
auto_pad is a DEPRECATED attribute. If you are using them currently, the output spatial shape will be following: `` VALID: output_spatial_shape[i] = ceil((input_spatial_shape[i] - ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) + 1) / strides_spatial_shape[i]) SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i]) `` And pad shape will be following if SAME_UPPER or SAME_LOWER: `` pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + ((kernel_spatial_shape[i] - 1) * dilations[i] + 1) - input_spatial_shape[i] `` The output of each pooling window is maximum number of elements exclude pad.
Attributes
auto_pad: auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER. Default value is
nameautopadsNOTSETtypeSTRING
(STRING)ceil_mode: Whether to use ceil or floor (default) to compute the output shape. Default value is
nameceilmodei0typeINT
(INT)dilations: Dilation value along each spatial axis of filter. If not present, the dilation defaults to 1 along each spatial axis. default value cannot be automatically retrieved (INTS)
kernel_shape (required): The size of the kernel along each axis. default value cannot be automatically retrieved (INTS)
pads: Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. pads format should be as follow [x1_begin, x2_begin…x1_end, x2_end,…], where xi_begin the number of pixels added at the beginning of axis i and xi_end, the number of pixels added at the end of axis i. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis. default value cannot be automatically retrieved (INTS)
storage_order: The storage order of the tensor. 0 is row major, and 1 is column major. This attribute is used only to convert an n-tuple index value into a single integer value for producing the second output. Default value is
namestorageorderi0typeINT
(INT)strides: Stride along each spatial axis. If not present, the stride defaults to 1 along each spatial axis. default value cannot be automatically retrieved (INTS)
Inputs
X (heterogeneous)T: Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 … Dn), where N is the batch size. Optionally, if dimension denotation is in effect, the operation expects the input data tensor to arrive with the dimension denotation of [DATA_BATCH, DATA_CHANNEL, DATA_FEATURE, DATA_FEATURE …].
Outputs
Between 1 and 2 outputs.
Y (heterogeneous)T: Output data tensor from average or max pooling across the input tensor. Dimensions will vary based on various kernel, stride, and pad sizes. Floor value of the dimension is used
Indices (optional, heterogeneous)I: Indices tensor from max pooling across the input tensor. The dimensions of indices are the same as output tensor. The values in indices of are the indices of the selected values during pooling. The indices are computed as flatten 1-D tensor, and the indices do not consider padding. So the values in indices are in [0, N x C x D1 x … x Dn).
Type Constraints
T tensor(float16), tensor(float), tensor(double), tensor(int8), tensor(uint8): Constrain input and output types to float and 8 bit tensors.
I tensor(int64): Constrain index tensor to int64
Version
Onnx name: MaxPool
This version of the operator has been available since version 12.
Runtime implementation:
MaxPool
- __init__(onnx_node, desc=None, **options)#
- _init()#
- _run(X, attributes=None, verbose=0, fLOG=None)#
Should be overwritten.
- mlprodict.onnxrt.ops_cpu.op_max_pool._pool_get_output_shape(auto_pad, input_spatial_shape, kernel_spatial_shape, strides_spatial)#
- mlprodict.onnxrt.ops_cpu.op_max_pool._pool_impl(padded, x_shape, kernel_shape, strides_shape, out_shape, pad_shape, pooling_type, count_include_pad=0)#