ttnn.global_avg_pool2d
- ttnn.global_avg_pool2d = Operation(python_fully_qualified_name='ttnn.global_avg_pool2d', function=<ttnn._ttnn.operations.pool.global_avg_pool2d_t object>, preprocess_golden_function_inputs=<function default_preprocess_golden_function_inputs>, golden_function=<function golden_global_avg_pool2d>, postprocess_golden_function_outputs=<function default_postprocess_golden_function_outputs>, is_cpp_operation=True, is_experimental=False)
-
Applies global_avg_pool2d to
input_tensor
by performing a 2D adaptive average pooling over an input signal composed of several input planes. This operation computes the average of all elements in each channel across the entire spatial dimensions.\[\begin{split}global_avg_pool2d(\\mathrm{input\\_tensor}_i)\end{split}\]- Parameters:
-
input_tensor (ttnn.Tensor) – the input tensor. Typically of shape (batch_size, channels, height, width).
- Keyword Arguments:
-
memory_config (ttnn.MemoryConfig, optional) – Memory configuration for the operation. Defaults to None.
dtype (ttnn.DataType, optional) – data type for the output tensor. Defaults to None
- Returns:
-
ttnn.Tensor – the output tensor with the averaged values. The output tensor shape is (batch_size, channels, 1, 1).
Example
>>> tensor = ttnn.from_torch(torch.randn((10, 3, 32, 32), dtype=ttnn.bfloat16), device=device) >>> output = ttnn.global_avg_pool2d(tensor)