Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log: refine log function for Android #2071

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zhouwg
Copy link
Contributor

@zhouwg zhouwg commented Apr 17, 2024

__ANDROID__ ||  ANDROID

are defined by Android NDK, not self-defined macro. so it will not bring side-effect to existing codes.

this PR is prepare for submit Qualcomm's QNN backend to upstream whisper.cpp from "PoC: Add Qualcomm mobile SoC native backend for GGML,zhouwg/kantv#121 ".

the first step is for whisper.cpp, then llama.cpp, because llama.cpp is much more complicated then whisper.cpp

WHISPER_ATTRIBUTE_FORMAT(2, 3)
static void whisper_log_internal (ggml_log_level level, const char * format, ...);
WHISPER_ATTRIBUTE_FORMAT(5, 6)
static void whisper_log_internal (ggml_log_level level, const char * file, const char * func, int line, const char * format, ...);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add these three parameters at such a low level?

int len = vsnprintf(buffer, 1024, format, args);
if (len < 1024) {
int len_prefix = snprintf(buffer, 1024, "[%s, %d]: ", func, line); // param file not used in this file
int len = vsnprintf(buffer + len_prefix, 1024 - len_prefix, format, args);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if snprintf fails due to an output error then this will write to an address before the buffer's start.

@imaami
Copy link

imaami commented Dec 13, 2024

The macros WHISPER_LOG_{ERROR,WARN,INFO,DEBUG} are used with __func__, __FILE__ or __LINE__ already all around the codebase selectively depending on situation. They aren't meant to always be in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants