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 --- compute_kernel_writer/include/ckw/Error.h | 24 +++--- compute_kernel_writer/include/ckw/Kernel.h | 1 + compute_kernel_writer/include/ckw/KernelArgument.h | 3 +- compute_kernel_writer/include/ckw/KernelWriter.h | 85 +++++++++++++++------- compute_kernel_writer/include/ckw/TensorInfo.h | 9 ++- compute_kernel_writer/include/ckw/TensorSampler.h | 23 +++--- compute_kernel_writer/include/ckw/TileInfo.h | 2 +- .../include/ckw/types/ConstantData.h | 10 +-- .../include/ckw/types/MemoryOperation.h | 10 +-- .../include/ckw/types/TensorSamplerTypes.h | 4 +- 10 files changed, 103 insertions(+), 68 deletions(-) (limited to 'compute_kernel_writer/include/ckw') diff --git a/compute_kernel_writer/include/ckw/Error.h b/compute_kernel_writer/include/ckw/Error.h index 7da9544b9e..6b80778957 100644 --- a/compute_kernel_writer/include/ckw/Error.h +++ b/compute_kernel_writer/include/ckw/Error.h @@ -53,7 +53,7 @@ create_error_msg(const std::string &file, const std::string &func, const std::st const std::string arg2(std::to_string(__LINE__)); \ const std::string arg3(msg); \ std::runtime_error(create_error_msg(arg0, arg1, arg2, arg3)); \ - } while(false) + } while (false) /** Mark the variables as unused. * @@ -74,16 +74,16 @@ inline void ignore_unused(T &&...) * * @param[in] msg The error message. */ -#define CKW_THROW_MSG(msg) \ - do \ - { \ - const std::string file(__FILE__); \ - const std::string func(__func__); \ - const std::string line(std::to_string(__LINE__)); \ - const std::string message(msg); \ - \ +#define CKW_THROW_MSG(msg) \ + do \ + { \ + const std::string file(__FILE__); \ + const std::string func(__func__); \ + const std::string line(std::to_string(__LINE__)); \ + const std::string message(msg); \ + \ throw std::runtime_error(ckw::create_error_msg(file, func, line, message)); \ - } while(false) + } while (false) #ifdef COMPUTE_KERNEL_WRITER_ASSERTS_ENABLED @@ -95,11 +95,11 @@ inline void ignore_unused(T &&...) #define CKW_ASSERT_MSG(cond, msg) \ do \ { \ - if(!(cond)) \ + if (!(cond)) \ { \ CKW_THROW_MSG(msg); \ } \ - } while(false) + } while (false) #else // COMPUTE_KERNEL_WRITER_ASSERTS_ENABLED diff --git a/compute_kernel_writer/include/ckw/Kernel.h b/compute_kernel_writer/include/ckw/Kernel.h index dc0cad5503..f9b7bbb82e 100644 --- a/compute_kernel_writer/include/ckw/Kernel.h +++ b/compute_kernel_writer/include/ckw/Kernel.h @@ -26,6 +26,7 @@ #define CKW_INCLUDE_CKW_KERNEL_H #include "ckw/KernelArgument.h" + #include #include diff --git a/compute_kernel_writer/include/ckw/KernelArgument.h b/compute_kernel_writer/include/ckw/KernelArgument.h index 530e2920eb..7e9bcbf1ee 100644 --- a/compute_kernel_writer/include/ckw/KernelArgument.h +++ b/compute_kernel_writer/include/ckw/KernelArgument.h @@ -27,6 +27,7 @@ #include "ckw/types/TensorComponentType.h" #include "ckw/types/TensorStorageType.h" + #include namespace ckw @@ -90,7 +91,7 @@ private: TensorComponentType tensor_component_type; }; - SubId _sub_id{ 0 }; + SubId _sub_id{0}; }; } // namespace ckw diff --git a/compute_kernel_writer/include/ckw/KernelWriter.h b/compute_kernel_writer/include/ckw/KernelWriter.h index 15c99fe652..0d739e859a 100644 --- a/compute_kernel_writer/include/ckw/KernelWriter.h +++ b/compute_kernel_writer/include/ckw/KernelWriter.h @@ -115,7 +115,8 @@ public: * @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; + virtual void + op_binary(const TileOperand &dst, BinaryOp op, const TileOperand &first, const TileOperand &second) = 0; /** Write ternary expression statement: ` = (, , );`. * @@ -125,7 +126,11 @@ public: * @param[in] second The second source tile. * @param[in] third The third source tile. */ - virtual void op_ternary(const TileOperand &dst, TernaryOp op, const TileOperand &first, const TileOperand &second, const TileOperand &third) = 0; + virtual void op_ternary(const TileOperand &dst, + TernaryOp op, + const TileOperand &first, + const TileOperand &second, + const TileOperand &third) = 0; // ============================================================================================= // Flow control @@ -138,7 +143,8 @@ public: * @param[in] rhs The RHS tile of the condition. * @param[in] body The function that writes the body of the if block. */ - virtual void op_if(const TileOperand &lhs, BinaryOp op, const TileOperand &rhs, const std::function &body) = 0; + virtual void + op_if(const TileOperand &lhs, BinaryOp op, const TileOperand &rhs, const std::function &body) = 0; /** Write else-if block: `else if( ) { }`. * @@ -147,7 +153,8 @@ public: * @param[in] rhs The RHS tile of the condition. * @param[in] body The function that writes the body of the else-if block. */ - virtual void op_else_if(const TileOperand &lhs, BinaryOp op, const TileOperand &rhs, const std::function &body) = 0; + virtual void + op_else_if(const TileOperand &lhs, BinaryOp op, const TileOperand &rhs, const std::function &body) = 0; /** Write an else block: `else { }`. * @@ -165,10 +172,13 @@ public: * @param[in] update_value The value which is updated at every iteration. * @param[in] body The function that writes the body of the for-loop block. */ - virtual 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 &body) = 0; + virtual 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 &body) = 0; /** Write the return statement. */ virtual void op_return() = 0; @@ -271,9 +281,13 @@ public: * @param[in] z z-coordinate * @param[in] batch batch */ - virtual 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) = 0; + virtual 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) = 0; /** Load the data from the tensor memory to the tile in a dilated way using the sampling information. * @@ -282,27 +296,41 @@ public: * @param[in] dilation_x Dilation while reading in x-dimension * @param[in] dilation_y Dilation while reading in y-dimension */ - virtual 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) = 0; + virtual 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) = 0; /** Store the data to the tensor memory from the tile using the sampling information. * * Similar to @ref KernelWriter::op_load() */ - virtual 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) = 0; + virtual 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) = 0; /** Store the data to the tensor memory from the tile in a dilated way using the sampling information. * * Similar to @ref KernelWriter::op_load_dilated() */ - virtual 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) = 0; + virtual 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) = 0; /** Load the data from the tensor memory to the tile using the indirect buffer approach and respecting the sampling information. * @@ -314,8 +342,13 @@ public: * @param[in] z z-coordinate * @param[in] batch batch */ - virtual void op_load_indirect(const TileOperand &tile_op, const TensorOperand &tensor_op, TensorSampler &sampler, - const TileOperand &x, const TileOperand &y, const TileOperand &z, const TileOperand &batch_op) = 0; + virtual void op_load_indirect(const TileOperand &tile_op, + const TensorOperand &tensor_op, + TensorSampler &sampler, + const TileOperand &x, + const TileOperand &y, + const TileOperand &z, + const TileOperand &batch_op) = 0; protected: // ============================================================================================= @@ -373,8 +406,8 @@ protected: static DataType get_data_type(const ConstantData &data); private: - int32_t _id_space{ 0 }; - int32_t _last_created_id_space{ 0 }; + int32_t _id_space{0}; + int32_t _last_created_id_space{0}; }; } // namespace ckw diff --git a/compute_kernel_writer/include/ckw/TensorInfo.h b/compute_kernel_writer/include/ckw/TensorInfo.h index 87cf7c1426..5c87cb5b12 100644 --- a/compute_kernel_writer/include/ckw/TensorInfo.h +++ b/compute_kernel_writer/include/ckw/TensorInfo.h @@ -27,6 +27,7 @@ #include "ckw/types/DataType.h" #include "ckw/types/TensorDataLayout.h" + #include #include @@ -85,10 +86,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/include/ckw/TensorSampler.h b/compute_kernel_writer/include/ckw/TensorSampler.h index 1b51636edb..117e8de2cf 100644 --- a/compute_kernel_writer/include/ckw/TensorSampler.h +++ b/compute_kernel_writer/include/ckw/TensorSampler.h @@ -25,8 +25,8 @@ #ifndef CKW_INCLUDE_CKW_TENSORSAMPLER_H #define CKW_INCLUDE_CKW_TENSORSAMPLER_H -#include "ckw/types/TensorStorageType.h" #include "ckw/types/TensorSamplerTypes.h" +#include "ckw/types/TensorStorageType.h" namespace ckw { @@ -53,12 +53,11 @@ 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. */ - TensorSampler( - TensorStorageType storage, - TensorSamplerFormat format, - TensorSamplerAddressModeX address_mode_x, - TensorSamplerAddressModeY address_mode_y, - TensorSamplerAddressModeZ address_mode_z); + TensorSampler(TensorStorageType storage, + TensorSamplerFormat format, + TensorSamplerAddressModeX address_mode_x, + TensorSamplerAddressModeY address_mode_y, + TensorSamplerAddressModeZ address_mode_z); /** Get the storage for the tensor */ TensorStorageType storage() const; @@ -91,11 +90,11 @@ public: TensorSampler &address_mode_z(TensorSamplerAddressModeZ address_mode_z); private: - TensorStorageType _storage { TensorStorageType::BufferUint8Ptr }; - TensorSamplerFormat _format { TensorSamplerFormat::Unknown }; - TensorSamplerAddressModeX _address_mode_x { TensorSamplerAddressModeX::Unknown }; - TensorSamplerAddressModeY _address_mode_y { TensorSamplerAddressModeY::Unknown }; - TensorSamplerAddressModeZ _address_mode_z { TensorSamplerAddressModeZ::Unknown }; + TensorStorageType _storage{TensorStorageType::BufferUint8Ptr}; + 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/include/ckw/TileInfo.h b/compute_kernel_writer/include/ckw/TileInfo.h index b8094f79bf..678bb7aaf6 100644 --- a/compute_kernel_writer/include/ckw/TileInfo.h +++ b/compute_kernel_writer/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/include/ckw/types/ConstantData.h b/compute_kernel_writer/include/ckw/types/ConstantData.h index 95425b2c65..7708818ca8 100644 --- a/compute_kernel_writer/include/ckw/types/ConstantData.h +++ b/compute_kernel_writer/include/ckw/types/ConstantData.h @@ -45,12 +45,12 @@ class KernelWriter; class ConstantData { - using String = std::string; + using String = std::string; using StringVector = std::vector; public: /** Templated constructor */ - template + template ConstantData(std::initializer_list> values, DataType data_type); private: @@ -60,14 +60,14 @@ private: * * @return true if user provided data type and the template type are conformant */ - template + template bool validate(DataType data_type); /** Get the constant data as a 2d vector of string values * * @return a 2d vector of strings that has the string-converted values */ - const std::vector& values() const; + const std::vector &values() const; /** Get the underlying data type of the constant values * @@ -81,7 +81,7 @@ private: private: // Data members std::vector _values{}; - DataType _data_type{}; + DataType _data_type{}; }; } // namespace ckw diff --git a/compute_kernel_writer/include/ckw/types/MemoryOperation.h b/compute_kernel_writer/include/ckw/types/MemoryOperation.h index 0466b82df2..f93f60c51a 100644 --- a/compute_kernel_writer/include/ckw/types/MemoryOperation.h +++ b/compute_kernel_writer/include/ckw/types/MemoryOperation.h @@ -27,11 +27,11 @@ namespace ckw { - enum class MemoryOperation - { - Load = 1, - Store = 2 - }; +enum class MemoryOperation +{ + Load = 1, + Store = 2 +}; } // namespace ckw #endif /* CKW_INCLUDE_CKW_TYPES_MEMORYOPERATION */ diff --git a/compute_kernel_writer/include/ckw/types/TensorSamplerTypes.h b/compute_kernel_writer/include/ckw/types/TensorSamplerTypes.h index 43dce1d4e4..512d0b4501 100644 --- a/compute_kernel_writer/include/ckw/types/TensorSamplerTypes.h +++ b/compute_kernel_writer/include/ckw/types/TensorSamplerTypes.h @@ -75,8 +75,8 @@ enum class TensorSamplerAddressModeY : int32_t */ enum class TensorSamplerAddressModeZ : int32_t { - Unknown = 0, - None = 1, + Unknown = 0, + None = 1, }; } // namespace ckw -- cgit v1.2.1