Use GGML_LOG instead of GGML_PRINT
This commit is contained in:
parent
31c3b89c88
commit
a731280e61
1 changed files with 23 additions and 25 deletions
|
@ -357,25 +357,23 @@ void ggml_log_callback_default(enum ggml_log_level level, const char * text, voi
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (GGML_DEBUG >= 1)
|
#if (GGML_DEBUG >= 1)
|
||||||
#define GGML_PRINT_DEBUG(...) printf(__VA_ARGS__)
|
#define GGML_PRINT_DEBUG(...) GGML_LOG_DEBUG(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define GGML_PRINT_DEBUG(...)
|
#define GGML_PRINT_DEBUG(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (GGML_DEBUG >= 5)
|
#if (GGML_DEBUG >= 5)
|
||||||
#define GGML_PRINT_DEBUG_5(...) printf(__VA_ARGS__)
|
#define GGML_PRINT_DEBUG_5(...) GGML_LOG_DEBUG(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define GGML_PRINT_DEBUG_5(...)
|
#define GGML_PRINT_DEBUG_5(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (GGML_DEBUG >= 10)
|
#if (GGML_DEBUG >= 10)
|
||||||
#define GGML_PRINT_DEBUG_10(...) printf(__VA_ARGS__)
|
#define GGML_PRINT_DEBUG_10(...) GGML_LOG_DEBUG(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define GGML_PRINT_DEBUG_10(...)
|
#define GGML_PRINT_DEBUG_10(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GGML_PRINT(...) printf(__VA_ARGS__)
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// end of logging block
|
// end of logging block
|
||||||
//
|
//
|
||||||
|
@ -392,7 +390,7 @@ void ggml_log_callback_default(enum ggml_log_level level, const char * text, voi
|
||||||
#else
|
#else
|
||||||
inline static void * ggml_aligned_malloc(size_t size) {
|
inline static void * ggml_aligned_malloc(size_t size) {
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
GGML_PRINT("WARNING: Behavior may be unexpected when allocating 0 bytes for ggml_aligned_malloc!\n");
|
GGML_LOG_WARN("Behavior may be unexpected when allocating 0 bytes for ggml_aligned_malloc!\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
void * aligned_memory = NULL;
|
void * aligned_memory = NULL;
|
||||||
|
@ -414,7 +412,7 @@ inline static void * ggml_aligned_malloc(size_t size) {
|
||||||
error_desc = "insufficient memory";
|
error_desc = "insufficient memory";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
GGML_PRINT("%s: %s (attempted to allocate %6.2f MB)\n", __func__, error_desc, size/(1024.0*1024.0));
|
GGML_LOG_ERROR("%s: %s (attempted to allocate %6.2f MB)\n", __func__, error_desc, size/(1024.0*1024.0));
|
||||||
GGML_ABORT("fatal error");
|
GGML_ABORT("fatal error");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -430,12 +428,12 @@ inline static void * ggml_aligned_malloc(size_t size) {
|
||||||
|
|
||||||
inline static void * ggml_malloc(size_t size) {
|
inline static void * ggml_malloc(size_t size) {
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
GGML_PRINT("WARNING: Behavior may be unexpected when allocating 0 bytes for ggml_malloc!\n");
|
GGML_LOG_WARN("Behavior may be unexpected when allocating 0 bytes for ggml_malloc!\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
void * result = malloc(size);
|
void * result = malloc(size);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
GGML_PRINT("%s: failed to allocate %6.2f MB\n", __func__, size/(1024.0*1024.0));
|
GGML_LOG_ERROR("%s: failed to allocate %6.2f MB\n", __func__, size/(1024.0*1024.0));
|
||||||
GGML_ABORT("fatal error");
|
GGML_ABORT("fatal error");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -444,12 +442,12 @@ inline static void * ggml_malloc(size_t size) {
|
||||||
// calloc
|
// calloc
|
||||||
inline static void * ggml_calloc(size_t num, size_t size) {
|
inline static void * ggml_calloc(size_t num, size_t size) {
|
||||||
if (num == 0 || size == 0) {
|
if (num == 0 || size == 0) {
|
||||||
GGML_PRINT("WARNING: Behavior may be unexpected when allocating 0 bytes for ggml_calloc!\n");
|
GGML_LOG_WARN("Behavior may be unexpected when allocating 0 bytes for ggml_calloc!\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
void * result = calloc(num, size);
|
void * result = calloc(num, size);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
GGML_PRINT("%s: failed to allocate %6.2f MB\n", __func__, size/(1024.0*1024.0));
|
GGML_LOG_ERROR("%s: failed to allocate %6.2f MB\n", __func__, size/(1024.0*1024.0));
|
||||||
GGML_ABORT("fatal error");
|
GGML_ABORT("fatal error");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -3384,7 +3382,7 @@ void ggml_numa_init(enum ggml_numa_strategy numa_flag) {
|
||||||
if (fptr != NULL) {
|
if (fptr != NULL) {
|
||||||
char buf[42];
|
char buf[42];
|
||||||
if (fgets(buf, sizeof(buf), fptr) && strncmp(buf, "0\n", sizeof(buf)) != 0) {
|
if (fgets(buf, sizeof(buf), fptr) && strncmp(buf, "0\n", sizeof(buf)) != 0) {
|
||||||
GGML_PRINT("WARNING: /proc/sys/kernel/numa_balancing is enabled, this has been observed to impair performance\n");
|
GGML_LOG_WARN("/proc/sys/kernel/numa_balancing is enabled, this has been observed to impair performance\n");
|
||||||
}
|
}
|
||||||
fclose(fptr);
|
fclose(fptr);
|
||||||
}
|
}
|
||||||
|
@ -3402,21 +3400,21 @@ bool ggml_is_numa(void) {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void ggml_print_object(const struct ggml_object * obj) {
|
void ggml_print_object(const struct ggml_object * obj) {
|
||||||
GGML_PRINT(" - ggml_object: type = %d, offset = %zu, size = %zu, next = %p\n",
|
GGML_LOG_INFO(" - ggml_object: type = %d, offset = %zu, size = %zu, next = %p\n",
|
||||||
obj->type, obj->offs, obj->size, (const void *) obj->next);
|
obj->type, obj->offs, obj->size, (const void *) obj->next);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ggml_print_objects(const struct ggml_context * ctx) {
|
void ggml_print_objects(const struct ggml_context * ctx) {
|
||||||
struct ggml_object * obj = ctx->objects_begin;
|
struct ggml_object * obj = ctx->objects_begin;
|
||||||
|
|
||||||
GGML_PRINT("%s: objects in context %p:\n", __func__, (const void *) ctx);
|
GGML_LOG_INFO("%s: objects in context %p:\n", __func__, (const void *) ctx);
|
||||||
|
|
||||||
while (obj != NULL) {
|
while (obj != NULL) {
|
||||||
ggml_print_object(obj);
|
ggml_print_object(obj);
|
||||||
obj = obj->next;
|
obj = obj->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
GGML_PRINT("%s: --- end ---\n", __func__);
|
GGML_LOG_INFO("%s: --- end ---\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
GGML_CALL int64_t ggml_nelements(const struct ggml_tensor * tensor) {
|
GGML_CALL int64_t ggml_nelements(const struct ggml_tensor * tensor) {
|
||||||
|
@ -3999,7 +3997,7 @@ static struct ggml_object * ggml_new_object(struct ggml_context * ctx, enum ggml
|
||||||
struct ggml_object * const obj_new = (struct ggml_object *)(mem_buffer + cur_end);
|
struct ggml_object * const obj_new = (struct ggml_object *)(mem_buffer + cur_end);
|
||||||
|
|
||||||
if (cur_end + size_needed + GGML_OBJECT_SIZE > ctx->mem_size) {
|
if (cur_end + size_needed + GGML_OBJECT_SIZE > ctx->mem_size) {
|
||||||
GGML_PRINT("%s: not enough space in the context's memory pool (needed %zu, available %zu)\n",
|
GGML_LOG_WARN("%s: not enough space in the context's memory pool (needed %zu, available %zu)\n",
|
||||||
__func__, cur_end + size_needed + GGML_OBJECT_SIZE, ctx->mem_size);
|
__func__, cur_end + size_needed + GGML_OBJECT_SIZE, ctx->mem_size);
|
||||||
assert(false);
|
assert(false);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -4063,7 +4061,7 @@ static struct ggml_tensor * ggml_new_tensor_impl(
|
||||||
if (ctx->scratch.data != NULL) {
|
if (ctx->scratch.data != NULL) {
|
||||||
// allocate tensor data in the scratch buffer
|
// allocate tensor data in the scratch buffer
|
||||||
if (ctx->scratch.offs + data_size > ctx->scratch.size) {
|
if (ctx->scratch.offs + data_size > ctx->scratch.size) {
|
||||||
GGML_PRINT("%s: not enough space in the scratch memory pool (needed %zu, available %zu)\n",
|
GGML_LOG_WARN("%s: not enough space in the scratch memory pool (needed %zu, available %zu)\n",
|
||||||
__func__, ctx->scratch.offs + data_size, ctx->scratch.size);
|
__func__, ctx->scratch.offs + data_size, ctx->scratch.size);
|
||||||
assert(false);
|
assert(false);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -20046,7 +20044,7 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (n_threads > threadpool->n_threads_max) {
|
if (n_threads > threadpool->n_threads_max) {
|
||||||
GGML_PRINT("WARNING: cplan requested more threads (%d) than available (%d)\n", n_threads, threadpool->n_threads_max);
|
GGML_LOG_WARN("cplan requested more threads (%d) than available (%d)\n", n_threads, threadpool->n_threads_max);
|
||||||
n_threads = threadpool->n_threads_max;
|
n_threads = threadpool->n_threads_max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20585,30 +20583,30 @@ struct ggml_cgraph * ggml_graph_import(const char * fname, struct ggml_context *
|
||||||
}
|
}
|
||||||
|
|
||||||
void ggml_graph_print(const struct ggml_cgraph * cgraph) {
|
void ggml_graph_print(const struct ggml_cgraph * cgraph) {
|
||||||
GGML_PRINT("=== GRAPH ===\n");
|
GGML_LOG_INFO("=== GRAPH ===\n");
|
||||||
|
|
||||||
GGML_PRINT("n_nodes = %d\n", cgraph->n_nodes);
|
GGML_LOG_INFO("n_nodes = %d\n", cgraph->n_nodes);
|
||||||
for (int i = 0; i < cgraph->n_nodes; i++) {
|
for (int i = 0; i < cgraph->n_nodes; i++) {
|
||||||
struct ggml_tensor * node = cgraph->nodes[i];
|
struct ggml_tensor * node = cgraph->nodes[i];
|
||||||
|
|
||||||
GGML_PRINT(" - %3d: [ %5" PRId64 ", %5" PRId64 ", %5" PRId64 "] %16s %s\n",
|
GGML_LOG_INFO(" - %3d: [ %5" PRId64 ", %5" PRId64 ", %5" PRId64 "] %16s %s\n",
|
||||||
i,
|
i,
|
||||||
node->ne[0], node->ne[1], node->ne[2],
|
node->ne[0], node->ne[1], node->ne[2],
|
||||||
ggml_op_name(node->op), (node->flags & GGML_TENSOR_FLAG_PARAM) ? "x" : node->grad ? "g" : " ");
|
ggml_op_name(node->op), (node->flags & GGML_TENSOR_FLAG_PARAM) ? "x" : node->grad ? "g" : " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
GGML_PRINT("n_leafs = %d\n", cgraph->n_leafs);
|
GGML_LOG_INFO("n_leafs = %d\n", cgraph->n_leafs);
|
||||||
for (int i = 0; i < cgraph->n_leafs; i++) {
|
for (int i = 0; i < cgraph->n_leafs; i++) {
|
||||||
struct ggml_tensor * node = cgraph->leafs[i];
|
struct ggml_tensor * node = cgraph->leafs[i];
|
||||||
|
|
||||||
GGML_PRINT(" - %3d: [ %5" PRId64 ", %5" PRId64 "] %8s %16s\n",
|
GGML_LOG_INFO(" - %3d: [ %5" PRId64 ", %5" PRId64 "] %8s %16s\n",
|
||||||
i,
|
i,
|
||||||
node->ne[0], node->ne[1],
|
node->ne[0], node->ne[1],
|
||||||
ggml_op_name(node->op),
|
ggml_op_name(node->op),
|
||||||
ggml_get_name(node));
|
ggml_get_name(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
GGML_PRINT("========================================\n");
|
GGML_LOG_INFO("========================================\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if node is part of the graph
|
// check if node is part of the graph
|
||||||
|
@ -20779,7 +20777,7 @@ void ggml_graph_dump_dot(const struct ggml_cgraph * gb, const struct ggml_cgraph
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
GGML_PRINT("%s: dot -Tpng %s -o %s.png && open %s.png\n", __func__, filename, filename, filename);
|
GGML_LOG_INFO("%s: dot -Tpng %s -o %s.png && open %s.png\n", __func__, filename, filename, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue