liblloyal 1.0.0
Composable primitives for llama.cpp inference
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
14// ===== PLATFORM-NATIVE LOGGING =====
15
16#ifdef DEBUG
17
18#if defined(__APPLE__)
19#include <os/log.h>
20// Apple's Unified Logging System - integrates with Xcode Console
21#define LLOYAL_LOG_DEBUG(...) os_log(OS_LOG_DEFAULT, __VA_ARGS__)
22#define LLOYAL_LOG_INFO(...) os_log_info(OS_LOG_DEFAULT, __VA_ARGS__)
23#define LLOYAL_LOG_WARNING(...) os_log_error(OS_LOG_DEFAULT, __VA_ARGS__)
24#define LLOYAL_LOG_ERROR(...) os_log_fault(OS_LOG_DEFAULT, __VA_ARGS__)
25#elif defined(__ANDROID__)
26#include <android/log.h>
27// Android's Logcat system - integrates with Android Studio
28#define LLOYAL_LOG_DEBUG(...) \
29 __android_log_print(ANDROID_LOG_DEBUG, "lloyal", __VA_ARGS__)
30#define LLOYAL_LOG_INFO(...) \
31 __android_log_print(ANDROID_LOG_INFO, "lloyal", __VA_ARGS__)
32#define LLOYAL_LOG_WARNING(...) \
33 __android_log_print(ANDROID_LOG_WARN, "lloyal", __VA_ARGS__)
34#define LLOYAL_LOG_ERROR(...) \
35 __android_log_print(ANDROID_LOG_ERROR, "lloyal", __VA_ARGS__)
36#else
37// Fallback for desktop/other platforms
38#include <cstdio>
39#define LLOYAL_LOG_DEBUG(...) printf(__VA_ARGS__)
40#define LLOYAL_LOG_INFO(...) printf(__VA_ARGS__)
41#define LLOYAL_LOG_WARNING(...) printf(__VA_ARGS__)
42#define LLOYAL_LOG_ERROR(...) printf(__VA_ARGS__)
43#endif
44
45#else
46// Release builds: compile out all logging (zero overhead)
47#define LLOYAL_LOG_DEBUG(...) \
48 do { \
49 } while (0)
50#define LLOYAL_LOG_INFO(...) \
51 do { \
52 } while (0)
53#define LLOYAL_LOG_WARNING(...) \
54 do { \
55 } while (0)
56#define LLOYAL_LOG_ERROR(...) \
57 do { \
58 } while (0)
59#endif
60
61// ===== CONSTANTS =====
62
63namespace lloyal {
64
65namespace defaults {
66// Context window size - reasonable for mobile devices
67static constexpr int N_CTX = 2048;
68
69// Batch size for context initialization - optimized for memory usage
70static constexpr int N_BATCH_INIT = 512;
71
72// Batch size for token processing - smaller batches for streaming
73static constexpr int N_BATCH_PROCESS = 32;
74} // namespace defaults
75
76} // namespace lloyal
static constexpr int N_CTX
Definition common.hpp:67
static constexpr int N_BATCH_INIT
Definition common.hpp:70
static constexpr int N_BATCH_PROCESS
Definition common.hpp:73
JSON Schema to Grammar Converter (Header-Only)