aboutsummaryrefslogtreecommitdiff
path: root/compute_kernel_writer/src/cl/CLKernelWriter.h
diff options
context:
space:
mode:
authorViet-Hoa Do <viet-hoa.do@arm.com>2023-07-31 17:13:34 +0100
committerViet-Hoa Do <viet-hoa.do@arm.com>2023-08-22 08:42:23 +0000
commite1c3b466960d5e3fd5a54871287f5eb6102bfb8c (patch)
treeca7b46273f564cd96bbb6832fbcd743ce4642301 /compute_kernel_writer/src/cl/CLKernelWriter.h
parent47a396e3aae96f2dcad44f4e0d6cb6b87b368395 (diff)
downloadComputeLibrary-e1c3b466960d5e3fd5a54871287f5eb6102bfb8c.tar.gz
Add CKW writing methods for CL unary ops
* Add writing methods for: - Assignment. - Cast. - Unary expression. * Add corresponding tests. Partially resolves: COMPMID-6388. Signed-off-by: Viet-Hoa Do <viet-hoa.do@arm.com> Change-Id: Ia654173e2e1ee9cddb7819980251e0591934439f Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10155 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Gunes Bayir <gunes.bayir@arm.com> Reviewed-by: Jakub Sujak <jakub.sujak@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'compute_kernel_writer/src/cl/CLKernelWriter.h')
-rw-r--r--compute_kernel_writer/src/cl/CLKernelWriter.h45
1 files changed, 29 insertions, 16 deletions
diff --git a/compute_kernel_writer/src/cl/CLKernelWriter.h b/compute_kernel_writer/src/cl/CLKernelWriter.h
index a40698d7bb..ea455a7fdd 100644
--- a/compute_kernel_writer/src/cl/CLKernelWriter.h
+++ b/compute_kernel_writer/src/cl/CLKernelWriter.h
@@ -57,13 +57,21 @@ public:
~CLKernelWriter();
// =============================================================================================
+ // Data processing
+ // =============================================================================================
+
+ void op_assign(const TileOperand &dst, const TileOperand &src) override;
+
+ void op_cast(const TileOperand &dst, const TileOperand &src, ConvertPolicy policy) override;
+
+ void op_unary(const TileOperand &dst, const TileOperand &src, UnaryOp op) override;
+
+ // =============================================================================================
// Misc
// =============================================================================================
- /** Similar to @ref KernelWriter::comment() */
- void comment(const std::string &text) override;
+ void op_comment(const std::string &text) override;
- /** Similar to @ref KernelWriter::op_write_raw_code() */
void op_write_raw_code(const std::string &raw_code) override;
// =============================================================================================
@@ -92,14 +100,16 @@ public:
*
* Similar to @ref KernelWriter::op_load()
*/
- void op_load(const TileOperand &tile_op, const TensorOperand &tensor_op, TensorSampler &sampler,
+ void op_load(
+ const TileOperand &tile_op, const TensorOperand &tensor_op, TensorSampler &sampler,
const TileOperand &x, const TileOperand &y, const TileOperand &z, const TileOperand &batch) override;
/** Load the data from the tensor memory to the tile in a dilated way using the sampling information.
*
* Similar to @ref KernelWriter::op_load_dilated()
*/
- void op_load_dilated(const TileOperand &tile_op, const TensorOperand &tensor_op, TensorSampler &sampler,
+ void op_load_dilated(
+ const TileOperand &tile_op, const TensorOperand &tensor_op, TensorSampler &sampler,
const TileOperand &x, const TileOperand &y, const TileOperand &z, const TileOperand &batch,
const TileOperand &dilation_x, const TileOperand &dilation_y) override;
@@ -107,18 +117,26 @@ public:
*
* Similar to @ref KernelWriter::op_store()
*/
- void op_store(const TensorOperand &tensor_op, const TileOperand &tile_op, TensorSampler &sampler,
+ void op_store(
+ const TensorOperand &tensor_op, const TileOperand &tile_op, TensorSampler &sampler,
const TileOperand &x, const TileOperand &y, const TileOperand &z, const TileOperand &batch) override;
/** Store the data to the tensor memory from the tile in a dilated way using the sampling information.
*
* Similar to @ref KernelWriter::op_store_dilated()
*/
- void op_store_dilated(const TensorOperand &tensor_op, const TileOperand &tile_op, TensorSampler &sampler,
+ void op_store_dilated(
+ const TensorOperand &tensor_op, const TileOperand &tile_op, TensorSampler &sampler,
const TileOperand &x, const TileOperand &y, const TileOperand &z, const TileOperand &batch,
const TileOperand &dilation_x, const TileOperand &dilation_y) override;
protected:
+ /** Return @ref CLTile object from the @ref TileOperand object.
+ *
+ * This function performs appropriate check before doing type casting.
+ */
+ const CLTile &to_cl_tile(const TileOperand &operand);
+
/** Append the specified code to the kernel body source code. */
template <typename T, typename... TArgs>
void append_code(T &&code, TArgs &&...args)
@@ -137,20 +155,15 @@ protected:
/** Get the current kernel body source code. */
const std::string &body_source_code() const;
-// For helper functions
+ // For helper functions
private:
- /** Return @ref CLTile object from the @ref TileOperand object.
- *
- * This function performs appropriate check before doing type casting.
- */
- const CLTile &to_cl_tile(const TileOperand &operand);
-
/** Helper function to consolidate all load/store logic in this class */
- void op_load_store(MemoryOperation op, const TileOperand &tile_op, const TensorOperand &tensor_op, TensorSampler &sampler,
+ void op_load_store(
+ MemoryOperation op, const TileOperand &tile_op, const TensorOperand &tensor_op, TensorSampler &sampler,
const TileOperand &x, const TileOperand &y, const TileOperand &z, const TileOperand &batch,
const CLTile &dilation_x, const CLTile &dilation_y);
-// For attributes
+ // For attributes
private:
/** This string contains the kernel body source code, not the full CL source code.
* The full source code will only be generated when the user calls @ref KernelWriter::emit_kernel.