module onnxrt.ops_cpu.op_average_pool#

Inheritance diagram of mlprodict.onnxrt.ops_cpu.op_average_pool

Short summary#

module mlprodict.onnxrt.ops_cpu.op_average_pool

Runtime operator.

source on GitHub

Classes#

class

truncated documentation

AveragePool

AveragePool =========== AveragePool consumes an input tensor X and applies average pooling across the tensor according …

Functions#

function

truncated documentation

_get_output_shape

_get_output_shape_no_ceil

_get_pad_shape

_pool

Properties#

property

truncated documentation

args_default

Returns the list of arguments as well as the list of parameters with the default values (close to the signature). …

args_default_modified

Returns the list of modified parameters.

args_mandatory

Returns the list of optional arguments.

args_optional

Returns the list of optional arguments.

atts_value

Returns all parameters in a dictionary.

Methods#

method

truncated documentation

__init__

_run

Documentation#

Runtime operator.

source on GitHub

class mlprodict.onnxrt.ops_cpu.op_average_pool.AveragePool(onnx_node, desc=None, **options)#

Bases: OpRun

AveragePool consumes an input tensor X and applies average pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. average pooling consisting of computing the average on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape will be following: `` output_spatial_shape[i] = floor((input_spatial_shape[i] + pad_shape[i] - kernel_spatial_shape[i]) / strides_spatial_shape[i] + 1) `` or `` output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[i] - kernel_spatial_shape[i]) / 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) / strides_spatial_shape[i]) SAME_UPPER or SAME_LOWER: output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides_spatial_shape[i]) `` And pad shape will be following if SAME_UPPER or SAME_LOWER: `` pad_shape[i] = (output_spatial_shape[i] - 1) * strides_spatial_shape[i] + kernel_spatial_shape[i] - input_spatial_shape[i] `` The output of each pooling window is divided by the number of elements (exclude pad when attribute count_include_pad is zero).

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)

  • count_include_pad: Whether include pad pixels when calculating values for the edges. Default is 0, doesn’t count include pad. Default value is namecountincludepadi0typeINT (INT)

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

  • 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

  • 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

Type Constraints

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

Version

Onnx name: AveragePool

This version of the operator has been available since version 11.

Runtime implementation: AveragePool

__init__(onnx_node, desc=None, **options)#
_run(x, attributes=None, verbose=0, fLOG=None)#

Should be overwritten.

source on GitHub

mlprodict.onnxrt.ops_cpu.op_average_pool._get_output_shape(auto_pad, input_spatial_shape, kernel_spatial_shape, strides_spatial, pad_shape=None, ceil_mode=0)#
mlprodict.onnxrt.ops_cpu.op_average_pool._get_output_shape_no_ceil(auto_pad, input_spatial_shape, kernel_spatial_shape, strides_spatial)#
mlprodict.onnxrt.ops_cpu.op_average_pool._get_pad_shape(auto_pad, input_spatial_shape, kernel_spatial_shape, strides_spatial, output_spatial_shape)#
mlprodict.onnxrt.ops_cpu.op_average_pool._pool(padded, x_shape, kernel_shape, strides_shape, out_shape, pad_shape, pooling_type, count_include_pad=0, ceil_mode=0)#