-
Notifications
You must be signed in to change notification settings - Fork 125
Description
Checklist
- Checked the issue tracker for similar issues to ensure this is not a duplicate.
- Described the feature in detail and justified the reason for the request.
- Provided specific use cases and examples.
Feature description
Tflite micro features a profiling tool for measuring the execution time of each layer in a model.
Usage example:
#include "tensorflow/lite/micro/micro_profiler.h"
void function()
{
// other setup stuff ....
tflite::MicroProfiler profiler;
tflite::MicroInterpreter interpreter(
model, micro_op_resolver, tensor_arena, kTensorArenaSize,
nullptr, &profiler);
// infer model
interpreter.Invoke()
// print profiling information
profiler.Log();
}
This works, but requires an implementation of the timing functions GetCurrentTimeTicks
and ticks_per_second
(see tensorflow/lite/micro/micro_time.cc). This is obviously target dependent, but since this is a tflite library port for ESP devices, this repo could provide an implementation that works across all ESP devices.
An example implementation of micro_time.cc
could be:
#include "esp_timer.h"
uint32_t ticks_per_second() { return 1000000; }
uint32_t GetCurrentTimeTicks() { return esp_timer_get_time(); }
and then add esp_timer
as a private requirement in the CMakeLists.txt.
This would be very convenient, because this way it would work out of the box when this components is used in the component manager.
Use cases
This is very convenient for finding model bottlenecks for further optimization. I have not found a more convenient alternative for this.
Alternatives
Alternatively, a mechanism could be provided to the user to implement GetCurrentTimeTicks
and ticks_per_second
in the user program, by for example providing a weakly linked implementation in the library or using preprocessor macros to disable the default implementation in menuconfig. Providing a useful default implementation together with this functionality would be even better.
Overriding these functions in the user program is currently not possible without modifying the library code.
Additional context
No response