oa::ml::matrix::avg_pool_2d

Apply two-dimensional average pooling to an NCHW Matrix. Padding positions do not contribute to either the sum or divisor. The output spatial extent is floor((input + 2 * padding - kernel_size) / stride) + 1, matching the OA C++ operation. Errors Returns an error unless input is a nonempty rank-four F32 Matrix, kernel_size and stride are nonzero, the kernel fits the padded input, every shader extent is representable, or runtime recording fails.

FnRust public API

Function Documentation

pub fn avg_pool_2d( input: &Matrix, kernel_size: usize, stride: usize, padding: usize ) -> Result<Matrix>
Apply two-dimensional average pooling to an NCHW Matrix. Padding positions do not contribute to either the sum or divisor. The output spatial extent is floor((input + 2 * padding - kernel_size) / stride) + 1, matching the OA C++ operation. Errors Returns an error unless input is a nonempty rank-four F32 Matrix, kernel_size and stride are nonzero, the kernel fits the padded input, every shader extent is representable, or runtime recording fails.