| 150 | }; |
| 151 | |
| 152 | Status validate_arguments(const ITensorInfo *src, |
| 153 | const ITensorInfo *dst, |
| 154 | const PoolingLayerInfo &pool_info, |
| 155 | const ITensorInfo *indices, |
| 156 | Size2D pool_size) |
| 157 | { |
| 158 | ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src, dst); |
| 159 | ARM_COMPUTE_RETURN_ERROR_ON(pool_size.x() == 0); |
| 160 | ARM_COMPUTE_RETURN_ERROR_ON(pool_size.y() == 0); |
| 161 | ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(src, indices); |
| 162 | |
| 163 | int pool_stride_x = 0; |
| 164 | int pool_stride_y = 0; |
| 165 | int output_width = 0; |
| 166 | int output_height = 0; |
| 167 | PoolingType pool_type = pool_info.pool_type; |
| 168 | const PadStrideInfo pad_stride_info = pool_info.pad_stride_info; |
| 169 | const auto data_layout = pool_info.data_layout == DataLayout::UNKNOWN ? src->data_layout() : pool_info.data_layout; |
| 170 | const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH); |
| 171 | const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT); |
| 172 | |
| 173 | ARM_COMPUTE_RETURN_ERROR_ON_MSG( |
| 174 | (!is_data_type_float(src->data_type())) && (is_pool_region_entirely_outside_input(pool_info)), |
| 175 | "Pooling region that is entirely outside input tensor is unsupported for non-float types"); |
| 176 | |
| 177 | std::tie(output_width, output_height) = |
| 178 | scaled_dimensions_signed(src->tensor_shape()[idx_width], src->tensor_shape()[idx_height], pool_size.x(), |
| 179 | pool_size.y(), pool_info.pad_stride_info); |
| 180 | ARM_COMPUTE_RETURN_ERROR_ON_MSG((output_width < 1 || output_height < 1), |
| 181 | "Calculated output dimension size is invalid"); |
| 182 | |
| 183 | TensorInfo out_info(TensorInfo(compute_pool_shape(*src, pool_info), 1, dst->data_type())); |
| 184 | std::tie(pool_stride_x, pool_stride_y) = pad_stride_info.stride(); |
| 185 | |
| 186 | ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(src); |
| 187 | if (indices) |
| 188 | { |
| 189 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(src, 1, DataType::F32, DataType::F16); |
| 190 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(indices, 1, DataType::U32); |
| 191 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(pool_type != PoolingType::MAX, |
| 192 | "Pooling indices only supported for MAX pooling method"); |
| 193 | } |
| 194 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(src, 1, DataType::QASYMM8, DataType::QASYMM8_SIGNED, |
| 195 | DataType::F16, DataType::F32); |
| 196 | ARM_COMPUTE_RETURN_ERROR_ON(pool_type == PoolingType::L2 && is_data_type_quantized(src->data_type())); |
| 197 | ARM_COMPUTE_RETURN_ERROR_ON_MSG( |
| 198 | is_data_type_quantized(src->data_type()) && !pool_info.exclude_padding && |
| 199 | (pool_info.pool_type == PoolingType::AVG) && pool_info.pad_stride_info.has_padding() && |
| 200 | (src->data_layout() == DataLayout::NHWC), |
| 201 | "exclude_padding equal false is not supported for AVG Pooling with padding on quantized types"); |
| 202 | |
| 203 | if (dst->total_size() != 0) |
| 204 | { |
| 205 | ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(dst); |
| 206 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst); |
| 207 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(src, dst); |
| 208 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(dst, &out_info); |
| 209 | if (indices) |
no test coverage detected