Fix benchmark tool alternate profiler (#3629)

@tensorflow/micro

Set the alternate profiler in the benchmark tool prior to the `Prepare` phase (before calling `MicroInterpreter::AllocateTensors`).  This is because the DECODE operator requires the alternate `MicroProfilerInterface` to already be initialized during the `Prepare` phase.

Previously the alternate profiler was only required during the `Eval` phase with the legacy compression code.  This fix does not change the functionality of the benchmark tool with respect to the legacy compression.

bug=#3628
This commit is contained in:
David Davis 2026-07-13 11:10:56 -07:00 committed by GitHub
parent 35b20c5c74
commit 0965635467
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -259,6 +259,15 @@ int Benchmark(const uint8_t* model_data, tflite::PrettyPrintType print_type) {
profiler.EndEvent(event_handle);
#endif // USE_ALT_DECOMPRESSION_MEM
if (using_compression) {
MicroPrintf("profiler2 %p", &profiler2);
status = interpreter.SetAlternateProfiler(&profiler2);
if (status != kTfLiteOk) {
MicroPrintf("tflite::MicroInterpreter::SetAlternateProfiler failed");
return -1;
}
}
event_handle =
profiler.BeginEvent("tflite::MicroInterpreter::AllocateTensors");
status = interpreter.AllocateTensors();
@ -271,14 +280,6 @@ int Benchmark(const uint8_t* model_data, tflite::PrettyPrintType print_type) {
profiler.LogTicksPerTagCsv();
profiler.ClearEvents();
if (using_compression) {
status = interpreter.SetAlternateProfiler(&profiler2);
if (status != kTfLiteOk) {
MicroPrintf("tflite::MicroInterpreter::SetAlternateProfiler failed");
return -1;
}
}
MicroPrintf(""); // null MicroPrintf serves as a newline.
// For streaming models, the interpreter will return kTfLiteAbort if the