liblloyal 1.0.0
Branched Inference for llama.cpp
Loading...
Searching...
No Matches
common.hpp
Go to the documentation of this file.
1#pragma once
2
3// SPDX-License-Identifier: Apache-2.0
4// Copyright 2026 Lloyal Labs
5
6
15// ===== PLATFORM-NATIVE LOGGING =====
16
17#ifdef DEBUG
18
19#if defined(__APPLE__)
20#include <os/log.h>
21// Apple's Unified Logging System - integrates with Xcode Console
22#define LLOYAL_LOG_DEBUG(...) os_log(OS_LOG_DEFAULT, __VA_ARGS__)
23#define LLOYAL_LOG_INFO(...) os_log_info(OS_LOG_DEFAULT, __VA_ARGS__)
24#define LLOYAL_LOG_WARNING(...) os_log_error(OS_LOG_DEFAULT, __VA_ARGS__)
25#define LLOYAL_LOG_ERROR(...) os_log_fault(OS_LOG_DEFAULT, __VA_ARGS__)
26#elif defined(__ANDROID__)
27#include <android/log.h>
28// Android's Logcat system - integrates with Android Studio
29#define LLOYAL_LOG_DEBUG(...) \
30 __android_log_print(ANDROID_LOG_DEBUG, "lloyal", __VA_ARGS__)
31#define LLOYAL_LOG_INFO(...) \
32 __android_log_print(ANDROID_LOG_INFO, "lloyal", __VA_ARGS__)
33#define LLOYAL_LOG_WARNING(...) \
34 __android_log_print(ANDROID_LOG_WARN, "lloyal", __VA_ARGS__)
35#define LLOYAL_LOG_ERROR(...) \
36 __android_log_print(ANDROID_LOG_ERROR, "lloyal", __VA_ARGS__)
37#else
38// Fallback for desktop/other platforms
39#include <cstdio>
40#define LLOYAL_LOG_DEBUG(...) printf(__VA_ARGS__)
41#define LLOYAL_LOG_INFO(...) printf(__VA_ARGS__)
42#define LLOYAL_LOG_WARNING(...) printf(__VA_ARGS__)
43#define LLOYAL_LOG_ERROR(...) printf(__VA_ARGS__)
44#endif
45
46#else
47// Release builds: compile out all logging (zero overhead)
48#define LLOYAL_LOG_DEBUG(...) \
49 do { \
50 } while (0)
51#define LLOYAL_LOG_INFO(...) \
52 do { \
53 } while (0)
54#define LLOYAL_LOG_WARNING(...) \
55 do { \
56 } while (0)
57#define LLOYAL_LOG_ERROR(...) \
58 do { \
59 } while (0)
60#endif
61
62// ===== CONSTANTS =====
63
64namespace lloyal {
65
66namespace defaults {
67// Context window size - reasonable for mobile devices
68static constexpr int N_CTX = 2048;
69
70// Batch size for context initialization - optimized for memory usage
71static constexpr int N_BATCH_INIT = 512;
72
73// Batch size for token processing - smaller batches for streaming
74static constexpr int N_BATCH_PROCESS = 32;
75} // namespace defaults
76
77} // namespace lloyal
static constexpr int N_CTX
Definition common.hpp:68
static constexpr int N_BATCH_INIT
Definition common.hpp:71
static constexpr int N_BATCH_PROCESS
Definition common.hpp:74
Boundary Tracker Stub for OSS liblloyal.