mirror of
https://github.com/vee1e/tflite-micro.git
synced 2026-09-01 09:51:22 +00:00
@tensorflow/micro Preparatory work for [b/297590035](https://issuetracker.google.com/297590035) Add MicroSnprintf Add MicroVsnprintf Update debug_log.cc for all required targets Add debug_log.cc for riscv32_generic target using third-party eyalroz printf code (riscv32_generic stdio formatting does not support %f) bug=fixes #2342
62 lines
1.7 KiB
C++
62 lines
1.7 KiB
C++
/* Copyright 2023 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_log.h"
|
|
|
|
#include <cstdarg>
|
|
#include <cstdint>
|
|
|
|
#if !defined(TF_LITE_STRIP_ERROR_STRINGS)
|
|
#include "tensorflow/lite/micro/debug_log.h"
|
|
#endif
|
|
|
|
#if !defined(TF_LITE_STRIP_ERROR_STRINGS)
|
|
namespace {
|
|
|
|
void VDebugLog(const char* format, ...) {
|
|
va_list args;
|
|
va_start(args, format);
|
|
DebugLog(format, args);
|
|
va_end(args);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
void VMicroPrintf(const char* format, va_list args) {
|
|
DebugLog(format, args);
|
|
// TODO(b/290051015): remove "\r\n"
|
|
VDebugLog("\r\n");
|
|
}
|
|
|
|
void MicroPrintf(const char* format, ...) {
|
|
va_list args;
|
|
va_start(args, format);
|
|
VMicroPrintf(format, args);
|
|
va_end(args);
|
|
}
|
|
|
|
int MicroSnprintf(char* buffer, size_t buf_size, const char* format, ...) {
|
|
va_list args;
|
|
va_start(args, format);
|
|
int result = MicroVsnprintf(buffer, buf_size, format, args);
|
|
va_end(args);
|
|
return result;
|
|
}
|
|
|
|
int MicroVsnprintf(char* buffer, size_t buf_size, const char* format,
|
|
va_list vlist) {
|
|
return DebugVsnprintf(buffer, buf_size, format, vlist);
|
|
}
|
|
#endif // !defined(TF_LITE_STRIP_ERROR_STRINGS)
|