GlobalAveragePool - 1#
shape inference: True
This version of the operator has been available since version 1.
GlobalAveragePool consumes an input tensor X and applies average pooling across the values in the same channel. This is equivalent to AveragePool with kernel size equal to the spatial dimension of input tensor.
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.
Y (heterogeneous) - T: Output data tensor from pooling across the input tensor. The output tensor has the same rank as the input. The first two dimensions of output shape are the same as the input (N x C), while the other dimensions are all 1.
T in ( tensor(double), tensor(float), tensor(float16) ): Constrain input and output types to float tensors.
node = onnx.helper.make_node( "GlobalAveragePool", inputs=["x"], outputs=["y"], ) x = np.random.randn(1, 3, 5, 5).astype(np.float32) y = np.mean(x, axis=tuple(range(2, np.ndim(x))), keepdims=True) expect(node, inputs=[x], outputs=[y], name="test_globalaveragepool")
node = onnx.helper.make_node( "GlobalAveragePool", inputs=["x"], outputs=["y"], ) x = np.array( [ [ [ [1, 2, 3], [4, 5, 6], [7, 8, 9], ] ] ] ).astype(np.float32) y = np.array([[[]]]).astype(np.float32) expect(node, inputs=[x], outputs=[y], name="test_globalaveragepool_precomputed")