From 32741725ac6e6c9658c51ed8585d314a1707ee8c Mon Sep 17 00:00:00 2001 From: Jakub Sujak Date: Fri, 25 Nov 2022 16:43:18 +0000 Subject: Add CLAMP operator to Dynamic Fusion interface Add the CLAMP activation function for GPU backend with generic activation Component and TemplateWriter modules. CLAMP is internally implemented as LU_BOUNDED_RELU activation function with the alpha and beta variables swapped. We do NOT consider in-place computation cases in this patch. * CLAMP operator for GPU backend. * Activation Component and TemplateWriter for CL backend. * TemplateWriter generates tiled kernel code. * Supported data types: F16, F32. * Validation tests for CLAMP operation. Resolves: COMPMID-5519 Change-Id: Ieb097d6b1e6a7ed2b882518e88314454efb402f6 Signed-off-by: Jakub Sujak Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8762 Comments-Addressed: Arm Jenkins Reviewed-by: Gunes Bayir Reviewed-by: SiCong Li Tested-by: Arm Jenkins Benchmark: Arm Jenkins --- utils/TypePrinter.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'utils') diff --git a/utils/TypePrinter.h b/utils/TypePrinter.h index 515e568657..9f20b38b96 100644 --- a/utils/TypePrinter.h +++ b/utils/TypePrinter.h @@ -40,6 +40,7 @@ #include "arm_compute/core/experimental/PostOps.h" #include "arm_compute/dynamic_fusion/sketch/OperatorAttributes.h" #include "arm_compute/dynamic_fusion/sketch/attributes/CastAttributes.h" +#include "arm_compute/dynamic_fusion/sketch/attributes/ClampAttributes.h" #include "arm_compute/dynamic_fusion/sketch/attributes/DepthwiseConv2dAttributes.h" #include "arm_compute/runtime/CL/CLTunerTypes.h" #include "arm_compute/runtime/CL/CLTypes.h" @@ -3495,6 +3496,34 @@ inline std::string to_string(const experimental::dynamic_fusion::DepthwiseConv2d return str.str(); } +/** Formatted output of the arm_compute::experimental::dynamic_fusion::ClampAttributes type. + * + * @param[out] os Output stream. + * @param[in] clamp_attr arm_compute::experimental::dynamic_fusion::ClampAttributes type to output. + * + * @return Modified output stream. + */ +inline ::std::ostream &operator<<(::std::ostream &os, const experimental::dynamic_fusion::ClampAttributes &clamp_attr) +{ + os << "ClampAttributes=" + << "[" + << "Min value=" << clamp_attr.min_val() << ", " + << "Max value=" << clamp_attr.max_val() << "]"; + return os; +} +/** Formatted output of the arm_compute::experimental::dynamic_fusion::ClampAttributes type. + * + * @param[in] clamp_attr arm_compute::experimental::dynamic_fusion::ClampAttributes type to output. + * + * @return Formatted string. + */ +inline std::string to_string(const experimental::dynamic_fusion::ClampAttributes &clamp_attr) +{ + std::stringstream str; + str << clamp_attr; + return str.str(); +} + } // namespace arm_compute #endif /* __ARM_COMPUTE_TYPE_PRINTER_H__ */ -- cgit v1.2.1