From e528e5ab82fafe1cf8f5d69f9b18426af1b51d09 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 14 May 2018 13:22:09 -0700 Subject: [PATCH] Various ClangTidy-inspired fixes. PiperOrigin-RevId: 196556727 --- .../lite/examples/label_image/label_image.cc | 50 +++++++++++----------- .../contrib/lite/kernels/kernel_util_test.cc | 2 +- tensorflow/contrib/lite/toco/tooling_util.cc | 2 +- tensorflow/contrib/lite/tools/verifier_test.cc | 1 - 4 files changed, 26 insertions(+), 29 deletions(-) diff --git a/tensorflow/contrib/lite/examples/label_image/label_image.cc b/tensorflow/contrib/lite/examples/label_image/label_image.cc index 456c5c6..966fcd2 100644 --- a/tensorflow/contrib/lite/examples/label_image/label_image.cc +++ b/tensorflow/contrib/lite/examples/label_image/label_image.cc @@ -77,14 +77,13 @@ void PrintProfilingInfo(const profiling::ProfileEvent* e, uint32_t op_index, // time (ms) , Node xxx, OpCode xxx, symblic name // 5.352, Node 5, OpCode 4, DEPTHWISE_CONV_2D - LOG(INFO) << std::fixed << std::setw(10) << std::setprecision(3) << (e->end_timestamp_us - e->begin_timestamp_us) / 1000.0 << ", Node " << std::setw(3) << std::setprecision(3) << op_index << ", OpCode " << std::setw(3) << std::setprecision(3) << registration.builtin_code << ", " << EnumNameBuiltinOperator( - (BuiltinOperator)registration.builtin_code) + static_cast(registration.builtin_code)) << "\n"; } @@ -190,13 +189,13 @@ void RunInference(Settings* s) { if (s->profiling) profiler->StartProfiling(); struct timeval start_time, stop_time; - gettimeofday(&start_time, NULL); + gettimeofday(&start_time, nullptr); for (int i = 0; i < s->loop_count; i++) { if (interpreter->Invoke() != kTfLiteOk) { LOG(FATAL) << "Failed to invoke tflite!\n"; } } - gettimeofday(&stop_time, NULL); + gettimeofday(&stop_time, nullptr); LOG(INFO) << "invoked \n"; LOG(INFO) << "average time: " << (get_us(stop_time) - get_us(start_time)) / (s->loop_count * 1000) @@ -271,17 +270,17 @@ int Main(int argc, char** argv) { int c; while (1) { static struct option long_options[] = { - {"accelerated", required_argument, 0, 'a'}, - {"count", required_argument, 0, 'c'}, - {"verbose", required_argument, 0, 'v'}, - {"image", required_argument, 0, 'i'}, - {"labels", required_argument, 0, 'l'}, - {"tflite_model", required_argument, 0, 'm'}, - {"profiling", required_argument, 0, 'p'}, - {"threads", required_argument, 0, 't'}, - {"input_mean", required_argument, 0, 'b'}, - {"input_std", required_argument, 0, 's'}, - {0, 0, 0, 0}}; + {"accelerated", required_argument, nullptr, 'a'}, + {"count", required_argument, nullptr, 'c'}, + {"verbose", required_argument, nullptr, 'v'}, + {"image", required_argument, nullptr, 'i'}, + {"labels", required_argument, nullptr, 'l'}, + {"tflite_model", required_argument, nullptr, 'm'}, + {"profiling", required_argument, nullptr, 'p'}, + {"threads", required_argument, nullptr, 't'}, + {"input_mean", required_argument, nullptr, 'b'}, + {"input_std", required_argument, nullptr, 's'}, + {nullptr, 0, nullptr, 0}}; /* getopt_long stores the option index here. */ int option_index = 0; @@ -294,15 +293,14 @@ int Main(int argc, char** argv) { switch (c) { case 'a': - s.accel = strtol( // NOLINT(runtime/deprecated_fn) - optarg, (char**)NULL, 10); + s.accel = strtol(optarg, nullptr, 10); // NOLINT(runtime/deprecated_fn) break; case 'b': - s.input_mean = strtod(optarg, NULL); + s.input_mean = strtod(optarg, nullptr); break; case 'c': - s.loop_count = strtol( // NOLINT(runtime/deprecated_fn) - optarg, (char**)NULL, 10); + s.loop_count = + strtol(optarg, nullptr, 10); // NOLINT(runtime/deprecated_fn) break; case 'i': s.input_bmp_name = optarg; @@ -314,19 +312,19 @@ int Main(int argc, char** argv) { s.model_name = optarg; break; case 'p': - s.profiling = strtol( // NOLINT(runtime/deprecated_fn) - optarg, (char**)NULL, 10); + s.profiling = + strtol(optarg, nullptr, 10); // NOLINT(runtime/deprecated_fn) break; case 's': - s.input_std = strtod(optarg, NULL); + s.input_std = strtod(optarg, nullptr); break; case 't': s.number_of_threads = strtol( // NOLINT(runtime/deprecated_fn) - optarg, (char**)NULL, 10); + optarg, nullptr, 10); break; case 'v': - s.verbose = strtol( // NOLINT(runtime/deprecated_fn) - optarg, (char**)NULL, 10); + s.verbose = + strtol(optarg, nullptr, 10); // NOLINT(runtime/deprecated_fn) break; case 'h': case '?': diff --git a/tensorflow/contrib/lite/kernels/kernel_util_test.cc b/tensorflow/contrib/lite/kernels/kernel_util_test.cc index c65b689..bf6f249 100644 --- a/tensorflow/contrib/lite/kernels/kernel_util_test.cc +++ b/tensorflow/contrib/lite/kernels/kernel_util_test.cc @@ -33,7 +33,7 @@ class KernelUtilTest : public ::testing::Test { tensor1_.allocation_type = kTfLiteMmapRo; tensor2_.allocation_type = kTfLiteMmapRo; } - ~KernelUtilTest() { + ~KernelUtilTest() override { TfLiteTensorFree(&tensor1_); TfLiteTensorFree(&tensor2_); } diff --git a/tensorflow/contrib/lite/toco/tooling_util.cc b/tensorflow/contrib/lite/toco/tooling_util.cc index a789b5c..1e6314f 100644 --- a/tensorflow/contrib/lite/toco/tooling_util.cc +++ b/tensorflow/contrib/lite/toco/tooling_util.cc @@ -987,7 +987,7 @@ void FixOperatorOrdering(Model* model) { for (auto i : remaining) { bool can_insert = true; auto& op = old_operators[i]; - CHECK(op.get()); + CHECK(op); for (const auto& input : op->inputs) { if (!IsConstantParameterArray(*model, input) && !arrays_behind_us.count(input)) { diff --git a/tensorflow/contrib/lite/tools/verifier_test.cc b/tensorflow/contrib/lite/tools/verifier_test.cc index 03b93af..8a10e68 100644 --- a/tensorflow/contrib/lite/tools/verifier_test.cc +++ b/tensorflow/contrib/lite/tools/verifier_test.cc @@ -31,7 +31,6 @@ namespace tflite { using flatbuffers::FlatBufferBuilder; using flatbuffers::Offset; -using flatbuffers::Vector; // Build single subgraph model. class TfLiteFlatbufferModelBuilder { -- 2.7.4