未验证 提交 f03c3765 编写于 作者: T TFLM-bot 提交者: GitHub

Sync from upstream TF. (#100)

上级 7af878a3
/* Copyright 2021 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.
==============================================================================*/
#include "tensorflow/lite/micro/micro_time.h"
// DWT (Data Watchpoint and Trace) registers, only exists on ARM Cortex with a
// DWT unit.
#define KIN1_DWT_CONTROL (*((volatile uint32_t*)0xE0001000))
/*!< DWT Control register */
// DWT Control register.
#define KIN1_DWT_CYCCNTENA_BIT (1UL << 0)
// CYCCNTENA bit in DWT_CONTROL register.
#define KIN1_DWT_CYCCNT (*((volatile uint32_t*)0xE0001004))
// DWT Cycle Counter register.
#define KIN1_DEMCR (*((volatile uint32_t*)0xE000EDFC))
// DEMCR: Debug Exception and Monitor Control Register.
#define KIN1_TRCENA_BIT (1UL << 24)
#define KIN1_LAR (*((volatile uint32_t*)0xE0001FB0))
#define KIN1_DWT_CONTROL (*((volatile uint32_t*)0xE0001000))
// Unlock access to DWT (ITM, etc.)registers.
#define KIN1_UnlockAccessToDWT() KIN1_LAR = 0xC5ACCE55;
// TRCENA: Enable trace and debug block DEMCR (Debug Exception and Monitor
// Control Register.
#define KIN1_InitCycleCounter() KIN1_DEMCR |= KIN1_TRCENA_BIT
#define KIN1_ResetCycleCounter() KIN1_DWT_CYCCNT = 0
#define KIN1_EnableCycleCounter() KIN1_DWT_CONTROL |= KIN1_DWT_CYCCNTENA_BIT
#define KIN1_DisableCycleCounter() KIN1_DWT_CONTROL &= ~KIN1_DWT_CYCCNTENA_BIT
#define KIN1_GetCycleCounter() KIN1_DWT_CYCCNT
namespace tflite {
int32_t ticks_per_second() { return 0; }
int32_t GetCurrentTimeTicks() {
static bool is_initialized = false;
if (!is_initialized) {
KIN1_UnlockAccessToDWT();
KIN1_InitCycleCounter();
KIN1_ResetCycleCounter();
KIN1_EnableCycleCounter();
is_initialized = true;
}
return KIN1_GetCycleCounter();
}
} // namespace tflite
......@@ -287,10 +287,10 @@ TF_LITE_MICRO_TEST(InterpreterWithProfilerShouldProfileOps) {
TF_LITE_MICRO_EXPECT_EQ(profiler.event_ends(), 0);
TF_LITE_MICRO_EXPECT_EQ(interpreter.AllocateTensors(), kTfLiteOk);
TF_LITE_MICRO_EXPECT_EQ(interpreter.Invoke(), kTfLiteOk);
#ifndef NDEBUG
#ifndef TF_LITE_STRIP_ERROR_STRINGS
TF_LITE_MICRO_EXPECT_EQ(profiler.event_starts(), 3);
TF_LITE_MICRO_EXPECT_EQ(profiler.event_ends(), 3);
#else // Profile events will not occur on release builds.
#else
TF_LITE_MICRO_EXPECT_EQ(profiler.event_starts(), 0);
TF_LITE_MICRO_EXPECT_EQ(profiler.event_ends(), 0);
#endif
......
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
/* Copyright 2021 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.
......@@ -70,7 +70,7 @@ class MicroProfiler {
TF_LITE_REMOVE_VIRTUAL_DELETE;
};
#if defined(NDEBUG)
#if defined(TF_LITE_STRIP_ERROR_STRINGS)
// For release builds, the ScopedMicroProfiler is a noop.
//
// This is done because the ScipedProfiler is used as part of the
......
......@@ -40,6 +40,11 @@ readable_run make -j8 -f tensorflow/lite/micro/tools/make/Makefile BUILD_TYPE=no
readable_run make -f tensorflow/lite/micro/tools/make/Makefile clean
readable_run make -j8 -f tensorflow/lite/micro/tools/make/Makefile BUILD_TYPE=release build
# Next, build wit release and logs so that we can run the tests and get
# additional debugging info on failures.
readable_run make -f tensorflow/lite/micro/tools/make/Makefile clean
readable_run make -s -j8 -f tensorflow/lite/micro/tools/make/Makefile BUILD_TYPE=release_with_logs test
# Next, build w/o release so that we can run the tests and get additional
# debugging info on failures.
readable_run make -f tensorflow/lite/micro/tools/make/Makefile clean
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册