diff --git a/tensorflow/lite/kernels/detection_postprocess.cc b/tensorflow/lite/kernels/detection_postprocess.cc index a0df4a10fa1bb2..09ed7945ec574b 100644 --- a/tensorflow/lite/kernels/detection_postprocess.cc +++ b/tensorflow/lite/kernels/detection_postprocess.cc @@ -130,7 +130,7 @@ TfLiteStatus SetTensorSizes(TfLiteContext* context, TfLiteTensor* tensor, std::initializer_list values) { TfLiteIntArray* size = TfLiteIntArrayCreate(values.size()); int index = 0; - for (int v : values) { + for (const auto& v : values) { size->data[index] = v; ++index; } @@ -503,7 +503,7 @@ TfLiteStatus NonMaxSuppressionMultiClassRegularHelper(TfLiteContext* context, num_detections_per_class)); // Add selected indices from non-max suppression of boxes in this class int output_index = size_of_sorted_indices; - for (int selected_index : selected) { + for (const auto& selected_index : selected) { box_indices_after_regular_non_max_suppression[output_index] = (selected_index * num_classes_with_background + col + label_offset); scores_after_regular_non_max_suppression[output_index] = diff --git a/tensorflow/lite/kernels/kernel_util_test.cc b/tensorflow/lite/kernels/kernel_util_test.cc index 4e792542a19eaf..2f581feb1ba4fd 100644 --- a/tensorflow/lite/kernels/kernel_util_test.cc +++ b/tensorflow/lite/kernels/kernel_util_test.cc @@ -44,7 +44,7 @@ class KernelUtilTest : public ::testing::Test { TfLiteTensorFree(tensor); tensor->dims = TfLiteIntArrayCreate(dims.size()); int i = 0; - for (int d : dims) { + for (const auto& d : dims) { tensor->dims->data[i] = d; ++i; } diff --git a/tensorflow/lite/kernels/test_util.h b/tensorflow/lite/kernels/test_util.h index 08c027f9d9d4fb..a4207a5e8179de 100644 --- a/tensorflow/lite/kernels/test_util.h +++ b/tensorflow/lite/kernels/test_util.h @@ -46,7 +46,7 @@ template inline std::vector Quantize(const std::vector& data, float scale, int32_t zero_point) { std::vector q; - for (float f : data) { + for (const auto& f : data) { q.push_back(static_cast(std::max( std::numeric_limits::min(), std::min(std::numeric_limits::max(), @@ -59,7 +59,7 @@ template inline std::vector Dequantize(const std::vector& data, float scale, int32_t zero_point) { std::vector f; - for (T q : data) { + for (const T& q : data) { f.push_back(scale * (q - zero_point)); } return f; @@ -276,7 +276,7 @@ class SingleOpModel { << ". Requested " << typeToTfLiteType() << ", got " << t->type; } - for (T f : data) { + for (const T& f : data) { *v = f; ++v; } @@ -296,7 +296,7 @@ class SingleOpModel { << ". Requested " << typeToTfLiteType() << ", got " << t->type; } - for (T f : data) { + for (const T& f : data) { *v = f; ++v; } @@ -496,7 +496,7 @@ class SingleOpTest : public ::testing::TestWithParam { static std::vector GetKernelTags( const std::map& kernel_map) { std::vector tags; - for (auto it : kernel_map) { + for (const auto& it : kernel_map) { tags.push_back(it.first); } return tags; diff --git a/tensorflow/lite/toco/tflite/export_test.cc b/tensorflow/lite/toco/tflite/export_test.cc index fb640f776abdef..7d5b59ee661bbf 100644 --- a/tensorflow/lite/toco/tflite/export_test.cc +++ b/tensorflow/lite/toco/tflite/export_test.cc @@ -251,7 +251,7 @@ class OpSetsTest : public ExportTest { params_.enable_select_tf_ops = false; params_.quantize_weights = false; - for (OpSet i : sets) { + for (const OpSet& i : sets) { switch (i) { case kTfLiteBuiltins: import_all_ops_as_unsupported_ = false;