From 1b8da3d12df03338fdb9034978a75dac5da3f071 Mon Sep 17 00:00:00 2001 From: ddavis-2015 Date: Wed, 11 Jun 2025 00:47:53 -0700 Subject: [PATCH] Fix MicroProfiler ClearEvents method @tensorflow/micro Make sure the MicroProfiler ClearEvents method clears the existing tick counts for the total_ticks_per_tag_ member. bug=fixes #3119 --- tensorflow/lite/micro/micro_profiler.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tensorflow/lite/micro/micro_profiler.cc b/tensorflow/lite/micro/micro_profiler.cc index e349bf73668..cace814514a 100644 --- a/tensorflow/lite/micro/micro_profiler.cc +++ b/tensorflow/lite/micro/micro_profiler.cc @@ -1,4 +1,4 @@ -/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. +/* Copyright 2025 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,9 +14,11 @@ limitations under the License. ==============================================================================*/ #include "tensorflow/lite/micro/micro_profiler.h" +#include #include #include #include +#include #include "tensorflow/lite/kernels/internal/compatibility.h" #include "tensorflow/lite/micro/micro_log.h" @@ -122,9 +124,7 @@ int MicroProfiler::FindExistingOrNextPosition(const char* tag_name) { } void MicroProfiler::ClearEvents() { - for (int i = 0; i < num_events_; i++) { - total_ticks_per_tag_[i].tag = nullptr; - } + std::fill_n(std::begin(total_ticks_per_tag_), num_events_, TicksPerTag{}); num_events_ = 0; }