MCPcopy Create free account
hub / github.com/AnswerDotAI/gpu.cpp / LOG

Function LOG

utils/logging.hpp:51–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49#ifndef NO_LOG
50 template <typename... Args>
51 inline void LOG(Logger &logger, int level, const char *message, ...)
52 {
53 static const char *orange = "\033[0;33m";
54 static const char *red = "\033[0;31m";
55 static const char *white = "\033[0;37m";
56 static const char *gray = "\033[0;90m";
57 static const char *reset = "\033[0m";
58 static const char *logColors[] = {red, red, orange, gray};
59 if (level <= logger.level)
60 {
61 va_list args;
62 va_list args2;
63 va_start(args, message);
64 va_copy(args2, args);
65
66 int size = vsnprintf(nullptr, 0, message, args) + 1;
67 std::unique_ptr<char[]> buffer(new char[size]);
68
69#ifdef _WIN32
70 _vsnprintf_s(buffer.get(), size, _TRUNCATE, message, args2);
71#else
72 vsnprintf(buffer.get(), size, message, args2);
73#endif
74
75 // Brackets and messages are white.
76 // Log levels are red for error and warning, orange for info, and grey for trace.
77 // Then the color is reset.
78 logger.stream << white << "[" << logColors[level] << kLevelStr[level] << white << "] ";
79 logger.stream << buffer.get();
80 logger.stream << reset << std::endl;
81 va_end(args);
82 va_end(args2);
83 }
84 }
85#else
86 template <typename... Args>
87 inline void LOG(Logger &logger, int level, const char *message, Args... args)

Callers 15

sizeBytesFunction · 0.85
toStringFunction · 0.85
KernelCodeMethod · 0.85
~ContextMethod · 0.85
createTensorFunction · 0.85
FreeTensorFunction · 0.85
~TensorPoolMethod · 0.85
checkFunction · 0.85
createContextFunction · 0.85
createContextByGpuIdxFunction · 0.85
createKernelFunction · 0.85
iscloseFunction · 0.85

Calls

no outgoing calls

Tested by 8

testResidualFunction · 0.68
testHadamardFunction · 0.68
testMatmulFunction · 0.68
testTensorPoolFunction · 0.68
testGeluFunction · 0.68
testLayerNormFunction · 0.68
testSoftmaxFunction · 0.68
mainFunction · 0.68