From afd38f0c617d6f89b2b4532c6c44f116617e2b6f Mon Sep 17 00:00:00 2001 From: Felix Thomasmathibalan Date: Wed, 27 Sep 2023 17:46:17 +0100 Subject: Apply clang-format on repository Code is formatted as per a revised clang format configuration file(not part of this delivery). Version 14.0.6 is used. Exclusion List: - files with .cl extension - files that are not strictly C/C++ (e.g. Android.bp, Sconscript ...) And the following directories - compute_kernel_writer/validation/ - tests/ - include/ - src/core/NEON/kernels/convolution/ - src/core/NEON/kernels/arm_gemm/ - src/core/NEON/kernels/arm_conv/ - data/ There will be a follow up for formatting of .cl files and the files under tests/ and compute_kernel_writer/validation/. Signed-off-by: Felix Thomasmathibalan Change-Id: Ib7eb1fcf4e7537b9feaefcfc15098a804a3fde0a Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10391 Benchmark: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Gunes Bayir --- .../prototype/include/ckw/Error.h | 7 +- .../prototype/include/ckw/KernelArgument.h | 3 +- .../prototype/include/ckw/KernelWriter.h | 32 ++++-- .../prototype/include/ckw/KernelWriterHelper.h | 122 ++++++++++++--------- .../prototype/include/ckw/OperandBase.h | 1 + .../prototype/include/ckw/ScalarValue.h | 8 +- .../prototype/include/ckw/TensorInfo.h | 8 +- .../prototype/include/ckw/TensorOperand.h | 26 ++--- .../prototype/include/ckw/TensorTileSampler.h | 56 +++++----- .../prototype/include/ckw/TileInfo.h | 2 +- .../prototype/include/ckw/types/Functions.h | 20 ++-- .../prototype/include/ckw/types/Operators.h | 4 +- .../include/ckw/types/TensorSamplerTypes.h | 40 ++++--- 13 files changed, 188 insertions(+), 141 deletions(-) (limited to 'compute_kernel_writer/prototype/include') diff --git a/compute_kernel_writer/prototype/include/ckw/Error.h b/compute_kernel_writer/prototype/include/ckw/Error.h index b18944eac5..aab713c817 100644 --- a/compute_kernel_writer/prototype/include/ckw/Error.h +++ b/compute_kernel_writer/prototype/include/ckw/Error.h @@ -39,11 +39,11 @@ namespace ckw #define CKW_ASSERT_MSG(cond, msg) \ do \ { \ - if(!(cond)) \ + if (!(cond)) \ { \ throw ::std::runtime_error(msg); \ } \ - } while(false) + } while (false) /** If the condition is not met, throw an std::runtime_error. * @@ -56,8 +56,7 @@ namespace ckw * @param[in] precond The condition if is met requires the consequence must also be met. * @param[in] cond The condition that is expected to be true if the precondition is true. */ -#define CKW_ASSERT_IF(precond, cond) \ - CKW_ASSERT_MSG(!(precond) || ((precond) && (cond)), #precond " |-> " #cond) +#define CKW_ASSERT_IF(precond, cond) CKW_ASSERT_MSG(!(precond) || ((precond) && (cond)), #precond " |-> " #cond) /** Mark the variables as unused. * diff --git a/compute_kernel_writer/prototype/include/ckw/KernelArgument.h b/compute_kernel_writer/prototype/include/ckw/KernelArgument.h index af8bcde634..3384a20aef 100644 --- a/compute_kernel_writer/prototype/include/ckw/KernelArgument.h +++ b/compute_kernel_writer/prototype/include/ckw/KernelArgument.h @@ -26,6 +26,7 @@ #define CKW_PROTOTYPE_INCLUDE_CKW_KERNELARGUMENT_H #include "ckw/TensorInfo.h" + #include namespace ckw @@ -98,7 +99,7 @@ private: TensorComponentType tensor_component_type; }; - SubId _sub_id{ 0 }; + SubId _sub_id{0}; }; } // namespace ckw diff --git a/compute_kernel_writer/prototype/include/ckw/KernelWriter.h b/compute_kernel_writer/prototype/include/ckw/KernelWriter.h index fdb5fedc59..f9e0066f91 100644 --- a/compute_kernel_writer/prototype/include/ckw/KernelWriter.h +++ b/compute_kernel_writer/prototype/include/ckw/KernelWriter.h @@ -94,7 +94,9 @@ public: * * @return The @ref TensorOperand object. */ - TensorOperand &declare_tensor_argument(const std::string &name, const TensorInfo &info, TensorStorageType storage_type = TensorStorageType::BufferUint8Ptr); + TensorOperand &declare_tensor_argument(const std::string &name, + const TensorInfo &info, + TensorStorageType storage_type = TensorStorageType::BufferUint8Ptr); /** Declare a compile-time constant scalar argument. * @@ -134,7 +136,10 @@ public: * @param[in] sampler The tensor sampling information. * @param[in] dilation_y Dilation in the Y dimension. */ - void op_load(TileOperand &tile, const TensorOperand &tensor, const TensorTileSampler &sampler, const TileOperand &dilation_y = TileOperand("dil_y", 1)); + void op_load(TileOperand &tile, + const TensorOperand &tensor, + const TensorTileSampler &sampler, + const TileOperand &dilation_y = TileOperand("dil_y", 1)); /** Load the data from the tensor memory to the tile using the indirect buffer approach and respective of the sampling information. * @@ -221,7 +226,10 @@ public: * @param[in] first The first argument tile. * @param[in] second The second argument tile. */ - void op_binary_elementwise_function(const TileOperand &dst, BinaryFunction func, const TileOperand &first, const TileOperand &second); + void op_binary_elementwise_function(const TileOperand &dst, + BinaryFunction func, + const TileOperand &first, + const TileOperand &second); /** Write function applied to scalar value: ` = (, , );`. * @@ -231,7 +239,11 @@ public: * @param[in] second The second argument tile. * @param[in] third The third argument tile. */ - void op_ternary_elementwise_function(const TileOperand &dst, TernaryFunction func, const TileOperand &first, const TileOperand &second, const TileOperand &third); + void op_ternary_elementwise_function(const TileOperand &dst, + TernaryFunction func, + const TileOperand &first, + const TileOperand &second, + const TileOperand &third); /** Write if-statement: `if( ) { }`. * @@ -267,7 +279,13 @@ public: * @param[in, out] update_value The value which is updated at every iteration. * @param[in] body The body of the for-loop. */ - void op_for_loop(const TileOperand &var_name, BinaryOp cond_op, const TileOperand &cond_value_name, const TileOperand &update_var_name, AssignmentOp update_op, const TileOperand &update_value_name, const std::function &body); + void op_for_loop(const TileOperand &var_name, + BinaryOp cond_op, + const TileOperand &cond_value_name, + const TileOperand &update_var_name, + AssignmentOp update_op, + const TileOperand &update_value_name, + const std::function &body); /** Write the return statement: `return;` */ @@ -311,8 +329,8 @@ private: ::std::unique_ptr _impl_attr; ::std::unique_ptr _impl; - int32_t _id_space{ 0 }; - int32_t _max_id_space{ 0 }; + int32_t _id_space{0}; + int32_t _max_id_space{0}; }; } // namespace ckw diff --git a/compute_kernel_writer/prototype/include/ckw/KernelWriterHelper.h b/compute_kernel_writer/prototype/include/ckw/KernelWriterHelper.h index a8be859680..3ba079bbc2 100644 --- a/compute_kernel_writer/prototype/include/ckw/KernelWriterHelper.h +++ b/compute_kernel_writer/prototype/include/ckw/KernelWriterHelper.h @@ -32,8 +32,6 @@ #include #include -#include - /* * By including this header file you will be able to supplement the default * Compute Kernel Writer API with additional syntax to help ease the use of CKW. @@ -154,7 +152,9 @@ struct can_be_assigned : ::std::true_type * @tparam TLeft The type of the destination of the assignment. * @tparam TRight The type of the source assigned to the destination. */ -template ::value && can_be_assigned::value>> +template ::value && can_be_assigned::value>> struct Assignment { TLeft lhs; @@ -173,7 +173,7 @@ struct Assignment template inline Assignment operator+=(TLeft &&lhs, TRight &&rhs) { - return Assignment{ std::forward(lhs), std::forward(rhs), AssignmentOp::Increment }; + return Assignment{std::forward(lhs), std::forward(rhs), AssignmentOp::Increment}; } /** Represents the expression: `\p lhs -= \p rhs`. @@ -187,7 +187,7 @@ inline Assignment operator+=(TLeft &&lhs, TRight &&rhs) template inline Assignment operator-=(TLeft &&lhs, TRight &&rhs) { - return Assignment{ std::forward(lhs), std::forward(rhs), AssignmentOp::Decrement }; + return Assignment{std::forward(lhs), std::forward(rhs), AssignmentOp::Decrement}; } // ================================================== @@ -221,7 +221,7 @@ struct can_be_operand> : ::std::true_type template inline UnaryExpression operator!(TSrc &&src) { - return UnaryExpression{ std::forward(src), UnaryOp::LogicalNot }; + return UnaryExpression{std::forward(src), UnaryOp::LogicalNot}; } /** Represents the expression: `~\p src`. @@ -233,7 +233,7 @@ inline UnaryExpression operator!(TSrc &&src) template inline UnaryExpression operator~(TSrc &&src) { - return UnaryExpression{ std::forward(src), UnaryOp::BitwiseNot }; + return UnaryExpression{std::forward(src), UnaryOp::BitwiseNot}; } // ================================================== @@ -247,7 +247,9 @@ inline UnaryExpression operator~(TSrc &&src) * @tparam TLeft The type of the left argument of the expression. * @tparam TRight The type of the right argument of the expression. */ -template ::value && can_be_operand::value>> +template ::value && can_be_operand::value>> struct BinaryExpression { TLeft lhs; @@ -271,7 +273,7 @@ struct can_be_operand> : ::std::true_type template inline BinaryExpression operator+(TLeft &&lhs, TRight &&rhs) { - return BinaryExpression{ std::forward(lhs), std::forward(rhs), BinaryOp::Add }; + return BinaryExpression{std::forward(lhs), std::forward(rhs), BinaryOp::Add}; } /** Represents the expression: `\p lhs - \p rhs`. @@ -285,7 +287,7 @@ inline BinaryExpression operator+(TLeft &&lhs, TRight &&rhs) template inline BinaryExpression operator-(TLeft &&lhs, TRight &&rhs) { - return BinaryExpression{ std::forward(lhs), std::forward(rhs), BinaryOp::Sub }; + return BinaryExpression{std::forward(lhs), std::forward(rhs), BinaryOp::Sub}; } /** Represents the expression: `\p lhs * \p rhs`. @@ -299,7 +301,7 @@ inline BinaryExpression operator-(TLeft &&lhs, TRight &&rhs) template inline BinaryExpression operator*(TLeft &&lhs, TRight &&rhs) { - return BinaryExpression{ std::forward(lhs), std::forward(rhs), BinaryOp::Mul }; + return BinaryExpression{std::forward(lhs), std::forward(rhs), BinaryOp::Mul}; } /** Represents the expression: `\p lhs / \p rhs`. @@ -313,7 +315,7 @@ inline BinaryExpression operator*(TLeft &&lhs, TRight &&rhs) template inline BinaryExpression operator/(TLeft &&lhs, TRight &&rhs) { - return BinaryExpression{ std::forward(lhs), std::forward(rhs), BinaryOp::Div }; + return BinaryExpression{std::forward(lhs), std::forward(rhs), BinaryOp::Div}; } /** Represents the expression: `\p lhs % \p rhs`. @@ -327,7 +329,7 @@ inline BinaryExpression operator/(TLeft &&lhs, TRight &&rhs) template inline BinaryExpression operator%(TLeft &&lhs, TRight &&rhs) { - return BinaryExpression{ std::forward(lhs), std::forward(rhs), BinaryOp::Mod }; + return BinaryExpression{std::forward(lhs), std::forward(rhs), BinaryOp::Mod}; } /** Represents the expression: `\p lhs == \p rhs`. @@ -341,7 +343,7 @@ inline BinaryExpression operator%(TLeft &&lhs, TRight &&rhs) template inline BinaryExpression operator==(TLeft &&lhs, TRight &&rhs) { - return BinaryExpression{ std::forward(lhs), std::forward(rhs), BinaryOp::Equal }; + return BinaryExpression{std::forward(lhs), std::forward(rhs), BinaryOp::Equal}; } /** Represents the expression: `\p lhs < \p rhs`. @@ -355,7 +357,7 @@ inline BinaryExpression operator==(TLeft &&lhs, TRight &&rhs) template inline BinaryExpression operator<(TLeft &&lhs, TRight &&rhs) { - return BinaryExpression{ std::forward(lhs), std::forward(rhs), BinaryOp::Less }; + return BinaryExpression{std::forward(lhs), std::forward(rhs), BinaryOp::Less}; } /** Represents the expression: `\p lhs <= \p rhs`. @@ -369,7 +371,7 @@ inline BinaryExpression operator<(TLeft &&lhs, TRight &&rhs) template inline BinaryExpression operator<=(TLeft &&lhs, TRight &&rhs) { - return BinaryExpression{ std::forward(lhs), std::forward(rhs), BinaryOp::LessEqual }; + return BinaryExpression{std::forward(lhs), std::forward(rhs), BinaryOp::LessEqual}; } /** Represents the expression: `\p lhs > \p rhs`. @@ -383,7 +385,7 @@ inline BinaryExpression operator<=(TLeft &&lhs, TRight &&rhs) template inline BinaryExpression operator>(TLeft &&lhs, TRight &&rhs) { - return BinaryExpression{ std::forward(lhs), std::forward(rhs), BinaryOp::Greater }; + return BinaryExpression{std::forward(lhs), std::forward(rhs), BinaryOp::Greater}; } /** Represents the expression: `\p lhs >= \p rhs`. @@ -397,7 +399,7 @@ inline BinaryExpression operator>(TLeft &&lhs, TRight &&rhs) template inline BinaryExpression operator>=(TLeft &&lhs, TRight &&rhs) { - return BinaryExpression{ std::forward(lhs), std::forward(rhs), BinaryOp::GreaterEqual }; + return BinaryExpression{std::forward(lhs), std::forward(rhs), BinaryOp::GreaterEqual}; } /** Represents the expression: `\p lhs ^ \p rhs`. @@ -411,7 +413,7 @@ inline BinaryExpression operator>=(TLeft &&lhs, TRight &&rhs) template inline BinaryExpression operator^(TLeft &&lhs, TRight &&rhs) { - return BinaryExpression{ std::forward(lhs), std::forward(rhs), BinaryOp::BitwiseXOR }; + return BinaryExpression{std::forward(lhs), std::forward(rhs), BinaryOp::BitwiseXOR}; } /** Represents the expression: `\p lhs && \p rhs`. @@ -425,7 +427,7 @@ inline BinaryExpression operator^(TLeft &&lhs, TRight &&rhs) template inline BinaryExpression logical_and(TLeft &&lhs, TRight &&rhs) { - return BinaryExpression{ std::forward(lhs), std::forward(rhs), BinaryOp::LogicalAnd }; + return BinaryExpression{std::forward(lhs), std::forward(rhs), BinaryOp::LogicalAnd}; } /** Represents the expression: `\p lhs && \p rhs`. @@ -440,7 +442,7 @@ template inline BinaryExpression, TOps...> logical_and(TLeft &&lhs, TRight &&rhs, TOps &&...ops) { return logical_and( - BinaryExpression{ std::forward(lhs), std::forward(rhs), BinaryOp::LogicalAnd }, + BinaryExpression{std::forward(lhs), std::forward(rhs), BinaryOp::LogicalAnd}, std::forward(ops)...); } @@ -455,7 +457,7 @@ inline BinaryExpression, TOps...> logical_and(TL template inline BinaryExpression logical_or(TLeft &&lhs, TRight &&rhs) { - return BinaryExpression{ std::forward(lhs), std::forward(rhs), BinaryOp::LogicalOr }; + return BinaryExpression{std::forward(lhs), std::forward(rhs), BinaryOp::LogicalOr}; } /** Represents the expression: `\p lhs || \p rhs`. @@ -470,7 +472,7 @@ template inline BinaryExpression, TOps...> logical_or(TLeft &&lhs, TRight &&rhs, TOps &&...ops) { return logical_or( - BinaryExpression{ std::forward(lhs), std::forward(rhs), BinaryOp::LogicalOr }, + BinaryExpression{std::forward(lhs), std::forward(rhs), BinaryOp::LogicalOr}, std::forward(ops)...); } @@ -505,7 +507,7 @@ struct can_be_operand> : ::std::true_type template UnaryElementwiseFunction exp(TSrc &&src) { - return UnaryElementwiseFunction{ std::forward(src), UnaryFunction::Exp }; + return UnaryElementwiseFunction{std::forward(src), UnaryFunction::Exp}; } /** Represents the expression: `tanh(\p src)`. @@ -517,7 +519,7 @@ UnaryElementwiseFunction exp(TSrc &&src) template UnaryElementwiseFunction tanh(TSrc &&src) { - return UnaryElementwiseFunction{ std::forward(src), UnaryFunction::Tanh }; + return UnaryElementwiseFunction{std::forward(src), UnaryFunction::Tanh}; } /** Represents the expression: `sqrt(\p src)`. @@ -529,7 +531,7 @@ UnaryElementwiseFunction tanh(TSrc &&src) template UnaryElementwiseFunction sqrt(TSrc &&src) { - return UnaryElementwiseFunction{ std::forward(src), UnaryFunction::Sqrt }; + return UnaryElementwiseFunction{std::forward(src), UnaryFunction::Sqrt}; } /** Represents the expression: `erf(\p src)`. @@ -541,7 +543,7 @@ UnaryElementwiseFunction sqrt(TSrc &&src) template UnaryElementwiseFunction erf(TSrc &&src) { - return UnaryElementwiseFunction{ std::forward(src), UnaryFunction::Erf }; + return UnaryElementwiseFunction{std::forward(src), UnaryFunction::Erf}; } /** Represents the expression: `fabs(\p src)`. @@ -553,7 +555,7 @@ UnaryElementwiseFunction erf(TSrc &&src) template UnaryElementwiseFunction fabs(TSrc &&src) { - return UnaryElementwiseFunction{ std::forward(src), UnaryFunction::Fabs }; + return UnaryElementwiseFunction{std::forward(src), UnaryFunction::Fabs}; } /** Represents the expression: `log(\p src)`. @@ -565,7 +567,7 @@ UnaryElementwiseFunction fabs(TSrc &&src) template UnaryElementwiseFunction log(TSrc &&src) { - return UnaryElementwiseFunction{ std::forward(src), UnaryFunction::Log }; + return UnaryElementwiseFunction{std::forward(src), UnaryFunction::Log}; } /** Represents the expression: `round(\p src)`. @@ -577,7 +579,7 @@ UnaryElementwiseFunction log(TSrc &&src) template UnaryElementwiseFunction round(TSrc &&src) { - return UnaryElementwiseFunction{ std::forward(src), UnaryFunction::Round }; + return UnaryElementwiseFunction{std::forward(src), UnaryFunction::Round}; } /** Represents the expression: `sizeof(\p src)`. @@ -589,7 +591,7 @@ UnaryElementwiseFunction round(TSrc &&src) template UnaryElementwiseFunction sizeOf(TSrc &&src) { - return UnaryElementwiseFunction{ std::forward(src), UnaryFunction::SizeOf }; + return UnaryElementwiseFunction{std::forward(src), UnaryFunction::SizeOf}; } // ================================================== @@ -603,7 +605,9 @@ UnaryElementwiseFunction sizeOf(TSrc &&src) * @tparam TFirst The type of the left argument of the function. * @tparam TSecond The type of the right argument of the function. */ -template ::value && can_be_operand::value>> +template ::value && can_be_operand::value>> struct BinaryElementwiseFunction { TFirst first; @@ -627,7 +631,8 @@ struct can_be_operand> : ::std::true_ template BinaryElementwiseFunction max(TFirst &&first, TSecond &&second) { - return BinaryElementwiseFunction{ std::forward(first), std::forward(second), BinaryFunction::Max }; + return BinaryElementwiseFunction{std::forward(first), std::forward(second), + BinaryFunction::Max}; } /** Represents the function call: `min(\p first, \p second)`. @@ -641,7 +646,8 @@ BinaryElementwiseFunction max(TFirst &&first, TSecond &&second) template BinaryElementwiseFunction min(TFirst &&first, TSecond &&second) { - return BinaryElementwiseFunction{ std::forward(first), std::forward(second), BinaryFunction::Min }; + return BinaryElementwiseFunction{std::forward(first), std::forward(second), + BinaryFunction::Min}; } // ================================================== @@ -656,7 +662,11 @@ BinaryElementwiseFunction min(TFirst &&first, TSecond &&second) * @tparam TSecond The type of the second argument to the function. * @tparam TThird The type of the third argument to the function. */ -template ::value && can_be_operand::value && can_be_operand::value>> +template ::value && can_be_operand::value && + can_be_operand::value>> struct TernaryElementwiseFunction { TFirst first; @@ -683,7 +693,9 @@ struct can_be_operand> : ::s template TernaryElementwiseFunction select(TFirst &&first, TSecond &&second, TThird &&third) { - return TernaryElementwiseFunction{ std::forward(first), std::forward(second), std::forward(third), TernaryFunction::Select }; + return TernaryElementwiseFunction{std::forward(first), + std::forward(second), + std::forward(third), TernaryFunction::Select}; } /** Helper class used to extend a KernelWriter with additional functionality @@ -715,7 +727,8 @@ public: * @param[in] cond The BinaryExpression representing the condition. * @param[in] body The body of the if-statement. */ - KernelWriterHelper &op_if(const BinaryExpression &cond, const std::function &body) + KernelWriterHelper &op_if(const BinaryExpression &cond, + const std::function &body) { TWriter::op_if(cond.lhs, cond.opcode, cond.rhs, body); return *this; @@ -730,7 +743,8 @@ public: * @param[in] body The body of the if-statement. */ template - KernelWriterHelper &op_if(const BinaryExpression &cond, const std::function &body) + KernelWriterHelper &op_if(const BinaryExpression &cond, + const std::function &body) { auto &tmp1 = declare_temp_tile(cond.lhs.tile_info()); op_assign(tmp1, cond.rhs); @@ -747,7 +761,8 @@ public: * @param[in] body The body of the if-statement. */ template - KernelWriterHelper &op_if(const BinaryExpression &cond, const std::function &body) + KernelWriterHelper &op_if(const BinaryExpression &cond, + const std::function &body) { auto &tmp1 = declare_temp_tile(cond.rhs.tile_info()); op_assign(tmp1, cond.lhs); @@ -766,7 +781,8 @@ public: * @param[in] cond The BinaryExpression representing the condition. * @param[in] body The body of the else-if-statement. */ - KernelWriterHelper &op_else_if(const BinaryExpression &cond, const std::function &body) + KernelWriterHelper &op_else_if(const BinaryExpression &cond, + const std::function &body) { TWriter::op_else_if(cond.lhs, cond.opcode, cond.rhs, body); return *this; @@ -781,7 +797,8 @@ public: * @param[in] body The body of the else-if-statement. */ template - KernelWriterHelper &op_else_if(const BinaryExpression &cond, const std::function &body) + KernelWriterHelper &op_else_if(const BinaryExpression &cond, + const std::function &body) { auto &tmp1 = declare_temp_tile(cond.lhs.tile_info()); op_assign(tmp1, cond.rhs); @@ -798,7 +815,8 @@ public: * @param[in] body The body of the else-if-statement. */ template - KernelWriterHelper &op_else_if(const BinaryExpression &cond, const std::function &body) + KernelWriterHelper &op_else_if(const BinaryExpression &cond, + const std::function &body) { auto &tmp1 = declare_temp_tile(cond.rhs.tile_info()); op_assign(tmp1, cond.lhs); @@ -823,7 +841,9 @@ public: * @param[in] updater The Assignment representing the updater. * @param[in] body The body of the for-loop. */ - void op_for_loop(const BinaryExpression &cond, const Assignment &updater, const std::function &body) + void op_for_loop(const BinaryExpression &cond, + const Assignment &updater, + const std::function &body) { TWriter::op_for_loop(cond.lhs, cond.opcode, cond.rhs, updater.lhs, updater.opcode, updater.rhs, body); } @@ -1029,7 +1049,8 @@ public: * @param[in] dst The tile which is assigned to. * @param[in] exp The TernaryElementwiseFunction representing the expression to be evaluated and assigned. */ - void op_assign(const TileOperand &dst, const TernaryElementwiseFunction &exp) + void op_assign(const TileOperand &dst, + const TernaryElementwiseFunction &exp) { TWriter::op_ternary_elementwise_function(dst, exp.opcode, exp.first, exp.second, exp.third); } @@ -1169,11 +1190,11 @@ public: */ void op_assign(const Assignment &exp) { - if(exp.opcode == AssignmentOp::Increment) + if (exp.opcode == AssignmentOp::Increment) { TWriter::op_binary_expression(exp.lhs, exp.lhs, BinaryOp::Add, exp.rhs); } - else if(exp.opcode == AssignmentOp::Decrement) + else if (exp.opcode == AssignmentOp::Decrement) { TWriter::op_binary_expression(exp.lhs, exp.lhs, BinaryOp::Sub, exp.rhs); } @@ -1192,7 +1213,7 @@ public: { auto &tmp1 = declare_temp_tile(exp.lhs.tile_info()); op_assign(tmp1, exp.rhs); - op_assign(Assignment{ exp.lhs, tmp1, exp.opcode }); + op_assign(Assignment{exp.lhs, tmp1, exp.opcode}); } private: @@ -1241,11 +1262,8 @@ private: template ::value>> TileInfo get_largest_size(const TileInfo &first, const TileInfo &second, const TOps &...ops) { - TileInfo largest = { - first.data_type(), - std::max(first.width(), second.width()), - std::max(first.height(), second.height()) - }; + TileInfo largest = {first.data_type(), std::max(first.width(), second.width()), + std::max(first.height(), second.height())}; return get_largest_size(largest, ops...); } diff --git a/compute_kernel_writer/prototype/include/ckw/OperandBase.h b/compute_kernel_writer/prototype/include/ckw/OperandBase.h index 06d9f82756..9842127339 100644 --- a/compute_kernel_writer/prototype/include/ckw/OperandBase.h +++ b/compute_kernel_writer/prototype/include/ckw/OperandBase.h @@ -26,6 +26,7 @@ #define CKW_PROTOTYPE_INCLUDE_CKW_OPERANDBASE_H #include "ckw/types/DataType.h" + #include namespace ckw diff --git a/compute_kernel_writer/prototype/include/ckw/ScalarValue.h b/compute_kernel_writer/prototype/include/ckw/ScalarValue.h index 16c3f6d441..2a9c42acc8 100644 --- a/compute_kernel_writer/prototype/include/ckw/ScalarValue.h +++ b/compute_kernel_writer/prototype/include/ckw/ScalarValue.h @@ -59,9 +59,9 @@ public: _size = sizeof(T); - if(::std::is_integral::value) + if (::std::is_integral::value) { - if(::std::is_signed::value) + if (::std::is_signed::value) { _type = Type::INT; _value.i64 = value; @@ -90,9 +90,9 @@ public: CKW_ASSERT(::std::is_integral::value || ::std::is_floating_point::value); CKW_ASSERT(sizeof(T) >= _size); - if(::std::is_integral::value) + if (::std::is_integral::value) { - if(::std::is_signed::value) + if (::std::is_signed::value) { CKW_ASSERT(_type == Type::INT || _type == Type::UINT); CKW_ASSERT_IF(_type == Type::UINT, sizeof(T) > _size); diff --git a/compute_kernel_writer/prototype/include/ckw/TensorInfo.h b/compute_kernel_writer/prototype/include/ckw/TensorInfo.h index 55f8101a53..24da7dc8ab 100644 --- a/compute_kernel_writer/prototype/include/ckw/TensorInfo.h +++ b/compute_kernel_writer/prototype/include/ckw/TensorInfo.h @@ -143,10 +143,10 @@ public: int32_t id() const; private: - TensorShape _shape{ { 0 } }; - DataType _dt{ DataType::Unknown }; - TensorDataLayout _dl{ TensorDataLayout::Unknown }; - int32_t _id{ -1 }; + TensorShape _shape{{0}}; + DataType _dt{DataType::Unknown}; + TensorDataLayout _dl{TensorDataLayout::Unknown}; + int32_t _id{-1}; }; } // namespace ckw diff --git a/compute_kernel_writer/prototype/include/ckw/TensorOperand.h b/compute_kernel_writer/prototype/include/ckw/TensorOperand.h index 6d88932c66..c221b449fa 100644 --- a/compute_kernel_writer/prototype/include/ckw/TensorOperand.h +++ b/compute_kernel_writer/prototype/include/ckw/TensorOperand.h @@ -139,21 +139,21 @@ private: TensorInfo _info; TensorStorageType _storage_type; - TileOperand *_tile{ nullptr }; + TileOperand *_tile{nullptr}; TensorTileSampler _tile_sampler{}; - ::std::unique_ptr _stride1{ nullptr }; - ::std::unique_ptr _stride2{ nullptr }; - ::std::unique_ptr _stride3{ nullptr }; - ::std::unique_ptr _stride4{ nullptr }; - ::std::unique_ptr _dim0{ nullptr }; - ::std::unique_ptr _dim1{ nullptr }; - ::std::unique_ptr _dim2{ nullptr }; - ::std::unique_ptr _dim3{ nullptr }; - ::std::unique_ptr _dim4{ nullptr }; - ::std::unique_ptr _dim1_dim2{ nullptr }; - ::std::unique_ptr _dim1_dim2_dim3{ nullptr }; - ::std::unique_ptr _offset_first_element_in_bytes{ nullptr }; + ::std::unique_ptr _stride1{nullptr}; + ::std::unique_ptr _stride2{nullptr}; + ::std::unique_ptr _stride3{nullptr}; + ::std::unique_ptr _stride4{nullptr}; + ::std::unique_ptr _dim0{nullptr}; + ::std::unique_ptr _dim1{nullptr}; + ::std::unique_ptr _dim2{nullptr}; + ::std::unique_ptr _dim3{nullptr}; + ::std::unique_ptr _dim4{nullptr}; + ::std::unique_ptr _dim1_dim2{nullptr}; + ::std::unique_ptr _dim1_dim2_dim3{nullptr}; + ::std::unique_ptr _offset_first_element_in_bytes{nullptr}; }; // ================================================================================================= diff --git a/compute_kernel_writer/prototype/include/ckw/TensorTileSampler.h b/compute_kernel_writer/prototype/include/ckw/TensorTileSampler.h index e1bf0c52b8..606dec3535 100644 --- a/compute_kernel_writer/prototype/include/ckw/TensorTileSampler.h +++ b/compute_kernel_writer/prototype/include/ckw/TensorTileSampler.h @@ -26,6 +26,7 @@ #define CKW_PROTOTYPE_INCLUDE_CKW_TENSORTILESAMPLER_H #include "ckw/types/TensorSamplerTypes.h" + #include namespace ckw @@ -55,12 +56,14 @@ public: * @param[in] address_mode_y The address mode of the y dimension. * @param[in] address_mode_z The address mode of the z dimension. */ - TensorTileSampler( - TileOperand &x, TileOperand &y, TileOperand &z, TileOperand &b, - TensorSamplerFormat format, - TensorSamplerAddressModeX address_mode_x, - TensorSamplerAddressModeY address_mode_y, - TensorSamplerAddressModeZ address_mode_z); + TensorTileSampler(TileOperand &x, + TileOperand &y, + TileOperand &z, + TileOperand &b, + TensorSamplerFormat format, + TensorSamplerAddressModeX address_mode_x, + TensorSamplerAddressModeY address_mode_y, + TensorSamplerAddressModeZ address_mode_z); /** Initialize a new instance of @ref TensorSampler class. * @@ -75,13 +78,16 @@ public: * @param[in] address_mode_y The address mode of the y dimension. * @param[in] address_mode_z The address mode of the z dimension. */ - TensorTileSampler( - TileOperand &x, TileOperand &y, TileOperand &z, TileOperand &b, - int32_t height, int32_t width, - TensorSamplerFormat format, - TensorSamplerAddressModeX address_mode_x, - TensorSamplerAddressModeY address_mode_y, - TensorSamplerAddressModeZ address_mode_z); + TensorTileSampler(TileOperand &x, + TileOperand &y, + TileOperand &z, + TileOperand &b, + int32_t height, + int32_t width, + TensorSamplerFormat format, + TensorSamplerAddressModeX address_mode_x, + TensorSamplerAddressModeY address_mode_y, + TensorSamplerAddressModeZ address_mode_z); /** Get the coordinate in the x dimension. */ const TileOperand &x() const; @@ -144,18 +150,18 @@ public: TensorTileSampler &address_mode_z(TensorSamplerAddressModeZ address_mode_z); private: - TileOperand *_x{ nullptr }; - TileOperand *_y{ nullptr }; - TileOperand *_z{ nullptr }; - TileOperand *_b{ nullptr }; - - int32_t _height{ 0 }; - int32_t _width{ 0 }; - - TensorSamplerFormat _format{ TensorSamplerFormat::Unknown }; - TensorSamplerAddressModeX _address_mode_x{ TensorSamplerAddressModeX::Unknown }; - TensorSamplerAddressModeY _address_mode_y{ TensorSamplerAddressModeY::Unknown }; - TensorSamplerAddressModeZ _address_mode_z{ TensorSamplerAddressModeZ::Unknown }; + TileOperand *_x{nullptr}; + TileOperand *_y{nullptr}; + TileOperand *_z{nullptr}; + TileOperand *_b{nullptr}; + + int32_t _height{0}; + int32_t _width{0}; + + TensorSamplerFormat _format{TensorSamplerFormat::Unknown}; + TensorSamplerAddressModeX _address_mode_x{TensorSamplerAddressModeX::Unknown}; + TensorSamplerAddressModeY _address_mode_y{TensorSamplerAddressModeY::Unknown}; + TensorSamplerAddressModeZ _address_mode_z{TensorSamplerAddressModeZ::Unknown}; }; } // namespace ckw diff --git a/compute_kernel_writer/prototype/include/ckw/TileInfo.h b/compute_kernel_writer/prototype/include/ckw/TileInfo.h index de9e47af2b..e0d064169e 100644 --- a/compute_kernel_writer/prototype/include/ckw/TileInfo.h +++ b/compute_kernel_writer/prototype/include/ckw/TileInfo.h @@ -83,7 +83,7 @@ public: DataType data_type() const; private: - DataType _dt{ DataType::Unknown }; + DataType _dt{DataType::Unknown}; TileShape _shape{}; }; diff --git a/compute_kernel_writer/prototype/include/ckw/types/Functions.h b/compute_kernel_writer/prototype/include/ckw/types/Functions.h index bc1f85c188..c6afaa0ac8 100644 --- a/compute_kernel_writer/prototype/include/ckw/types/Functions.h +++ b/compute_kernel_writer/prototype/include/ckw/types/Functions.h @@ -32,14 +32,14 @@ namespace ckw enum class UnaryFunction : int32_t { - Exp = 0x0000, - Tanh = 0x0001, - Sqrt = 0x0002, - Erf = 0x0003, - Fabs = 0x0004, - Log = 0x0006, - Round = 0x0007, - Floor = 0x0008, + Exp = 0x0000, + Tanh = 0x0001, + Sqrt = 0x0002, + Erf = 0x0003, + Fabs = 0x0004, + Log = 0x0006, + Round = 0x0007, + Floor = 0x0008, // Misc SizeOf = 0x0009, @@ -47,8 +47,8 @@ enum class UnaryFunction : int32_t enum class BinaryFunction : int32_t { - Min = 0x0000, - Max = 0x0001, + Min = 0x0000, + Max = 0x0001, }; enum class TernaryFunction : int32_t diff --git a/compute_kernel_writer/prototype/include/ckw/types/Operators.h b/compute_kernel_writer/prototype/include/ckw/types/Operators.h index 43241170a5..b560996837 100644 --- a/compute_kernel_writer/prototype/include/ckw/types/Operators.h +++ b/compute_kernel_writer/prototype/include/ckw/types/Operators.h @@ -69,8 +69,8 @@ enum class BinaryOp : int32_t enum class AssignmentOp : int32_t { // Unary - Increment = 0x0000, // += - Decrement = 0x0001, // -= + Increment = 0x0000, // += + Decrement = 0x0001, // -= }; } // namespace ckw diff --git a/compute_kernel_writer/prototype/include/ckw/types/TensorSamplerTypes.h b/compute_kernel_writer/prototype/include/ckw/types/TensorSamplerTypes.h index 836bd13c95..63405a0764 100644 --- a/compute_kernel_writer/prototype/include/ckw/types/TensorSamplerTypes.h +++ b/compute_kernel_writer/prototype/include/ckw/types/TensorSamplerTypes.h @@ -39,34 +39,38 @@ enum class TensorSamplerFormat : int32_t enum class TensorSamplerAddressModeX : int32_t { - Unknown = 0, - None = 1, // The user guarantees that the X coordinate is always in-bound - OverlappingMin = 2 // (FIXED shapes only) Reduce the load/store length when x == 0 (MIN). The load length will be width % original length - // Leftover elements can be handled using overlapping. This involves processing some of the elements in the array twice. + Unknown = 0, + None = 1, // The user guarantees that the X coordinate is always in-bound + OverlappingMin = + 2 // (FIXED shapes only) Reduce the load/store length when x == 0 (MIN). The load length will be width % original length + // Leftover elements can be handled using overlapping. This involves processing some of the elements in the array twice. }; enum class TensorSamplerAddressModeY : int32_t { - Unknown = 0, - None = 1, // The user guarantees that the Y coordinate is always in-bound - OverlappingMin = 2, // (FIXED shapes only) Reduce the load/store length when x == 0 (MIN). The load length will be width % original length - Skip = 3, // Skip the read/write - SkipMinEdgeOnly = 4, // Skip greater than or equal to max only. The user guarantees that the Y coordinate is always >= 0 - SkipMaxEdgeOnly = 5, // Skip less than 0 only - ClampToNearest = 6, // Clamp the coordinate to nearest edge (0 or max value allowed on Y) - ClampToMinEdgeOnly = 7, // Clamp the negative coordinate to 0 only. Therefore, we expect Y to be always < MAX - ClampToMaxEdgeOnly = 8, // Clamp the coordinate to the max value allowed on Y only. We expect Y to be always >= 0 - ClampToBorder = 9, // Clamp to border which always has 0 value + Unknown = 0, + None = 1, // The user guarantees that the Y coordinate is always in-bound + OverlappingMin = + 2, // (FIXED shapes only) Reduce the load/store length when x == 0 (MIN). The load length will be width % original length + Skip = 3, // Skip the read/write + SkipMinEdgeOnly = + 4, // Skip greater than or equal to max only. The user guarantees that the Y coordinate is always >= 0 + SkipMaxEdgeOnly = 5, // Skip less than 0 only + ClampToNearest = 6, // Clamp the coordinate to nearest edge (0 or max value allowed on Y) + ClampToMinEdgeOnly = 7, // Clamp the negative coordinate to 0 only. Therefore, we expect Y to be always < MAX + ClampToMaxEdgeOnly = 8, // Clamp the coordinate to the max value allowed on Y only. We expect Y to be always >= 0 + ClampToBorder = 9, // Clamp to border which always has 0 value ClampToBorderMinEdgeOnly = 10, ClampToBorderMaxEdgeOnly = 11 }; enum class TensorSamplerAddressModeZ : int32_t { - Unknown = 0, - None = 1, // The user guarantees that the Y coordinate is always in-bound - Skip = 3, // Skip the read/write - SkipMinEdgeOnly = 4, // Skip greater than or equal to max only. The user guarantees that the Y coordinate is always >= 0 + Unknown = 0, + None = 1, // The user guarantees that the Y coordinate is always in-bound + Skip = 3, // Skip the read/write + SkipMinEdgeOnly = + 4, // Skip greater than or equal to max only. The user guarantees that the Y coordinate is always >= 0 SkipMaxEdgeOnly = 5, // Skip less than 0 only ClampToNearest = 6, // Clamp the coordinate to nearest edge (0 or max value allowed on Y) ClampToMinEdgeOnly = 7, // Clamp the negative coordinate to 0 only. Therefore, we expect Y to be always < MAX -- cgit v1.2.1