diff options
author | Viet-Hoa Do <viet-hoa.do@arm.com> | 2023-08-22 11:11:23 +0100 |
---|---|---|
committer | Viet-Hoa Do <viet-hoa.do@arm.com> | 2023-08-24 09:48:58 +0000 |
commit | 34b6c3a08c3fd3f99cf675921a319b8678a98273 (patch) | |
tree | b52068faf874063b79f0e4ddd7d587e785bb65bf /compute_kernel_writer/include | |
parent | 3a9ecdfdc76abd7f9acdab42a1f7e4c0188d6f48 (diff) | |
download | ComputeLibrary-34b6c3a08c3fd3f99cf675921a319b8678a98273.tar.gz |
Add CKW binary and ternary statements
Resolves: COMPMID-6388
Signed-off-by: Viet-Hoa Do <viet-hoa.do@arm.com>
Change-Id: Ia0cd1486f368af54053066f489cac83b9de01789
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10182
Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'compute_kernel_writer/include')
-rw-r--r-- | compute_kernel_writer/include/ckw/KernelWriter.h | 23 | ||||
-rw-r--r-- | compute_kernel_writer/include/ckw/types/Operators.h | 43 |
2 files changed, 64 insertions, 2 deletions
diff --git a/compute_kernel_writer/include/ckw/KernelWriter.h b/compute_kernel_writer/include/ckw/KernelWriter.h index 7eb6d2894a..d59867fa6f 100644 --- a/compute_kernel_writer/include/ckw/KernelWriter.h +++ b/compute_kernel_writer/include/ckw/KernelWriter.h @@ -100,10 +100,29 @@ public: /** Write the unary expression statement: `<dst> = <op> <src>;`. * * @param[in] dst The destination tile. - * @param[in] src The source tile. * @param[in] op The unary operator. + * @param[in] src The source tile. + */ + virtual void op_unary(const TileOperand &dst, UnaryOp op, const TileOperand &src) = 0; + + /** Write the binary expression statement: `<dst> = <op>(<first>, <second>);`. + * + * @param[in] dst The destination tile. + * @param[in] op The binary operator. + * @param[in] first The first source tile. + * @param[in] second The second source tile. + */ + virtual void op_binary(const TileOperand &dst, BinaryOp op, const TileOperand &first, const TileOperand &second) = 0; + + /** Write ternary expression statement: `<dst> = <op>(<first>, <second>, <third>);`. + * + * @param[in] dst The destination tile. + * @param[in] op The ternary operator. + * @param[in] first The first source tile. + * @param[in] second The second source tile. + * @param[in] third The third source tile. */ - virtual void op_unary(const TileOperand &dst, const TileOperand &src, UnaryOp op) = 0; + virtual void op_ternary(const TileOperand &dst, TernaryOp op, const TileOperand &first, const TileOperand &second, const TileOperand &third) = 0; // ============================================================================================= // Misc diff --git a/compute_kernel_writer/include/ckw/types/Operators.h b/compute_kernel_writer/include/ckw/types/Operators.h index ec2df08c46..1e5f9bd542 100644 --- a/compute_kernel_writer/include/ckw/types/Operators.h +++ b/compute_kernel_writer/include/ckw/types/Operators.h @@ -52,6 +52,49 @@ enum class AssignmentOp : int32_t Decrement = 0x0001, // -= }; +/** Binary operators. */ +enum class BinaryOp : int32_t +{ + // Elementwise + Add = 0x0000, // + + Sub = 0x0001, // - + Mul = 0x0002, // * + Div = 0x0003, // / + Mod = 0x0004, // % + + // Relational + Equal = 0x1000, // == + Less = 0x1001, // < + LessEqual = 0x1002, // <= + Greater = 0x1003, // > + GreaterEqual = 0x1004, // >= + + // Algebra + MatMul_Nt_Nt = 0x2000, // X + MatMul_Nt_T = 0x2001, // X + MatMul_T_Nt = 0x2002, // X + MatMul_T_T = 0x2003, // X + Dot = 0x2004, // . + + // Logical + LogicalAnd = 0x3000, // && + LogicalOr = 0x3001, // || + + // Bitwise + BitwiseXOR = 0x4000, // ^ + + // Functions + Min = 0x8000, + Max = 0x8001, +}; + +/** Ternary operators. */ +enum class TernaryOp : int32_t +{ + Select = 0x0000, + Clamp = 0x0001, +}; + } // namespace ckw #endif // CKW_INCLUDE_CKW_TYPES_OPERATORS_H |