| 46 | namespace |
| 47 | { |
| 48 | Status validate_arguments(const ITensorInfo *src, |
| 49 | const ITensorInfo *dst, |
| 50 | const PoolingLayerInfo &pool_info, |
| 51 | const ITensorInfo *indices) |
| 52 | { |
| 53 | ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src, dst); |
| 54 | ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(src); |
| 55 | ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(src); |
| 56 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(src, 1, DataType::QASYMM8, DataType::QASYMM8_SIGNED, |
| 57 | DataType::F16, DataType::F32); |
| 58 | ARM_COMPUTE_RETURN_ERROR_ON_MSG( |
| 59 | (is_data_type_quantized_asymmetric(src->data_type()) && pool_info.pool_type == PoolingType::L2), |
| 60 | "Unsupported combination of parameters!"); |
| 61 | |
| 62 | const auto data_layout = pool_info.data_layout == DataLayout::UNKNOWN ? src->data_layout() : pool_info.data_layout; |
| 63 | const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH); |
| 64 | const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT); |
| 65 | const bool is_global_pooling = pool_info.is_global_pooling; |
| 66 | unsigned int pool_size_x = is_global_pooling ? src->dimension(idx_width) : pool_info.pool_size.width; |
| 67 | unsigned int pool_size_y = is_global_pooling ? src->dimension(idx_height) : pool_info.pool_size.height; |
| 68 | int output_width = 0; |
| 69 | int output_height = 0; |
| 70 | |
| 71 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(is_pool_region_entirely_outside_input(pool_info), |
| 72 | "Pooling region that is entirely outside input tensor is unsupported"); |
| 73 | |
| 74 | std::tie(output_width, output_height) = |
| 75 | scaled_dimensions_signed(src->tensor_shape()[idx_width], src->tensor_shape()[idx_height], pool_size_x, |
| 76 | pool_size_y, pool_info.pad_stride_info); |
| 77 | ARM_COMPUTE_RETURN_ERROR_ON_MSG((output_width < 1 || output_height < 1), |
| 78 | "Calculated output dimension size is invalid"); |
| 79 | |
| 80 | const TensorShape output_shape = compute_pool_shape(*src, pool_info); |
| 81 | |
| 82 | // Check indices |
| 83 | if (indices) |
| 84 | { |
| 85 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(src, 1, DataType::F16, DataType::F32); |
| 86 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(pool_info.pool_type != PoolingType::MAX, |
| 87 | "Pooling indices only supported for MAX pooling method"); |
| 88 | ARM_COMPUTE_RETURN_ERROR_ON_MSG((pool_info.pool_size != Size2D(2, 2)), |
| 89 | "Pooling indices only supported for pool size 2x2"); |
| 90 | |
| 91 | if (indices->total_size() != 0) |
| 92 | { |
| 93 | ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(indices); |
| 94 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(indices->tensor_shape(), output_shape); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | // Checks performed when dst is configured |
| 99 | if (dst->total_size() != 0) |
| 100 | { |
| 101 | ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(dst); |
| 102 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst); |
| 103 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(src, dst); |
| 104 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(dst->tensor_shape(), output_shape); |
| 105 | } |
no test coverage detected