MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / validate_arguments

Function validate_arguments

src/gpu/cl/kernels/ClPool3dKernel.cpp:49–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47namespace
48{
49Status validate_arguments(const ITensorInfo *src, const ITensorInfo *dst, const Pooling3dLayerInfo &pool_info)
50{
51 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src, dst);
52 ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(src);
53 ARM_COMPUTE_RETURN_ERROR_ON_MSG(src->data_layout() != DataLayout::NDHWC, "Only NDHWC layout supported");
54
55 ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(src);
56 ARM_COMPUTE_RETURN_ERROR_ON_MSG(
57 (pool_info.stride.x() == 0 || pool_info.stride.y() == 0 || pool_info.stride.z() == 0),
58 "Strides cannot be zero.");
59 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(src, 1, DataType::F16, DataType::F32, DataType::QASYMM8_SIGNED,
60 DataType::QASYMM8);
61 ARM_COMPUTE_RETURN_ERROR_ON_MSG((!is_data_type_float(src->data_type())) &&
62 (!pool_info.exclude_padding && (pool_info.pool_type == PoolingType::AVG)),
63 "Exclude padding is unsupported for non-float types for Avg op");
64
65 const auto data_layout = src->data_layout();
66 const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
67 const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
68 const int idx_depth = get_data_layout_dimension_index(data_layout, DataLayoutDimension::DEPTH);
69 const bool is_global_pooling = pool_info.is_global_pooling;
70 const unsigned int pool_size_x = is_global_pooling ? src->dimension(idx_width) : pool_info.pool_size.width;
71 const unsigned int pool_size_y = is_global_pooling ? src->dimension(idx_height) : pool_info.pool_size.height;
72 const unsigned int pool_size_z = is_global_pooling ? src->dimension(idx_depth) : pool_info.pool_size.depth;
73 int output_width = 0;
74 int output_height = 0;
75 int output_depth = 0;
76
77 bool round_type_ceil_with_asymm_padding =
78 (pool_info.round_type == DimensionRoundingType::CEIL) && (!is_symmetric(pool_info.padding));
79 ARM_COMPUTE_RETURN_ERROR_ON_MSG(round_type_ceil_with_asymm_padding,
80 "Cannot use dimension round type CEIL when padding is asymmetric.");
81
82 ARM_COMPUTE_RETURN_ERROR_ON_MSG(is_pool_3d_region_entirely_outside_input(pool_info),
83 "Pooling region that is entirely outside input tensor is unsupported");
84 std::tie(output_width, output_height, output_depth) =
85 scaled_3d_dimensions_signed(src->tensor_shape()[idx_width], src->tensor_shape()[idx_height],
86 src->tensor_shape()[idx_depth], pool_size_x, pool_size_y, pool_size_z, pool_info);
87
88 ARM_COMPUTE_RETURN_ERROR_ON_MSG((output_width < 1 || output_height < 1 || output_depth < 1),
89 "Calculated output dimension size is invalid");
90
91 const TensorShape output_shape = compute_pool3d_shape(src->tensor_shape(), pool_info);
92
93 // Checks performed when dst is configured
94 if (dst->total_size() != 0)
95 {
96 ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(dst);
97 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst);
98 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(src, dst);
99 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(dst->tensor_shape(), output_shape);
100 }
101 else
102 {
103 const TensorInfo dst_info(output_shape, src->num_channels(), src->data_type());
104 ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(&dst_info);
105 }
106

Callers 2

configureMethod · 0.70
validateMethod · 0.70

Calls 13

is_data_type_floatFunction · 0.85
is_symmetricFunction · 0.85
compute_pool3d_shapeFunction · 0.85
data_layoutMethod · 0.45
xMethod · 0.45
yMethod · 0.45
zMethod · 0.45
data_typeMethod · 0.45
dimensionMethod · 0.45
total_sizeMethod · 0.45

Tested by

no test coverage detected