aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/utils
diff options
context:
space:
mode:
authorramelg01 <ramy.elgammal@arm.com>2022-02-26 22:06:20 +0000
committerRamy Elgammal <ramy.elgammal@arm.com>2022-03-15 16:18:13 +0000
commit375156937a0783432c5d18e199b5d8d2b3ec33f7 (patch)
tree4c755770ac569c286179e5ce40df1c820baa73d8 /arm_compute/core/utils
parent4e66d707a292b90a344e32c59eb1dacb67a0e4c1 (diff)
downloadComputeLibrary-375156937a0783432c5d18e199b5d8d2b3ec33f7.tar.gz
Implementation of ClPooling3d
- For NDHWC layout - For F16 and F32 data types - Mixed Precision stil not supported Resolves: COMPMID-4670 Signed-off-by: ramy.elgammal@arm.com Change-Id: I0e14a13e4625569e8e5ee67e6033bd1efe0da469 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7262 Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: SiCong Li <sicong.li@arm.com> Reviewed-by: Gunes Bayir <gunes.bayir@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'arm_compute/core/utils')
-rw-r--r--arm_compute/core/utils/misc/ShapeCalculator.h63
1 files changed, 20 insertions, 43 deletions
diff --git a/arm_compute/core/utils/misc/ShapeCalculator.h b/arm_compute/core/utils/misc/ShapeCalculator.h
index ee4fe0c02f..df907c106e 100644
--- a/arm_compute/core/utils/misc/ShapeCalculator.h
+++ b/arm_compute/core/utils/misc/ShapeCalculator.h
@@ -1467,52 +1467,29 @@ inline TensorShape compute_conv3d_shape(const TensorShape &src, const TensorShap
*
* @return the calculated shape
*/
-inline TensorShape compute_pool3d_shape(const TensorShape &src, Pool3DInfo pool3d_info)
+inline TensorShape compute_pool3d_shape(const TensorShape &src, Pooling3dLayerInfo pool3d_info)
{
TensorShape output_shape{ src };
- const int idx_width = 1;
- const int idx_height = 2;
- const int idx_depth = 3;
- const int pool_size_width = pool3d_info.is_global_pooling ? src[idx_width] : pool3d_info.pool_size.width;
- const int pool_size_height = pool3d_info.is_global_pooling ? src[idx_height] : pool3d_info.pool_size.height;
- const int pool_size_depth = pool3d_info.is_global_pooling ? src[idx_depth] : pool3d_info.pool_size.depth;
- const int pool_stride_width = pool3d_info.strides.width;
- const int pool_stride_height = pool3d_info.strides.height;
- const int pool_stride_depth = pool3d_info.strides.depth;
-
- int output_width_size = 0;
- int output_height_size = 0;
- int output_depth_size = 0;
-
- const size_t pad_left = pool3d_info.padding.left;
- const size_t pad_right = pool3d_info.padding.right;
- const size_t pad_top = pool3d_info.padding.top;
- const size_t pad_bottom = pool3d_info.padding.bottom;
- const size_t pad_front = pool3d_info.padding.front;
- const size_t pad_back = pool3d_info.padding.back;
-
- switch(pool3d_info.round_type)
- {
- case DimensionRoundingType::FLOOR:
- output_width_size = static_cast<int>(std::floor((static_cast<float>(src[idx_width] + pad_left + pad_right - pool_size_width)) / pool_stride_width) + 1);
- output_height_size = static_cast<int>(std::floor((static_cast<float>(src[idx_height] + pad_top + pad_bottom - pool_size_height)) / pool_stride_height) + 1);
- output_depth_size = static_cast<int>(std::floor((static_cast<float>(src[idx_depth] + pad_front + pad_back - pool_size_depth)) / pool_stride_depth) + 1);
- break;
- case DimensionRoundingType::CEIL:
- output_width_size = static_cast<int>(std::ceil((static_cast<float>(src[idx_width] + pad_left + pad_right - pool_size_width)) / pool_stride_width) + 1);
- output_height_size = static_cast<int>(std::ceil((static_cast<float>(src[idx_height] + pad_top + pad_bottom - pool_size_height)) / pool_stride_height) + 1);
- output_depth_size = static_cast<int>(std::ceil((static_cast<float>(src[idx_depth] + pad_front + pad_back - pool_size_depth)) / pool_stride_depth) + 1);
- break;
- default:
- ARM_COMPUTE_ERROR("Unsupported rounding type");
- }
-
- ARM_COMPUTE_ERROR_ON_MSG((output_width_size < 1 || output_height_size < 1 || output_depth_size < 1), "Calculated output dimension size is invalid");
-
- output_shape.set(idx_width, static_cast<size_t>(output_width_size));
- output_shape.set(idx_height, static_cast<size_t>(output_height_size));
- output_shape.set(idx_depth, static_cast<size_t>(output_depth_size));
+ const auto data_layout = DataLayout::NDHWC;
+ const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
+ const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
+ const int idx_depth = get_data_layout_dimension_index(data_layout, DataLayoutDimension::DEPTH);
+ const int pool_size_width = pool3d_info.is_global_pooling ? src[idx_width] : pool3d_info.pool_size.width;
+ const int pool_size_height = pool3d_info.is_global_pooling ? src[idx_height] : pool3d_info.pool_size.height;
+ const int pool_size_depth = pool3d_info.is_global_pooling ? src[idx_depth] : pool3d_info.pool_size.depth;
+ int output_width = 0;
+ int output_height = 0;
+ int output_depth = 0;
+
+ std::tie(output_width, output_height, output_depth) = scaled_3d_dimensions_signed(src[idx_width], src[idx_height], src[idx_depth], pool_size_width, pool_size_height,
+ pool_size_depth, pool3d_info);
+
+ ARM_COMPUTE_ERROR_ON_MSG((output_width < 1 || output_height < 1 || output_depth < 1), "Calculated output dimension size is invalid");
+
+ output_shape.set(idx_width, static_cast<size_t>(output_width));
+ output_shape.set(idx_height, static_cast<size_t>(output_height));
+ output_shape.set(idx_depth, static_cast<size_t>(output_depth));
return output_shape;
}