Skip to content

Commit 28aed94

Browse files
Added function definitions required for MicroProfiler
- Implemented ticks_per_second and GetCurrentTimeTicks functions w.r.t ESP-IDF - Note: ticks_per_second and GetCurrentTimeTicks return time in microseconds instead of no. of ticks - The esp-specific `micro_time.cc` file resides in `tensorflow/micro/esp` and required changes were made to `scripts/sync_from_tflite_micro.sh`
1 parent 2312aff commit 28aed94

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ set(srcs_micro
2929
"${tfmicro_dir}/recording_micro_allocator.cc"
3030
"${tfmicro_dir}/system_setup.cc")
3131

32+
list(REMOVE_ITEM srcs_micro
33+
"${tfmicro_dir}/micro_time.cc")
34+
list(APPEND srcs_micro
35+
"${tfmicro_dir}/esp/micro_time.cc")
36+
3237
file(GLOB src_micro_frontend
3338
"${tfmicro_frontend_dir}/*.c"
3439
"${tfmicro_frontend_dir}/*.cc")
@@ -109,9 +114,6 @@ idf_component_register(
109114
"third_party/flatbuffers/include"
110115
"third_party/ruy"
111116
"third_party/kissfft"
112-
"signal/micro/kernels"
113-
"signal/src"
114-
"signal/src/kiss_fft_wrappers"
115117
REQUIRES ${pub_req}
116118
PRIV_REQUIRES ${priv_req})
117119

scripts/sync_from_tflite_micro.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ python3 tensorflow/lite/micro/tools/project_generation/create_tflm_tree.py \
4040
/bin/cp -r "${TFLITE_LIB_DIR}"/tensorflow/lite/micro/kernels/esp_nn \
4141
"${TEMP_DIR}"/tflm-out/tensorflow/lite/micro/kernels/
4242

43+
# Backup `micro/esp` directory to new tree
44+
/bin/cp -r "${TFLITE_LIB_DIR}"/tensorflow/lite/micro/esp \
45+
"${TEMP_DIR}"/tflm-out/tensorflow/lite/micro/
46+
4347
cd "${TFLITE_LIB_DIR}"
4448
rm -rf tensorflow
4549
rm -rf third_party
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
==============================================================================*/
15+
16+
#include <esp_timer.h>
17+
#include "tensorflow/lite/micro/micro_time.h"
18+
19+
namespace tflite {
20+
21+
uint32_t ticks_per_second() { return 1000000; }
22+
23+
uint32_t GetCurrentTimeTicks() { return esp_timer_get_time(); }
24+
25+
} // namespace tflite

0 commit comments

Comments
 (0)