From: Jaeyun Date: Thu, 29 Apr 2021 03:13:26 +0000 (+0900) Subject: [Format] fix format and code style X-Git-Tag: accepted/tizen/unified/20210510.155212~28 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=880c41c405a6f5a9fd6125339a79c61b623fce1f;p=platform%2Fupstream%2Fnnstreamer.git [Format] fix format and code style fix clang format error in taos-ci and code style. Signed-off-by: Jaeyun --- diff --git a/.clang-format b/.clang-format index 004b8d0..1661a98 100644 --- a/.clang-format +++ b/.clang-format @@ -30,7 +30,8 @@ IncludeCategories: Priority: 10 - Regex: '<.*>' Priority: 0 -IndentCaseLabels: false +IndentCaseLabels: true +IndentCaseBlocks: true IndentFunctionDeclarationAfterType: true IndentWidth: 2 IndentWrappedFunctionNames: false diff --git a/ext/nnstreamer/tensor_decoder/tensordec-flatbuf.cc b/ext/nnstreamer/tensor_decoder/tensordec-flatbuf.cc index 49c98d0..435c962 100644 --- a/ext/nnstreamer/tensor_decoder/tensordec-flatbuf.cc +++ b/ext/nnstreamer/tensor_decoder/tensordec-flatbuf.cc @@ -18,7 +18,7 @@ #include #include #include -#include // Generated by `flatc`. +#include /* Generated by `flatc`. */ #include #include #include @@ -33,8 +33,8 @@ namespace flatbuf #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -void init_fbd (void) __attribute__((constructor)); -void fini_fbd (void) __attribute__((destructor)); +void init_fbd (void) __attribute__ ((constructor)); +void fini_fbd (void) __attribute__ ((destructor)); #ifdef __cplusplus } #endif /* __cplusplus */ @@ -154,7 +154,7 @@ fbd_decode (void **pdata, const GstTensorsConfig *config, static gchar decoder_subplugin_flatbuf[] = "flatbuf"; /** @brief flatbuffer tensordec-plugin GstTensorDecoderDef instance */ -static GstTensorDecoderDef flatBuf = {.modename = decoder_subplugin_flatbuf, +static GstTensorDecoderDef flatBuf = { .modename = decoder_subplugin_flatbuf, .init = fbd_init, .exit = fbd_exit, .setOption = fbd_setOption, diff --git a/ext/nnstreamer/tensor_decoder/tensordec-flexbuf.cc b/ext/nnstreamer/tensor_decoder/tensordec-flexbuf.cc index 2b4795b..f1f98ca 100644 --- a/ext/nnstreamer/tensor_decoder/tensordec-flexbuf.cc +++ b/ext/nnstreamer/tensor_decoder/tensordec-flexbuf.cc @@ -39,8 +39,8 @@ * This is an example of a callback type custom mode. * @code * // Define custom callback function - * int * tensor_decoder_custom_cb (const GstTensorMemory *input, - * const GstTensorsConfig *config, void * data, GstBuffer * out_buf) { + * int tensor_decoder_custom_cb (const GstTensorMemory *input, + * const GstTensorsConfig *config, void *data, GstBuffer *out_buf) { * // Write a code to convert tensors to flexbuffers. * } * @@ -56,19 +56,18 @@ * @endcode */ - +#include #include #include #include #include #include "tensordecutil.h" -#include #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -void init_flxd (void) __attribute__((constructor)); -void fini_flxd (void) __attribute__((destructor)); +void init_flxd (void) __attribute__ ((constructor)); +void fini_flxd (void) __attribute__ ((destructor)); #ifdef __cplusplus } #endif /* __cplusplus */ @@ -128,8 +127,8 @@ flxd_decode (void **pdata, const GstTensorsConfig *config, fbb.Int ("rate_n", config->rate_n); fbb.Int ("rate_d", config->rate_d); for (i = 0; i < num_tensors; i++) { - gchar * tensor_key = g_strdup_printf ("tensor_%d", i); - gchar * tensor_name = NULL; + gchar *tensor_key = g_strdup_printf ("tensor_%d", i); + gchar *tensor_name = NULL; if (config->info.info[i].name == NULL) { tensor_name = g_strdup (""); @@ -142,7 +141,7 @@ flxd_decode (void **pdata, const GstTensorsConfig *config, fbb += tensor_name; fbb += type; fbb.Vector (config->info.info[i].dimension, NNS_TENSOR_RANK_LIMIT); - fbb.Blob (input[i].data, (size_t) input[i].size); + fbb.Blob (input[i].data, input[i].size); }); g_free (tensor_key); g_free (tensor_name); @@ -182,7 +181,7 @@ flxd_decode (void **pdata, const GstTensorsConfig *config, static gchar decoder_subplugin_flexbuf[] = "flexbuf"; /** @brief flexbuffer tensordec-plugin GstTensorDecoderDef instance */ -static GstTensorDecoderDef flexBuf = {.modename = decoder_subplugin_flexbuf, +static GstTensorDecoderDef flexBuf = { .modename = decoder_subplugin_flexbuf, .init = flxd_init, .exit = flxd_exit, .setOption = flxd_setOption, diff --git a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite.cc b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite.cc index 7f1d0bf..cb22ac9 100644 --- a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite.cc +++ b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite.cc @@ -54,7 +54,7 @@ #include #endif -#if !defined (TFLITE_SUBPLUGIN_NAME) +#if !defined(TFLITE_SUBPLUGIN_NAME) #warning "The sub-plugin name for tensorflow-lite is not defined." #define TFLITE_SUBPLUGIN_NAME "tensorflow-lite" #endif @@ -177,17 +177,14 @@ class TFLiteInterpreter int getTensorDim (int tensor_idx, tensor_dim dim); int setTensorProp (const std::vector &tensor_idx_list, GstTensorsInfo *tensorMeta); - TfLiteDelegate *delegate_ - = nullptr; /**< The delegate for tflite interpreter */ + TfLiteDelegate *delegate_ = nullptr; /**< The delegate for tflite interpreter */ #ifdef TFLITE_NNAPI_DELEGATE_SUPPORTED - std::unique_ptr - stateful_nnapi_delegate; /**< The pointer of NNAPI delegate */ + std::unique_ptr stateful_nnapi_delegate; /**< The pointer of NNAPI delegate */ #endif #ifdef TFLITE_GPU_DELEGATE_SUPPORTED - std::unique_ptr gpu_delegate; /**< The pointer of GPU delegate - */ + std::unique_ptr gpu_delegate; /**< The pointer of GPU delegate */ #endif }; @@ -221,9 +218,9 @@ class TFLiteCore void setAccelerator (const char *accelerators, tflite_delegate_e d); }; -extern "C" { /* accessed by android api */ -void init_filter_tflite (void) __attribute__((constructor)); -void fini_filter_tflite (void) __attribute__((destructor)); +extern "C" { +void init_filter_tflite (void) __attribute__ ((constructor)); +void fini_filter_tflite (void) __attribute__ ((destructor)); } /** @@ -287,8 +284,10 @@ TFLiteInterpreter::invoke (const GstTensorMemory *input, GstTensorMemory *output tflite_internal_stats.total_invoke_num += 1; #if (DBG) - g_message ("Invoke() is finished: %" G_GINT64_FORMAT "ms, model path: %s", (stop_time - start_time) / 1000, getModelPath()); - g_message ("%" G_GINT64_FORMAT " invoke average %" G_GINT64_FORMAT ", total overhead %" G_GINT64_FORMAT, + ml_logi ("Invoke() is finished: %" G_GINT64_FORMAT "ms, model path: %s", + (stop_time - start_time) / 1000, getModelPath ()); + ml_logi ("%" G_GINT64_FORMAT " invoke average %" G_GINT64_FORMAT + ", total overhead %" G_GINT64_FORMAT, tflite_internal_stats.total_invoke_num, (tflite_internal_stats.total_invoke_latency / tflite_internal_stats.total_invoke_num), tflite_internal_stats.total_overhead_latency); @@ -318,7 +317,8 @@ int TFLiteInterpreter::loadModel (int num_threads, tflite_delegate_e delegate) { #if (DBG) - gint64 start_time = g_get_monotonic_time (); + gint64 start_time, stop_time; + start_time = g_get_monotonic_time (); #endif model = tflite::FlatBufferModel::BuildFromFile (model_path); @@ -326,8 +326,11 @@ TFLiteInterpreter::loadModel (int num_threads, tflite_delegate_e delegate) ml_loge ("Failed to mmap model\n"); return -1; } - /**If got any trouble at model, active below code. It'll be help to analyze. - * model->error_reporter (); */ + + /** + * If got any trouble at model, active below code. It'll be help to analyze. + * model->error_reporter (); + */ interpreter = nullptr; @@ -401,8 +404,8 @@ TFLiteInterpreter::loadModel (int num_threads, tflite_delegate_e delegate) } #if (DBG) - gint64 stop_time = g_get_monotonic_time (); - g_message ("Model is loaded: %" G_GINT64_FORMAT, (stop_time - start_time)); + stop_time = g_get_monotonic_time (); + ml_logi ("Model is loaded: %" G_GINT64_FORMAT, (stop_time - start_time)); #endif return 0; } @@ -499,7 +502,7 @@ TFLiteInterpreter::setTensorProp ( #if (DBG) gchar *dim_str = gst_tensor_get_dimension_string (tensorMeta->info[i].dimension); - g_message ("tensorMeta[%d] >> name[%s], type[%d], dim[%s]", i, + ml_logi ("tensorMeta[%d] >> name[%s], type[%d], dim[%s]", i, tensorMeta->info[i].name, tensorMeta->info[i].type, dim_str); g_free (dim_str); #endif @@ -1249,25 +1252,25 @@ tflite_checkAvailability (accl_hw hw) static gchar filter_subplugin_tensorflow_lite[] = TFLITE_SUBPLUGIN_NAME; static GstTensorFilterFramework NNS_support_tensorflow_lite - = {.version = GST_TENSOR_FILTER_FRAMEWORK_V0, + = { .version = GST_TENSOR_FILTER_FRAMEWORK_V0, .open = tflite_open, .close = tflite_close, - {.v0 = { - .name = filter_subplugin_tensorflow_lite, - .allow_in_place = FALSE, /** @todo: support this to optimize performance later. */ - .allocate_in_invoke = FALSE, - .run_without_model = FALSE, - .verify_model_path = TRUE, - .statistics = &tflite_internal_stats, - .invoke_NN = tflite_invoke, - .getInputDimension = tflite_getInputDim, - .getOutputDimension = tflite_getOutputDim, - .setInputDimension = tflite_setInputDim, - .destroyNotify = nullptr, - .reloadModel = tflite_reloadModel, - .checkAvailability = tflite_checkAvailability, - .allocateInInvoke = nullptr, - } } }; + { .v0 = { + .name = filter_subplugin_tensorflow_lite, + .allow_in_place = FALSE, /** @todo: support this to optimize performance later. */ + .allocate_in_invoke = FALSE, + .run_without_model = FALSE, + .verify_model_path = TRUE, + .statistics = &tflite_internal_stats, + .invoke_NN = tflite_invoke, + .getInputDimension = tflite_getInputDim, + .getOutputDimension = tflite_getOutputDim, + .setInputDimension = tflite_setInputDim, + .destroyNotify = nullptr, + .reloadModel = tflite_reloadModel, + .checkAvailability = tflite_checkAvailability, + .allocateInInvoke = nullptr, + } } }; /** @brief Initialize this object for tensor_filter subplugin runtime register */ void diff --git a/gst/nnstreamer/nnstreamer_conf.c b/gst/nnstreamer/nnstreamer_conf.c index 0eba5be..fb9999d 100644 --- a/gst/nnstreamer/nnstreamer_conf.c +++ b/gst/nnstreamer/nnstreamer_conf.c @@ -1,4 +1,5 @@ -/** * NNStreamer Configurations / Environmental Variable Manager. +/** + * NNStreamer Configurations / Environmental Variable Manager. * Copyright (C) 2018 MyungJoo Ham * * This library is free software; you can redistribute it and/or diff --git a/gst/nnstreamer/nnstreamer_internal.h b/gst/nnstreamer/nnstreamer_internal.h index a0edfb2..ec34acc 100644 --- a/gst/nnstreamer/nnstreamer_internal.h +++ b/gst/nnstreamer/nnstreamer_internal.h @@ -1,5 +1,5 @@ +/* SPDX-License-Identifier: LGPL-2.1-only */ /** - * SPDX-License-Identifier: LGPL-2.1-only * Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved. * * @file nnstreamer_internal.h diff --git a/tests/common/unittest_common.cc b/tests/common/unittest_common.cc index b7ebfc5..e5d373a 100644 --- a/tests/common/unittest_common.cc +++ b/tests/common/unittest_common.cc @@ -650,7 +650,7 @@ TEST (commonTensorInfo, getrankInvalidParam0_n) */ TEST (commonTensorsInfo, parsingDimInvalidParam0_n) { - const gchar * dim_str = "1:2:3:4"; + const gchar *dim_str = "1:2:3:4"; EXPECT_EQ (0U, gst_tensors_info_parse_dimensions_string (NULL, dim_str)); } @@ -668,7 +668,7 @@ TEST (commonTensorsInfo, parsingDimInvalidParam1_n) */ TEST (commonTensorsInfo, parsingTypeInvalidParam0_n) { - const gchar * dim_str = "uint8"; + const gchar *dim_str = "uint8"; EXPECT_EQ (0U, gst_tensors_info_parse_types_string (NULL, dim_str)); } @@ -686,7 +686,7 @@ TEST (commonTensorsInfo, parsingTypeInvalidParam1_n) */ TEST (commonTensorsInfo, parsingNameInvalidParam0_n) { - const gchar * dim_str = "tname"; + const gchar *dim_str = "tname"; EXPECT_EQ (0U, gst_tensors_info_parse_names_string (NULL, dim_str)); } @@ -1388,8 +1388,7 @@ TEST (commonPadCap, tensor0) gboolean is_tensor; /* Create a nnstreamer pipeline */ - pipeline = g_strdup_printf ( - "fakesrc name=fsrc ! fakesink name=fsink"); + pipeline = g_strdup_printf ("fakesrc name=fsrc ! fakesink name=fsink"); gstpipe = gst_parse_launch (pipeline, NULL); EXPECT_NE (pipeline, nullptr); diff --git a/tests/nnstreamer_decoder/unittest_decoder.cc b/tests/nnstreamer_decoder/unittest_decoder.cc index 8af0f11..50e5dc7 100644 --- a/tests/nnstreamer_decoder/unittest_decoder.cc +++ b/tests/nnstreamer_decoder/unittest_decoder.cc @@ -8,13 +8,13 @@ */ #include +#include #include #include +#include #include #include #include -#include -#include #define TEST_TIMEOUT_MS (1000U) @@ -23,7 +23,8 @@ static int data_received; /** * @brief custom callback function */ -int tensor_decoder_custom_cb (const GstTensorMemory *input, +static int +tensor_decoder_custom_cb (const GstTensorMemory *input, const GstTensorsConfig *config, void * data, GstBuffer *out_buf) { GstMapInfo out_info; @@ -39,8 +40,8 @@ int tensor_decoder_custom_cb (const GstTensorMemory *input, fbb.Int ("rate_n", config->rate_n); fbb.Int ("rate_d", config->rate_d); for (i = 0; i < num_tensors; i++) { - gchar * tensor_key = g_strdup_printf ("tensor_%d", i); - gchar * tensor_name = NULL; + gchar *tensor_key = g_strdup_printf ("tensor_%d", i); + gchar *tensor_name = NULL; if (config->info.info[i].name == NULL) { tensor_name = g_strdup (""); @@ -49,11 +50,11 @@ int tensor_decoder_custom_cb (const GstTensorMemory *input, } tensor_type type = config->info.info[i].type; - fbb.Vector (tensor_key, [&] () { + fbb.Vector (tensor_key, [&]() { fbb += tensor_name; fbb += type; fbb.Vector (config->info.info[i].dimension, NNS_TENSOR_RANK_LIMIT); - fbb.Blob (input[i].data, (size_t) input[i].size); + fbb.Blob (input[i].data, input[i].size); }); g_free (tensor_key); g_free (tensor_name); @@ -192,8 +193,8 @@ decsub_getOutCaps (void **pdata, const GstTensorsConfig *config) /** @brief tensordec-plugin's decode callback */ static GstFlowReturn -decsub_decode (void **pdata, const GstTensorsConfig * config, - const GstTensorMemory * input, GstBuffer * outbuf) +decsub_decode (void **pdata, const GstTensorsConfig *config, + const GstTensorMemory *input, GstBuffer *outbuf) { return GST_FLOW_OK; } @@ -207,7 +208,7 @@ get_default_decoder (const gchar *name) GstTensorDecoderDef *sub = g_try_new0 (GstTensorDecoderDef, 1); g_assert (sub); - sub->modename = (char *) g_strdup (name); + sub->modename = g_strdup (name); sub->init = decsub_init; sub->getOutCaps = decsub_getOutCaps; sub->decode = decsub_decode; @@ -221,7 +222,7 @@ get_default_decoder (const gchar *name) static void free_default_decoder (GstTensorDecoderDef *sub) { - g_free ((char *)sub->modename); + g_free (sub->modename); g_free (sub); }