diff options
author | Viet-Hoa Do <viet-hoa.do@arm.com> | 2023-08-24 11:48:19 +0100 |
---|---|---|
committer | Viet-Hoa Do <viet-hoa.do@arm.com> | 2023-08-29 13:42:21 +0000 |
commit | 2d0c2f5700434a4b0c3345c71a3a45825a0e6766 (patch) | |
tree | c4c9613cdc065b4604cadd21fd1953d877f3c7b2 /compute_kernel_writer/src/cl/CLKernelWriter.h | |
parent | 806b8e856911e6691ede6725c7e2a0e7e0dd6e95 (diff) | |
download | ComputeLibrary-2d0c2f5700434a4b0c3345c71a3a45825a0e6766.tar.gz |
Add CKW flow control writing methods
* Structures: if/else/else if, for, return.
* Add corresponding tests.
Partially resolves: COMPMID-6387
Signed-off-by: Viet-Hoa Do <viet-hoa.do@arm.com>
Change-Id: I2912ccaf46f836907f21bb53fa82bcc1f48dd224
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10199
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: SiCong Li <sicong.li@arm.com>
Reviewed-by: Gunes Bayir <gunes.bayir@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.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/compute_kernel_writer/src/cl/CLKernelWriter.h b/compute_kernel_writer/src/cl/CLKernelWriter.h index d2c84f192e..9fc7e550a7 100644 --- a/compute_kernel_writer/src/cl/CLKernelWriter.h +++ b/compute_kernel_writer/src/cl/CLKernelWriter.h @@ -75,6 +75,23 @@ public: void op_ternary(const TileOperand &dst, TernaryOp op, const TileOperand &first, const TileOperand &second, const TileOperand &third) override; // ============================================================================================= + // Flow control + // ============================================================================================= + + void op_if(const TileOperand &lhs, BinaryOp op, const TileOperand &rhs, const std::function<void()> &body) override; + + void op_else_if(const TileOperand &lhs, BinaryOp op, const TileOperand &rhs, const std::function<void()> &body) override; + + void op_else(const std::function<void()> &body) override; + + void op_for_loop( + const TileOperand &var, BinaryOp cond_op, const TileOperand &cond_value, + const TileOperand &update_var, AssignmentOp update_op, const TileOperand &update_value, + const std::function<void()> &body) override; + + void op_return() override; + + // ============================================================================================= // Misc // ============================================================================================= @@ -177,6 +194,18 @@ private: const TileOperand &x, const TileOperand &y, const TileOperand &z, const TileOperand &batch, const CLTile &dilation_x, const CLTile &dilation_y); + /** This function is the generic function to write both `if` and `else if` blocks. + * + * It is used for both @ref CLKernelWriter::op_if and @ref CLKernelWriter::op_else_if. + * + * @param[in] is_else True if this is an `else if` block, otherwise this is an `if` block. + * @param[in] lhs The LHS tile of the condition. + * @param[in] op The relational binary operator. + * @param[in] rhs The RHS tile of the condition. + * @param[in] body The function that writes the body of the else-if block. + */ + void op_if_generic(bool is_else, const TileOperand &lhs, BinaryOp op, const TileOperand &rhs, const std::function<void()> &body); + // For attributes private: /** This string contains the kernel body source code, not the full CL source code. |