From: 오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Wed, 5 Dec 2018 07:29:18 +0000 (+0900) Subject: Fix header files format in libs (#3879) X-Git-Tag: 0.3~195 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a67487bca04e75d60bb14984818de56f94e9f076;p=platform%2Fcore%2Fml%2Fnnfw.git Fix header files format in libs (#3879) Fix header files format in libs except comes from public tensorflow Signed-off-by: Hyeongseok Oh --- diff --git a/libs/support/include/.FORMATDENY b/libs/support/include/.FORMATDENY deleted file mode 100644 index e69de29..0000000 diff --git a/libs/support/include/support/nnapi/feature/Reader.h b/libs/support/include/support/nnapi/feature/Reader.h index 3ad9b17..23bd478 100644 --- a/libs/support/include/support/nnapi/feature/Reader.h +++ b/libs/support/include/support/nnapi/feature/Reader.h @@ -38,9 +38,10 @@ namespace feature { /** - * @brief Class to read value of feature which is inherited from nnfw::util::feature::Reader class + * @brief Class to read value of feature which is inherited + * from nnfw::util::feature::Reader class */ -template class Reader : public nnfw::util::feature::Reader +template class Reader : public nnfw::util::feature::Reader { public: /** @@ -48,8 +49,7 @@ public: * @param[in] shape The shape of a feature * @param[in] base The base address of a feature */ - Reader(const nnfw::util::feature::Shape &shape, const T *base) - : _shape{shape}, _base{base} + Reader(const nnfw::util::feature::Shape &shape, const T *base) : _shape{shape}, _base{base} { // DO NOTHING } @@ -68,8 +68,8 @@ public: } private: - nnfw::util::feature::Shape _shape; /**< Shape of feature */ - const T *_base; /**< Base address of feature */ + nnfw::util::feature::Shape _shape; /**< Shape of feature */ + const T *_base; /**< Base address of feature */ }; } // namespace feature diff --git a/libs/support/include/support/tflite/Assert.h b/libs/support/include/support/tflite/Assert.h index 77da5e6..ee19568 100644 --- a/libs/support/include/support/tflite/Assert.h +++ b/libs/support/include/support/tflite/Assert.h @@ -30,15 +30,16 @@ #define STR_DETAIL(value) #value #define STR(value) STR_DETAIL(value) -#define TFLITE_ENSURE(exp) { \ - const TfLiteStatus status = (exp); \ - \ - if (status != kTfLiteOk) \ - { \ - std::ostringstream ss; \ - ss << #exp << " failed (" << __FILE__ << ":" << __LINE__ << ")"; \ - throw std::runtime_error{ss.str()}; \ - } \ -} +#define TFLITE_ENSURE(exp) \ + { \ + const TfLiteStatus status = (exp); \ + \ + if (status != kTfLiteOk) \ + { \ + std::ostringstream ss; \ + ss << #exp << " failed (" << __FILE__ << ":" << __LINE__ << ")"; \ + throw std::runtime_error{ss.str()}; \ + } \ + } #endif // __NNFW_SUPPORT_TFLITE_ASSERT_H__ diff --git a/libs/support/include/support/tflite/Diff.h b/libs/support/include/support/tflite/Diff.h index 6a43a57..29d5ae6 100644 --- a/libs/support/include/support/tflite/Diff.h +++ b/libs/support/include/support/tflite/Diff.h @@ -46,7 +46,7 @@ public: * @param[in] comparator Comparator object for tensor comparation */ TfLiteInterpMatchApp(const nnfw::util::tensor::Comparator &comparator) - : _verbose{false}, _comparator(comparator) + : _verbose{false}, _comparator(comparator) { // DO NOTHING } @@ -78,8 +78,7 @@ public: */ template bool compareSingleTensorView(const nnfw::support::tflite::TensorView &expected, - const nnfw::support::tflite::TensorView &obtained, - int id) const; + const nnfw::support::tflite::TensorView &obtained, int id) const; private: const nnfw::util::tensor::Comparator &_comparator; @@ -129,10 +128,7 @@ public: * @brief Generate random numbers for type T * @return Random generated value */ - template T generate(void) - { - return _dist(_rand); - } + template T generate(void) { return _dist(_rand); } private: std::minstd_rand _rand; @@ -140,8 +136,7 @@ private: const TfLiteQuantizationParams _quantization; }; -template <> -uint8_t RandomGenerator::generate(void); +template <> uint8_t RandomGenerator::generate(void); /** * @brief Structure for NNAPI correctness test diff --git a/libs/support/include/support/tflite/FeatureView.h b/libs/support/include/support/tflite/FeatureView.h index 7f260ed..29a6d7b 100644 --- a/libs/support/include/support/tflite/FeatureView.h +++ b/libs/support/include/support/tflite/FeatureView.h @@ -38,12 +38,12 @@ namespace support namespace tflite { -template class FeatureView; +template class FeatureView; /** * @brief Class to support reading element of float type feature */ -template<> class FeatureView : public nnfw::util::feature::Reader +template <> class FeatureView : public nnfw::util::feature::Reader { public: /** diff --git a/libs/support/include/support/tflite/InterpreterSession.h b/libs/support/include/support/tflite/InterpreterSession.h index 63c2a12..70bac22 100644 --- a/libs/support/include/support/tflite/InterpreterSession.h +++ b/libs/support/include/support/tflite/InterpreterSession.h @@ -92,7 +92,7 @@ public: } private: - ::tflite::Interpreter * const _interp; + ::tflite::Interpreter *const _interp; }; } // namespace tflite diff --git a/libs/support/include/support/tflite/NNAPISession.h b/libs/support/include/support/tflite/NNAPISession.h index 7046622..d6ad46b 100644 --- a/libs/support/include/support/tflite/NNAPISession.h +++ b/libs/support/include/support/tflite/NNAPISession.h @@ -80,10 +80,7 @@ public: * @brief Run the Invoke function of NNAPI delegate * @return @c true if Invoke() is successful, otherwise @c false */ - bool run(void) override - { - return kTfLiteOk == _delegate.Invoke(_interp); - } + bool run(void) override { return kTfLiteOk == _delegate.Invoke(_interp); } /** * @brief Tear down TfLite interpreter session @@ -96,7 +93,7 @@ public: } private: - ::tflite::Interpreter * const _interp; + ::tflite::Interpreter *const _interp; nnfw::NNAPIDelegate _delegate; }; diff --git a/libs/support/include/support/tflite/TensorLogger.h b/libs/support/include/support/tflite/TensorLogger.h index f10f32a..e124cae 100644 --- a/libs/support/include/support/tflite/TensorLogger.h +++ b/libs/support/include/support/tflite/TensorLogger.h @@ -55,114 +55,113 @@ namespace tflite */ class TensorLogger { - private: - std::ofstream _outfile; - - public: - /** - * @brief Get TensorLogger instance - * @return The TensorLogger instance - */ - static TensorLogger &instance() +private: + std::ofstream _outfile; + +public: + /** + * @brief Get TensorLogger instance + * @return The TensorLogger instance + */ + static TensorLogger &instance() + { + static TensorLogger instance; + return instance; + } + + /** + * @brief Save the tensor details to file from interpreter + * @param[in] path The file path to save + * @param[in] interp The TfLite interpreter + */ + void save(const std::string &path, ::tflite::Interpreter &interp) + { + open(path); + + int log_index = 0; + for (const auto id : interp.inputs()) { - static TensorLogger instance; - return instance; + _outfile << "# input tensors" << std::endl; + printTensor(interp, id, log_index++); } - - /** - * @brief Save the tensor details to file from interpreter - * @param[in] path The file path to save - * @param[in] interp The TfLite interpreter - */ - void save(const std::string &path, ::tflite::Interpreter &interp) + for (const auto id : interp.outputs()) { - open(path); - - int log_index = 0; - for (const auto id : interp.inputs()) - { - _outfile << "# input tensors" << std::endl; - printTensor(interp, id, log_index++); - } - for (const auto id : interp.outputs()) - { - _outfile << "# output tensors" << std::endl; - printTensor(interp, id, log_index++); - } - close(); + _outfile << "# output tensors" << std::endl; + printTensor(interp, id, log_index++); } - - private: - - void open(const std::string &path) + close(); + } + +private: + void open(const std::string &path) + { + if (!_outfile.is_open()) + _outfile.open(path, std::ios_base::out); + + _outfile << "# ------ file: " << path << " ------" << std::endl + << "tensor_shape_gen = []" << std::endl + << "tensor_value_gen = []" << std::endl + << std::endl; + } + + void printTensor(::tflite::Interpreter &interp, const int id, const int log_index) + { + const TfLiteTensor *tensor = interp.tensor(id); + + _outfile << "# tensor name: " << tensor->name << std::endl; + _outfile << "# tflite::interpreter.tensor(" << id << ") -> " + "tensor_value_gen[" + << log_index << "]" << std::endl; + + if (tensor->type == kTfLiteInt32) { - if (! _outfile.is_open()) - _outfile.open(path, std::ios_base::out); - - _outfile << "# ------ file: " << path << " ------" << std::endl - << "tensor_shape_gen = []" << std::endl - << "tensor_value_gen = []" << std::endl << std::endl; + printTensorShape(tensor); + printTensorValue(tensor, tensor->data.i32); } - - void printTensor(::tflite::Interpreter &interp, const int id, const int log_index) + else if (interp.tensor(id)->type == kTfLiteUInt8) { - const TfLiteTensor* tensor = interp.tensor(id); - - _outfile << "# tensor name: " << tensor->name << std::endl; - _outfile << "# tflite::interpreter.tensor("<< id <<") -> " - "tensor_value_gen["<< log_index << "]" << std::endl; - - if (tensor->type == kTfLiteInt32) - { - printTensorShape(tensor); - printTensorValue(tensor, tensor->data.i32); - } - else if (interp.tensor(id)->type == kTfLiteUInt8) - { - printTensorShape(tensor); - printTensorValue(tensor, tensor->data.uint8); - } - else if (tensor->type == kTfLiteFloat32) - { - printTensorShape(tensor); - printTensorValue(tensor, tensor->data.f); - } + printTensorShape(tensor); + printTensorValue(tensor, tensor->data.uint8); } - - void printTensorShape(const TfLiteTensor* tensor) + else if (tensor->type == kTfLiteFloat32) { - _outfile << "tensor_shape_gen.append('{"; + printTensorShape(tensor); + printTensorValue(tensor, tensor->data.f); + } + } - size_t r = 0; - for (; r < tensor->dims->size - 1; r++) - { - _outfile << tensor->dims->data[r] - << ", "; - } - _outfile << tensor->dims->data[r]; + void printTensorShape(const TfLiteTensor *tensor) + { + _outfile << "tensor_shape_gen.append('{"; - _outfile << "}')" << std::endl; + size_t r = 0; + for (; r < tensor->dims->size - 1; r++) + { + _outfile << tensor->dims->data[r] << ", "; } + _outfile << tensor->dims->data[r]; - template - void printTensorValue(const TfLiteTensor* tensor, T* tensor_data_ptr) - { - _outfile << "tensor_value_gen.append(["; + _outfile << "}')" << std::endl; + } - _outfile << std::fixed << std::setprecision(10); + template void printTensorValue(const TfLiteTensor *tensor, T *tensor_data_ptr) + { + _outfile << "tensor_value_gen.append(["; - const T *end = reinterpret_cast(tensor->data.raw_const + tensor->bytes); - for (T *ptr = tensor_data_ptr; ptr < end; ptr++) - _outfile << *ptr << ", "; + _outfile << std::fixed << std::setprecision(10); - _outfile << "])" << std::endl << std::endl; - } + const T *end = reinterpret_cast(tensor->data.raw_const + tensor->bytes); + for (T *ptr = tensor_data_ptr; ptr < end; ptr++) + _outfile << *ptr << ", "; - void close() - { - _outfile << "# --------- tensor shape and value defined above ---------" << std::endl; - _outfile.close(); - } + _outfile << "])" << std::endl << std::endl; + } + + void close() + { + _outfile << "# --------- tensor shape and value defined above ---------" << std::endl; + _outfile.close(); + } }; } // namespace tflite diff --git a/libs/support/include/support/tflite/TensorUtils.h b/libs/support/include/support/tflite/TensorUtils.h index 86cbcce..b454453 100644 --- a/libs/support/include/support/tflite/TensorUtils.h +++ b/libs/support/include/support/tflite/TensorUtils.h @@ -37,13 +37,11 @@ namespace tflite * @param[in] tensor The tensor object to be compared * @return @c true if tensor type is kTfLiteFloat32, otherwise @c false */ -inline bool isFloatTensor(const TfLiteTensor *tensor) -{ - return tensor->type == kTfLiteFloat32; -} +inline bool isFloatTensor(const TfLiteTensor *tensor) { return tensor->type == kTfLiteFloat32; } /** - * @brief Get @c true if tensor is 4-D tensor and the first dimension length is 1, otherwise @c false + * @brief Get @c true if tensor is 4-D tensor and the first dimension length is 1, + * otherwise @c false * @param[in] tensor The tensor object to be compared * @return @c true if tensor is 4-D tensor and the first dimension length is 1, otherwise @c false */ diff --git a/libs/support/include/support/tflite/TensorView.h b/libs/support/include/support/tflite/TensorView.h index d5573a2..97216e4 100644 --- a/libs/support/include/support/tflite/TensorView.h +++ b/libs/support/include/support/tflite/TensorView.h @@ -40,7 +40,7 @@ namespace tflite /** * @brief Class to define TensorView which is inherited from nnfw::util::tensor::Reader class */ -template class TensorView final : public nnfw::util::tensor::Reader +template class TensorView final : public nnfw::util::tensor::Reader { public: /** @@ -48,8 +48,7 @@ public: * @param[in] shape The shape of a tensor * @param[in] base The base address of a tensor */ - TensorView(const nnfw::util::tensor::Shape &shape, T *base) - : _shape{shape}, _base{base} + TensorView(const nnfw::util::tensor::Shape &shape, T *base) : _shape{shape}, _base{base} { // Set 'stride' _stride.init(_shape); @@ -90,8 +89,8 @@ private: nnfw::util::tensor::Shape _shape; /**< The tensor shape */ public: - T *_base; /**< The base address of tensor */ - nnfw::util::tensor::NonIncreasingStride _stride; /**< The NonIncreasingStride object */ + T *_base; /**< The base address of tensor */ + nnfw::util::tensor::NonIncreasingStride _stride; /**< The NonIncreasingStride object */ public: // TODO Introduce Operand ID class diff --git a/libs/support/include/support/tflite/interp/FunctionBuilder.h b/libs/support/include/support/tflite/interp/FunctionBuilder.h index 3329a77..0e2f368 100644 --- a/libs/support/include/support/tflite/interp/FunctionBuilder.h +++ b/libs/support/include/support/tflite/interp/FunctionBuilder.h @@ -42,7 +42,7 @@ namespace interp class FunctionBuilder final : public Builder { public: - using SetupFunc = std::function; + using SetupFunc = std::function; public: /** diff --git a/libs/support/include/support/tflite/kernels/Abs.h b/libs/support/include/support/tflite/kernels/Abs.h index e2a639a..aaf96ae 100644 --- a/libs/support/include/support/tflite/kernels/Abs.h +++ b/libs/support/include/support/tflite/kernels/Abs.h @@ -30,10 +30,10 @@ namespace nnfw namespace Abs { - void *InitAbs(TfLiteContext *context, const char *buffer, size_t length); - void FreeAbs(TfLiteContext *context, void *buffer); - TfLiteStatus PrepareAbs(TfLiteContext *context, TfLiteNode *node); - TfLiteStatus EvalAbs(TfLiteContext *context, TfLiteNode *node); +void *InitAbs(TfLiteContext *context, const char *buffer, size_t length); +void FreeAbs(TfLiteContext *context, void *buffer); +TfLiteStatus PrepareAbs(TfLiteContext *context, TfLiteNode *node); +TfLiteStatus EvalAbs(TfLiteContext *context, TfLiteNode *node); } // namespace Abs } // namespace nnfw diff --git a/libs/support/include/support/tflite/kernels/CustomOps.h b/libs/support/include/support/tflite/kernels/CustomOps.h index 131dd23..fa33c7b 100644 --- a/libs/support/include/support/tflite/kernels/CustomOps.h +++ b/libs/support/include/support/tflite/kernels/CustomOps.h @@ -38,13 +38,14 @@ namespace custom namespace nnfw { -#define REGISTER_FUNCTION(Name) \ - TfLiteRegistration *Register_##Name(void) \ - { \ - static TfLiteRegistration r = { Name::Init##Name , Name::Free##Name , Name::Prepare##Name , \ - Name::Eval##Name ,}; \ - r.custom_name = #Name; \ - return &r; \ +#define REGISTER_FUNCTION(Name) \ + TfLiteRegistration *Register_##Name(void) \ + { \ + static TfLiteRegistration r = { \ + Name::Init##Name, Name::Free##Name, Name::Prepare##Name, Name::Eval##Name, \ + }; \ + r.custom_name = #Name; \ + return &r; \ } REGISTER_FUNCTION(TensorFlowMax) @@ -54,9 +55,9 @@ REGISTER_FUNCTION(Abs) #undef REGISTER_FUNCTION -} // namespace nnfw -} // namespace custom -} // namespace ops -} // namespace tflite +} // namespace nnfw +} // namespace custom +} // namespace ops +} // namespace tflite #endif // __NNFW_SUPPORT_TFLITE_KERNELS_CUSTOM_OP_H__ diff --git a/libs/support/include/support/tflite/kernels/SquaredDifference.h b/libs/support/include/support/tflite/kernels/SquaredDifference.h index f0a97df..0ceb83b 100644 --- a/libs/support/include/support/tflite/kernels/SquaredDifference.h +++ b/libs/support/include/support/tflite/kernels/SquaredDifference.h @@ -16,7 +16,8 @@ /** * @file SquaredDifference.h - * @brief This file contains SquaredDifference namespace and SquaredDifference function definitions + * @brief This file contains SquaredDifference namespace and SquaredDifference function + * definitions * @ingroup COM_AI_RUNTIME */ @@ -36,38 +37,38 @@ namespace nnfw namespace SquaredDifference { - /** - * @brief Initialize SquaredDifference operand using the contents of buffer - * @param[in] context The TfLite context - * @param[in] buffer The buffer with contents - * @param[in] length The buffer length - * @return The void pointer for user data - */ - void *InitSquaredDifference(TfLiteContext *context, const char *buffer, size_t length); +/** + * @brief Initialize SquaredDifference operand using the contents of buffer + * @param[in] context The TfLite context + * @param[in] buffer The buffer with contents + * @param[in] length The buffer length + * @return The void pointer for user data + */ +void *InitSquaredDifference(TfLiteContext *context, const char *buffer, size_t length); - /** - * @brief Release any memory it might have allocated via 'InitSquaredDifference' - * @param[in] context The TfLite context - * @param[in] buffer The buffer with contents - * @return N/A - */ - void FreeSquaredDifference(TfLiteContext *context, void *buffer); +/** + * @brief Release any memory it might have allocated via 'InitSquaredDifference' + * @param[in] context The TfLite context + * @param[in] buffer The buffer with contents + * @return N/A + */ +void FreeSquaredDifference(TfLiteContext *context, void *buffer); - /** - * @brief Prepare the SquaredDifference operand for execution - * @param[in] context The TfLite context - * @param[in] node The operand node - * @return The TfLite status - */ - TfLiteStatus PrepareSquaredDifference(TfLiteContext *context, TfLiteNode *node); +/** + * @brief Prepare the SquaredDifference operand for execution + * @param[in] context The TfLite context + * @param[in] node The operand node + * @return The TfLite status + */ +TfLiteStatus PrepareSquaredDifference(TfLiteContext *context, TfLiteNode *node); - /** - * @brief Evaluation the SquaredDifference operand for execution - * @param[in] context The TfLite context - * @param[in] node The operand node - * @return The TfLite status - */ - TfLiteStatus EvalSquaredDifference(TfLiteContext *context, TfLiteNode *node); +/** + * @brief Evaluation the SquaredDifference operand for execution + * @param[in] context The TfLite context + * @param[in] node The operand node + * @return The TfLite status + */ +TfLiteStatus EvalSquaredDifference(TfLiteContext *context, TfLiteNode *node); } // namespace SquaredDifference } // namespace nnfw diff --git a/libs/support/include/support/tflite/kernels/TensorFlowMax.h b/libs/support/include/support/tflite/kernels/TensorFlowMax.h index bd4db77..9cc8215 100644 --- a/libs/support/include/support/tflite/kernels/TensorFlowMax.h +++ b/libs/support/include/support/tflite/kernels/TensorFlowMax.h @@ -36,38 +36,38 @@ namespace nnfw namespace TensorFlowMax { - /** - * @brief Initialize TensorFlowMax operand using the contents of buffer - * @param[in] context The TfLite context - * @param[in] buffer The buffer with contents - * @param[in] length The buffer length - * @return The void pointer for user data - */ - void *InitTensorFlowMax(TfLiteContext *context, const char *buffer, size_t length); +/** + * @brief Initialize TensorFlowMax operand using the contents of buffer + * @param[in] context The TfLite context + * @param[in] buffer The buffer with contents + * @param[in] length The buffer length + * @return The void pointer for user data + */ +void *InitTensorFlowMax(TfLiteContext *context, const char *buffer, size_t length); - /** - * @brief Release any memory it might have allocated via 'InitTensorFlowMax' - * @param[in] context The TfLite context - * @param[in] buffer The buffer with contents - * @return N/A - */ - void FreeTensorFlowMax(TfLiteContext *context, void *buffer); +/** + * @brief Release any memory it might have allocated via 'InitTensorFlowMax' + * @param[in] context The TfLite context + * @param[in] buffer The buffer with contents + * @return N/A + */ +void FreeTensorFlowMax(TfLiteContext *context, void *buffer); - /** - * @brief Prepare the TensorFlowMax operand for execution - * @param[in] context The TfLite context - * @param[in] node The operand node - * @return The TfLite status - */ - TfLiteStatus PrepareTensorFlowMax(TfLiteContext *context, TfLiteNode *node); +/** + * @brief Prepare the TensorFlowMax operand for execution + * @param[in] context The TfLite context + * @param[in] node The operand node + * @return The TfLite status + */ +TfLiteStatus PrepareTensorFlowMax(TfLiteContext *context, TfLiteNode *node); - /** - * @brief Evaluation the TensorFlowMax operand for execution - * @param[in] context The TfLite context - * @param[in] node The operand node - * @return The TfLite status - */ - TfLiteStatus EvalTensorFlowMax(TfLiteContext *context, TfLiteNode *node); +/** + * @brief Evaluation the TensorFlowMax operand for execution + * @param[in] context The TfLite context + * @param[in] node The operand node + * @return The TfLite status + */ +TfLiteStatus EvalTensorFlowMax(TfLiteContext *context, TfLiteNode *node); } // namespace TensorFlowMax } // namespace nnfw diff --git a/libs/support/include/support/tflite/kernels/TensorFlowSum.h b/libs/support/include/support/tflite/kernels/TensorFlowSum.h index 88a5f2a..b1eff63 100644 --- a/libs/support/include/support/tflite/kernels/TensorFlowSum.h +++ b/libs/support/include/support/tflite/kernels/TensorFlowSum.h @@ -30,10 +30,10 @@ namespace nnfw namespace TensorFlowSum { - void *InitTensorFlowSum(TfLiteContext *context, const char *buffer, size_t length); - void FreeTensorFlowSum(TfLiteContext *context, void *buffer); - TfLiteStatus PrepareTensorFlowSum(TfLiteContext *context, TfLiteNode *node); - TfLiteStatus EvalTensorFlowSum(TfLiteContext *context, TfLiteNode *node); +void *InitTensorFlowSum(TfLiteContext *context, const char *buffer, size_t length); +void FreeTensorFlowSum(TfLiteContext *context, void *buffer); +TfLiteStatus PrepareTensorFlowSum(TfLiteContext *context, TfLiteNode *node); +TfLiteStatus EvalTensorFlowSum(TfLiteContext *context, TfLiteNode *node); } // namespace TensorFlowSum } // namespace nnfw diff --git a/libs/support/include/support/tflite/kernels/register.h b/libs/support/include/support/tflite/kernels/register.h index 43a4c1a..389c351 100644 --- a/libs/support/include/support/tflite/kernels/register.h +++ b/libs/support/include/support/tflite/kernels/register.h @@ -14,6 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ +// NOTE To minimize diff with upstream tensorflow, disable clang-format +// clang-format off + // NOTE This header is derived from the following file (in TensorFlow) // 'externals/tensorflow/tensorflow/contrib/lite/kernels/register.h' #ifndef __NNFW_SUPPORT_TFLITE_KERNELS_REGISTER_H__ @@ -38,3 +41,5 @@ class BuiltinOpResolver : public MutableOpResolver { } // namespace tflite #endif // __NNFW_SUPPORT_TFLITE_KERNELS_REGISTER_H__ + +// clang-format on diff --git a/libs/util/include/.FORMATDENY b/libs/util/include/.FORMATDENY deleted file mode 100644 index e69de29..0000000 diff --git a/libs/util/include/util/EnvVar.h b/libs/util/include/util/EnvVar.h index fd8bbda..7150dc3 100644 --- a/libs/util/include/util/EnvVar.h +++ b/libs/util/include/util/EnvVar.h @@ -28,7 +28,6 @@ #include #include - namespace nnfw { namespace util diff --git a/libs/util/include/util/feature/Index.h b/libs/util/include/util/feature/Index.h index 63760b8..ac95391 100644 --- a/libs/util/include/util/feature/Index.h +++ b/libs/util/include/util/feature/Index.h @@ -61,7 +61,8 @@ public: * @param[in] row The height index * @param[in] col The width index */ - Index(int32_t batch, int32_t ch, int32_t row, int32_t col) : _batch{batch}, _ch{ch}, _row{row}, _col{col} + Index(int32_t batch, int32_t ch, int32_t row, int32_t col) + : _batch{batch}, _ch{ch}, _row{row}, _col{col} { // DO NOTHING } diff --git a/libs/util/include/util/feature/Shape.h b/libs/util/include/util/feature/Shape.h index bb1ed92..3143a44 100644 --- a/libs/util/include/util/feature/Shape.h +++ b/libs/util/include/util/feature/Shape.h @@ -63,7 +63,8 @@ struct Shape * @param[in] height The height value * @param[in] width The width value */ - Shape(int32_t batch, int32_t depth, int32_t height, int32_t width) : N{batch}, C{depth}, H{height}, W{width} + Shape(int32_t batch, int32_t depth, int32_t height, int32_t width) + : N{batch}, C{depth}, H{height}, W{width} { // DO NOTHING } diff --git a/libs/util/include/util/fp32.h b/libs/util/include/util/fp32.h index 7af967b..e6c54c6 100644 --- a/libs/util/include/util/fp32.h +++ b/libs/util/include/util/fp32.h @@ -50,7 +50,8 @@ inline float relative_diff(float lhs, float rhs) } /** - * @brief Verify that an obtained float value is equal to the expected float value by using FLT_EPSILON + * @brief Verify that an obtained float value is equal to the expected float value + * by using FLT_EPSILON * @param[in] expected An expected float value to be compared * @param[in] obtained An obtained float value to be compared * @param[in] tolerance A tolerance value @@ -71,7 +72,8 @@ inline bool epsilon_equal(float expected, float obtained, uint32_t tolerance = 1 } /** - * @brief Verify that an obtained float value is equal to the expected float value by comparing absolute tolerance value + * @brief Verify that an obtained float value is equal to the expected float value + * by comparing absolute tolerance value * @param[in] expected An expected float value to be compared * @param[in] obtained An obtained float value to be compared * @param[in] tolerance A tolerance value diff --git a/libs/util/include/util/kernel/Shape.h b/libs/util/include/util/kernel/Shape.h index 23f7bdf..12b5748 100644 --- a/libs/util/include/util/kernel/Shape.h +++ b/libs/util/include/util/kernel/Shape.h @@ -37,10 +37,10 @@ namespace kernel */ struct Shape { - int32_t N; /**< The kernel index */ - int32_t C; /**< The channel index */ - int32_t H; /**< The height index */ - int32_t W; /**< The width index */ + int32_t N; /**< The kernel index */ + int32_t C; /**< The channel index */ + int32_t H; /**< The height index */ + int32_t W; /**< The width index */ /** * @brief Construct a new Shape object as default diff --git a/libs/util/include/util/profiling/profile_buffer.h b/libs/util/include/util/profiling/profile_buffer.h index 8785a40..8d7d93b 100644 --- a/libs/util/include/util/profiling/profile_buffer.h +++ b/libs/util/include/util/profiling/profile_buffer.h @@ -28,6 +28,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ + +// NOTE To minimize diff with upstream tensorflow, disable clang-format +// clang-format off + +// NOTE This header is derived from the following file (in TensorFlow v1.12) +// 'externals/tensorflow/tensorflow/contrib/lite/profiling/profile_buffer.h #ifndef TENSORFLOW_CONTRIB_LITE_PROFILING_PROFILE_BUFFER_H_ #define TENSORFLOW_CONTRIB_LITE_PROFILING_PROFILE_BUFFER_H_ @@ -160,3 +166,5 @@ class ProfileBuffer { } // namespace tflite #endif // TFLITE_PROFILING_ENABLED #endif // TENSORFLOW_CONTRIB_LITE_PROFILING_PROFILE_BUFFER_H_ + +// clang-format on diff --git a/libs/util/include/util/profiling/profiler.h b/libs/util/include/util/profiling/profiler.h index 0d68b8f..1dbbf31 100644 --- a/libs/util/include/util/profiling/profiler.h +++ b/libs/util/include/util/profiling/profiler.h @@ -28,6 +28,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ + +// NOTE To minimize diff with upstream tensorflow, disable clang-format +// clang-format off + +// NOTE This header is derived from the following file (in TensorFlow v1.12) +// 'externals/tensorflow/tensorflow/contrib/lite/profiling/profiler.h #ifndef TENSORFLOW_CONTRIB_LITE_PROFILING_PROFILER_H_ #define TENSORFLOW_CONTRIB_LITE_PROFILING_PROFILER_H_ @@ -193,3 +199,5 @@ class Profiler { #endif // TFLITE_PROFILING_ENABLED #endif // TENSORFLOW_CONTRIB_LITE_PROFILING_PROFILER_H_ + +// clang-format on diff --git a/libs/util/include/util/profiling/profiling.h b/libs/util/include/util/profiling/profiling.h index 3365dc8..fa4920e 100644 --- a/libs/util/include/util/profiling/profiling.h +++ b/libs/util/include/util/profiling/profiling.h @@ -19,8 +19,10 @@ #include -namespace tflite { -namespace profiling { +namespace tflite +{ +namespace profiling +{ class Profiler; // forward declaration } } @@ -60,12 +62,12 @@ public: public: const Sync &sync(void) const { return _sync; } - tflite::profiling::Profiler* getProfiler() { return _profiler; } - void setProfiler(tflite::profiling::Profiler* p) { _profiler = p; } + tflite::profiling::Profiler *getProfiler() { return _profiler; } + void setProfiler(tflite::profiling::Profiler *p) { _profiler = p; } private: Sync _sync; - tflite::profiling::Profiler* _profiler; + tflite::profiling::Profiler *_profiler; public: static Context &get(void) diff --git a/libs/util/include/util/profiling/time.h b/libs/util/include/util/profiling/time.h index cc2ec31..4b19494 100644 --- a/libs/util/include/util/profiling/time.h +++ b/libs/util/include/util/profiling/time.h @@ -12,6 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ + +// NOTE To minimize diff with upstream tensorflow, disable clang-format +// clang-format off + +// NOTE This header is derived from the following file (in TensorFlow v1.12) +// 'externals/tensorflow/tensorflow/contrib/lite/profiling/time.h #ifndef TENSORFLOW_CONTRIB_LITE_PROFILING_TIME_H_ #define TENSORFLOW_CONTRIB_LITE_PROFILING_TIME_H_ @@ -25,3 +31,5 @@ uint64_t NowMicros(); } // namespace profiling } // namespace tflite #endif // TENSORFLOW_CONTRIB_LITE_PROFILING_TIME_H_ + +// clang-format on diff --git a/libs/util/include/util/tensor/Comparator.h b/libs/util/include/util/tensor/Comparator.h index 721e194..2baebc4 100644 --- a/libs/util/include/util/tensor/Comparator.h +++ b/libs/util/include/util/tensor/Comparator.h @@ -49,7 +49,7 @@ public: * @brief Construct a new @c Comparator object * @param[in] fn Function that compares two float values */ - Comparator(const std::function &fn) : _compare_fn{fn} + Comparator(const std::function &fn) : _compare_fn{fn} { // DO NOTHING } @@ -80,13 +80,12 @@ public: * @return @c std::vector> containing information of failed comparison */ // NOTE Observer should live longer than comparator - std::vector> compare(const Shape &shape, - const Reader &expected, - const Reader &obtained, - Observer *observer = nullptr) const; + std::vector> compare(const Shape &shape, const Reader &expected, + const Reader &obtained, + Observer *observer = nullptr) const; private: - std::function _compare_fn; + std::function _compare_fn; }; } // namespace tensor diff --git a/libs/util/include/util/tensor/Diff.h b/libs/util/include/util/tensor/Diff.h index 5c9fbbc..ac2ed55 100644 --- a/libs/util/include/util/tensor/Diff.h +++ b/libs/util/include/util/tensor/Diff.h @@ -35,7 +35,7 @@ namespace tensor /** * @brief Struct to have information after comparing two elements of two tensors */ -template struct Diff +template struct Diff { Index index; /**< Index of elements in two tensors, which turn out to be different */ diff --git a/libs/util/include/util/tensor/Index.h b/libs/util/include/util/tensor/Index.h index 9b673a3..6873053 100644 --- a/libs/util/include/util/tensor/Index.h +++ b/libs/util/include/util/tensor/Index.h @@ -94,7 +94,7 @@ inline static Index copy_reverse(const Index &origin) size_t rank = origin.rank(); Index target(rank); for (int i = 0; i < rank; i++) - target.at(i) = origin.at(rank-1 -i); + target.at(i) = origin.at(rank - 1 - i); return target; } diff --git a/libs/util/include/util/tensor/IndexEnumerator.h b/libs/util/include/util/tensor/IndexEnumerator.h index 5d90b47..f19fb1a 100644 --- a/libs/util/include/util/tensor/IndexEnumerator.h +++ b/libs/util/include/util/tensor/IndexEnumerator.h @@ -94,12 +94,12 @@ public: const size_t rank = _shape.rank(); // Find axis to be updated - while((_cursor < rank) && !(_index.at(_cursor) + 1 < _shape.dim(_cursor))) + while ((_cursor < rank) && !(_index.at(_cursor) + 1 < _shape.dim(_cursor))) { ++_cursor; } - if(_cursor == rank) + if (_cursor == rank) { return; }