enable use of <ctime> for profiling via -DTF_LITE_USE_CTIME
This commit is contained in:
parent
ac56fe8f94
commit
ab21c0fbb8
tensorflow/lite/micro
@ -158,12 +158,12 @@ cc_library(
|
||||
cc_library(
|
||||
name = "micro_time",
|
||||
srcs = [
|
||||
"posix/micro_time.cc",
|
||||
"micro_time.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"micro_time.h",
|
||||
],
|
||||
copts = micro_copts(),
|
||||
copts = micro_copts() + ["-DTF_LITE_USE_CTIME"],
|
||||
deps = ["//tensorflow/lite/c:common"],
|
||||
)
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
/* Copyright 2020 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.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
// Hexagon timer implementation.
|
||||
// To include this with make, add TARGET=hexagon.
|
||||
#include "tensorflow/lite/micro/micro_time.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
namespace tflite {
|
||||
|
||||
int32_t ticks_per_second() { return CLOCKS_PER_SEC; }
|
||||
|
||||
int32_t GetCurrentTimeTicks() { return clock(); }
|
||||
|
||||
} // namespace tflite
|
@ -27,8 +27,14 @@ limitations under the License.
|
||||
|
||||
#include "tensorflow/lite/micro/micro_time.h"
|
||||
|
||||
#if defined(TF_LITE_USE_CTIME)
|
||||
#include <ctime>
|
||||
#endif
|
||||
|
||||
namespace tflite {
|
||||
|
||||
#if !defined(TF_LITE_USE_CTIME)
|
||||
|
||||
// Reference implementation of the ticks_per_second() function that's required
|
||||
// for a platform to support Tensorflow Lite for Microcontrollers profiling.
|
||||
// This returns 0 by default because timing is an optional feature that builds
|
||||
@ -41,4 +47,13 @@ int32_t ticks_per_second() { return 0; }
|
||||
// that builds without errors on platforms that do not need it.
|
||||
int32_t GetCurrentTimeTicks() { return 0; }
|
||||
|
||||
#else // defined(TF_LITE_USE_CTIME)
|
||||
|
||||
// For platforms that support ctime, we implment the micro_time interface in
|
||||
// this central location.
|
||||
int32_t ticks_per_second() { return CLOCKS_PER_SEC; }
|
||||
|
||||
int32_t GetCurrentTimeTicks() { return clock(); }
|
||||
#endif
|
||||
|
||||
} // namespace tflite
|
||||
|
@ -1,28 +0,0 @@
|
||||
/* Copyright 2019 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.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
// Posix implementation of micro_timer.
|
||||
// To include this with make, add TAGS=posix.
|
||||
#include "tensorflow/lite/micro/micro_time.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
namespace tflite {
|
||||
|
||||
int32_t ticks_per_second() { return CLOCKS_PER_SEC; }
|
||||
|
||||
int32_t GetCurrentTimeTicks() { return clock(); }
|
||||
|
||||
} // namespace tflite
|
@ -137,6 +137,12 @@ COMMON_FLAGS := \
|
||||
$(OPTIMIZED_KERNEL_DEFINES) \
|
||||
$(TAG_DEFINES)
|
||||
|
||||
ifeq ($(TARGET), $(HOST_OS))
|
||||
# If we are not doing a cross-compilation then -DTF_LITE_USE_CTIME is what we
|
||||
# want to have by default.
|
||||
COMMON_FLAGS += -DTF_LITE_USE_CTIME
|
||||
endif
|
||||
|
||||
CXXFLAGS := \
|
||||
-std=c++11 \
|
||||
-fno-rtti \
|
||||
|
@ -39,6 +39,7 @@ ifeq ($(TARGET), hexagon)
|
||||
|
||||
PLATFORM_ARGS = \
|
||||
-DTF_LITE_MCU_DEBUG_LOG \
|
||||
-DTF_LITE_USE_CTIME \
|
||||
-DHEXAGON_ASM \
|
||||
-DMALLOC_IN_STDLIB \
|
||||
-DPTHREAD_STUBS \
|
||||
|
@ -24,6 +24,7 @@ endif
|
||||
|
||||
PLATFORM_FLAGS = \
|
||||
-DTF_LITE_MCU_DEBUG_LOG \
|
||||
-DTF_LITE_USE_CTIME \
|
||||
--xtensa-core=$(XTENSA_CORE) \
|
||||
-mcoproc \
|
||||
-DXTENSA \
|
||||
|
@ -1,28 +0,0 @@
|
||||
/* Copyright 2020 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.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
// Xtensa timer implementation.
|
||||
// To include this with make, add TARGET=xtensa_hifimini.
|
||||
#include "tensorflow/lite/micro/micro_time.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
namespace tflite {
|
||||
|
||||
int32_t ticks_per_second() { return CLOCKS_PER_SEC; }
|
||||
|
||||
int32_t GetCurrentTimeTicks() { return clock(); }
|
||||
|
||||
} // namespace tflite
|
Loading…
Reference in New Issue
Block a user