From 7d9a78ebfb3553b95421a0da5e2686a3923748db Mon Sep 17 00:00:00 2001 From: Matthew Bentham Date: Wed, 31 May 2023 13:18:33 +0000 Subject: Remove dependency on fp16 definitions from some core include files This significantly improves the compilation times for parts of the core library that just need a definition of float16_t rather than access to all of the fp16 intrinsics. Signed-off-by: Matthew Bentham Change-Id: I5da1c6b0df0dd87d1d17948cd2e9b7375874f455 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/c/VisualCompute/ComputeLibrary/+/529385 Tested-by: bsgcomp Reviewed-by: Pablo Tello Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9781 Tested-by: Arm Jenkins Reviewed-by: Gunes Bayir Comments-Addressed: Arm Jenkins Benchmark: Arm Jenkins --- arm_compute/core/QuantizationInfo.h | 5 +-- arm_compute/core/Utils.h | 53 --------------------------- arm_compute/core/Validate.h | 54 ++++++++++++++++++++++++++++ arm_compute/graph/Graph.h | 3 +- arm_compute/runtime/CPP/functions/CPPSplit.h | 4 +-- 5 files changed, 57 insertions(+), 62 deletions(-) (limited to 'arm_compute') diff --git a/arm_compute/core/QuantizationInfo.h b/arm_compute/core/QuantizationInfo.h index f760d7512c..8fa513eee1 100644 --- a/arm_compute/core/QuantizationInfo.h +++ b/arm_compute/core/QuantizationInfo.h @@ -24,13 +24,10 @@ #ifndef ARM_COMPUTE_QUANTIZATION_INFO_H #define ARM_COMPUTE_QUANTIZATION_INFO_H -#include "arm_compute/core/Error.h" #include "arm_compute/core/Rounding.h" +#include "arm_compute/core/utils/misc/Utility.h" #include "support/ToolchainSupport.h" -#include "utils/misc/Utility.h" -#include -#include #include namespace arm_compute diff --git a/arm_compute/core/Utils.h b/arm_compute/core/Utils.h index edeae21c6f..188ae8cf5b 100644 --- a/arm_compute/core/Utils.h +++ b/arm_compute/core/Utils.h @@ -593,59 +593,6 @@ inline std::tuple get_min_max(DataType dt) return std::make_tuple(min, max); } -/** Return true if the given format has horizontal subsampling. - * - * @param[in] format Format to determine subsampling. - * - * @return True if the format can be subsampled horizontaly. - */ -inline bool has_format_horizontal_subsampling(Format format) -{ - return (format == Format::YUYV422 || format == Format::UYVY422 || format == Format::NV12 || format == Format::NV21 || format == Format::IYUV || format == Format::UV88) ? true : false; -} - -/** Return true if the given format has vertical subsampling. - * - * @param[in] format Format to determine subsampling. - * - * @return True if the format can be subsampled verticaly. - */ -inline bool has_format_vertical_subsampling(Format format) -{ - return (format == Format::NV12 || format == Format::NV21 || format == Format::IYUV || format == Format::UV88) ? true : false; -} - -/** Calculate subsampled shape for a given format and channel - * - * @param[in] shape Shape of the tensor to calculate the extracted channel. - * @param[in] format Format of the tensor. - * @param[in] channel Channel to create tensor shape to be extracted. - * - * @return The subsampled tensor shape. - */ -inline TensorShape calculate_subsampled_shape(const TensorShape &shape, Format format, Channel channel = Channel::UNKNOWN) -{ - TensorShape output{ shape }; - - // Subsample shape only for U or V channel - if(Channel::U == channel || Channel::V == channel || Channel::UNKNOWN == channel) - { - // Subsample width for the tensor shape when channel is U or V - if(has_format_horizontal_subsampling(format)) - { - output.set(0, output.x() / 2U); - } - - // Subsample height for the tensor shape when channel is U or V - if(has_format_vertical_subsampling(format)) - { - output.set(1, output.y() / 2U); - } - } - - return output; -} - /** Permutes the given dimensions according the permutation vector * * @param[in,out] dimensions Dimensions to be permuted. diff --git a/arm_compute/core/Validate.h b/arm_compute/core/Validate.h index 7e387c9cc1..ff4540cd8a 100644 --- a/arm_compute/core/Validate.h +++ b/arm_compute/core/Validate.h @@ -27,6 +27,7 @@ #include "arm_compute/core/Error.h" #include "arm_compute/core/IKernel.h" #include "arm_compute/core/ITensor.h" +#include "arm_compute/core/QuantizationInfo.h" #include "arm_compute/core/Utils.h" #include "arm_compute/core/Window.h" @@ -285,6 +286,28 @@ arm_compute::Status error_on_mismatching_dimensions(const char *function, const #define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(...) \ ARM_COMPUTE_RETURN_ON_ERROR(::arm_compute::error_on_mismatching_dimensions(__func__, __FILE__, __LINE__, __VA_ARGS__)) +/** Return true if the given format has horizontal subsampling. + * + * @param[in] format Format to determine subsampling. + * + * @return True if the format can be subsampled horizontaly. + */ +inline bool has_format_horizontal_subsampling(Format format) +{ + return (format == Format::YUYV422 || format == Format::UYVY422 || format == Format::NV12 || format == Format::NV21 || format == Format::IYUV || format == Format::UV88) ? true : false; +} + +/** Return true if the given format has vertical subsampling. + * + * @param[in] format Format to determine subsampling. + * + * @return True if the format can be subsampled verticaly. + */ +inline bool has_format_vertical_subsampling(Format format) +{ + return (format == Format::NV12 || format == Format::NV21 || format == Format::IYUV || format == Format::UV88) ? true : false; +} + /** Adjust tensor shape size if width or height are odd for a given multi-planar format. No modification is done for other formats. * * @note Adding here a few links discussing the issue of odd size and sharing the same solution: @@ -349,6 +372,37 @@ arm_compute::Status error_on_tensors_not_even(const char *function, const char * #define ARM_COMPUTE_RETURN_ERROR_ON_TENSORS_NOT_EVEN(...) \ ARM_COMPUTE_RETURN_ON_ERROR(::arm_compute::error_on_tensors_not_even(__func__, __FILE__, __LINE__, __VA_ARGS__)) +/** Calculate subsampled shape for a given format and channel + * + * @param[in] shape Shape of the tensor to calculate the extracted channel. + * @param[in] format Format of the tensor. + * @param[in] channel Channel to create tensor shape to be extracted. + * + * @return The subsampled tensor shape. + */ +inline TensorShape calculate_subsampled_shape(const TensorShape &shape, Format format, Channel channel = Channel::UNKNOWN) +{ + TensorShape output{ shape }; + + // Subsample shape only for U or V channel + if(Channel::U == channel || Channel::V == channel || Channel::UNKNOWN == channel) + { + // Subsample width for the tensor shape when channel is U or V + if(has_format_horizontal_subsampling(format)) + { + output.set(0, output.x() / 2U); + } + + // Subsample height for the tensor shape when channel is U or V + if(has_format_vertical_subsampling(format)) + { + output.set(1, output.y() / 2U); + } + } + + return output; +} + /** Return an error if the passed tensor objects are not sub-sampled. * * @param[in] function Function in which the error occurred. diff --git a/arm_compute/graph/Graph.h b/arm_compute/graph/Graph.h index d8d3feb1f7..806d84c3fd 100644 --- a/arm_compute/graph/Graph.h +++ b/arm_compute/graph/Graph.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2020,2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -30,7 +30,6 @@ #include "arm_compute/graph/Types.h" #include "support/Mutex.h" -#include "support/ToolchainSupport.h" #include #include diff --git a/arm_compute/runtime/CPP/functions/CPPSplit.h b/arm_compute/runtime/CPP/functions/CPPSplit.h index e2e5add264..56aad2db4b 100644 --- a/arm_compute/runtime/CPP/functions/CPPSplit.h +++ b/arm_compute/runtime/CPP/functions/CPPSplit.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021 Arm Limited. + * Copyright (c) 2020-2021,2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -30,8 +30,6 @@ #include "arm_compute/core/Types.h" #include "arm_compute/core/utils/misc/ShapeCalculator.h" -#include "support/ToolchainSupport.h" - #include "arm_compute/runtime/IFunction.h" namespace arm_compute -- cgit v1.2.1