aboutsummaryrefslogtreecommitdiff
path: root/compute_kernel_writer/src/cl/CLHelpers.h
diff options
context:
space:
mode:
authorGunes Bayir <gunes.bayir@arm.com>2023-07-27 22:50:22 +0100
committerGunes Bayir <gunes.bayir@arm.com>2023-08-02 18:56:12 +0000
commite98413e405015dec7e90946cc1e0c7b9921b0be3 (patch)
treeb2d55286cf134e418040b47c2efdfd1f441d385f /compute_kernel_writer/src/cl/CLHelpers.h
parent366514d54fd43321f440ebddc49fda28d40b8e49 (diff)
downloadComputeLibrary-e98413e405015dec7e90946cc1e0c7b9921b0be3.tar.gz
Add helpers methods to CLHelpers in CKW
This patch adds some helper methods to perform - scalar and vector data type to string conversion - decompose a vector length to a superposition of OpenCL vector lengths Partially Resolves: COMPMID-5791 Signed-off-by: Gunes Bayir <gunes.bayir@arm.com> Change-Id: I14495773a6bb57bd3c3565a0d6e44b891159a948 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9995 Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'compute_kernel_writer/src/cl/CLHelpers.h')
-rw-r--r--compute_kernel_writer/src/cl/CLHelpers.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/compute_kernel_writer/src/cl/CLHelpers.h b/compute_kernel_writer/src/cl/CLHelpers.h
index d0ca488617..669424088e 100644
--- a/compute_kernel_writer/src/cl/CLHelpers.h
+++ b/compute_kernel_writer/src/cl/CLHelpers.h
@@ -26,6 +26,7 @@
#include <cstdint>
#include <string>
+#include <vector>
/** OpenCL specific helper functions */
namespace ckw
@@ -57,7 +58,7 @@ std::string cl_get_variable_datatype_as_string(DataType dt, int32_t len);
*
* @return the OpenCL vector size
*/
-int32_t width_to_cl_vector_size(int32_t width);
+int32_t cl_round_up_to_nearest_valid_vector_width(int32_t width);
/** Helper function to return the OpenCL storage type as a string from a @ref TensorStorage
*
@@ -66,6 +67,24 @@ int32_t width_to_cl_vector_size(int32_t width);
* @return the OpenCL storage type as a string
*/
std::string cl_get_variable_storagetype_as_string(TensorStorageType storage);
+
+/** Helper function to decompose a vector width into a summation of valid OpenCL vector widths.
+ *
+ * @param[in] vector_width Vector width to be decomposed
+ *
+ * @return a vector of OpenCL vector widths
+ */
+std::vector<int32_t> cl_decompose_vector_width(int32_t vector_width);
+
+/** Helper function to get OpenCL data type from the data type enum and width
+ * It'll round up the given vector width to the nearest valid OpenCL vector width.
+ *
+ * @param[in] dt data type enum
+ * @param[in] width vector width
+ *
+ * @return a string representation of the data type
+ */
+std::string cl_data_type_rounded_up_to_valid_vector_width(DataType dt, int32_t width);
} // namespace ckw
-#endif /* COMPUTE_KERNEL_WRITER_SRC_CL_CLHELPERS_H */
+#endif /* CKW_SRC_CL_CLHELPERS_H */