Skip to content

Commit

Permalink
minor : fix printf warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed May 26, 2023
1 parent e8d347b commit 00b49ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions examples/replit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
#include <cstddef>
#include <cstdio>
#include <cstring>
#include <cinttypes>

#include <fstream>
#include <map>
#include <stdint.h>
#include <string>
#include <unordered_map>
#include <utility>
Expand Down Expand Up @@ -326,7 +327,7 @@ bool replit_model_load(const std::string & fname, replit_model & model, replit_t

const size_t memory_size = ggml_nbytes(model.memory_k) + ggml_nbytes(model.memory_v);

printf("%s: memory_size = %8.2f MB, n_mem = %lld\n", __func__, memory_size / 1024.0 / 1024.0, n_mem);
printf("%s: memory_size = %8.2f MB, n_mem = %" PRId64 "\n", __func__, memory_size / 1024.0 / 1024.0, n_mem);
}

// load weights
Expand Down
14 changes: 7 additions & 7 deletions tests/test-mul-mat0.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <inttypes.h>

#define MAX_NARGS 2

Expand Down Expand Up @@ -132,8 +133,7 @@ bool check_gradient(
const float error_rel = g0 != 0 ? fabsf(g0 - g1)/fabs(g0) : 0;

if (error_abs > max_error_abs || error_rel > max_error_rel) {
printf("%s: ndims=%d, i=%d, k=%lld, g0=%f, g1=%f, error_abs=%f, error_rel=%f\n",
op_name, ndims, i, k, g0, g1, error_abs, error_rel);
printf("%s: ndims=%d, i=%d, k=%" PRId64 ", g0=%f, g1=%f, error_abs=%f, error_rel=%f\n", op_name, ndims, i, k, g0, g1, error_abs, error_rel);
assert(false);
}
}
Expand Down Expand Up @@ -176,7 +176,7 @@ bool check_mat_mul(
const int64_t n22 = y->ne[2];
const int64_t n32 = y->ne[3];

printf("x0: [%lld, %lld, %lld, %lld]\n", n00, n10, n20, n30);
printf("x0: [%" PRId64 ", %" PRId64 ", %" PRId64 ", %" PRId64 "]\n", n00, n10, n20, n30);
for (int j = 0; j < n10; ++j) {
for (int i = 0; i < n00; ++i) {
printf("%6.3f ", mat_get(x0, i, j, 0, 0));
Expand All @@ -185,7 +185,7 @@ bool check_mat_mul(
}
printf("\n");

printf("x1: [%lld, %lld, %lld, %lld]\n", n01, n11, n21, n31);
printf("x1: [%" PRId64 ", %" PRId64 ", %" PRId64 ", %" PRId64 "]\n", n01, n11, n21, n31);
for (int j = 0; j < n11; ++j) {
for (int i = 0; i < n01; ++i) {
printf("%6.3f ", mat_get(x1, i, j, 0, 0));
Expand All @@ -194,7 +194,7 @@ bool check_mat_mul(
}
printf("\n");

printf("y: [%lld, %lld, %lld, %lld]\n", n02, n12, n22, n32);
printf("y: [%" PRId64 ", %" PRId64 ", %" PRId64 ", %" PRId64 "]\n", n02, n12, n22, n32);
for (int j = 0; j < n12; ++j) {
for (int i = 0; i < n02; ++i) {
printf("%6.3f ", mat_get(y, i, j, 0, 0));
Expand Down Expand Up @@ -264,7 +264,7 @@ int main(int argc, const char ** argv) {
struct ggml_tensor * m = ggml_mul_mat(ctx0, x[1], x[0]);
struct ggml_tensor * f = ggml_sum(ctx0, m);

printf("testing: mul_mat, [%lld, %lld, %lld, %lld] = [%lld, %lld, %lld, %lld] * [%lld, %lld, %lld, %lld]\n",
printf("testing: mul_mat, [%" PRId64 ", %" PRId64 ", %" PRId64 ", %" PRId64 "] = [%" PRId64 ", %" PRId64 ", %" PRId64 ", %" PRId64 "] * [%" PRId64 ", %" PRId64 ", %" PRId64 ", %" PRId64 "]\n",
m->ne[0], m->ne[1], m->ne[2], m->ne[3],
x[1]->ne[0], x[1]->ne[1], x[1]->ne[2], x[1]->ne[3],
x[0]->ne[0], x[0]->ne[1], x[0]->ne[2], x[0]->ne[3]);
Expand Down Expand Up @@ -300,7 +300,7 @@ int main(int argc, const char ** argv) {
struct ggml_tensor * m = ggml_mul_mat(ctx0, x[1], x[0]);
struct ggml_tensor * f = ggml_sum(ctx0, m);

printf("testing: mul_mat, [%lld, %lld, %lld, %lld] = [%lld, %lld, %lld, %lld] * [%lld, %lld, %lld, %lld]\n",
printf("testing: mul_mat, [%" PRId64 ", %" PRId64 ", %" PRId64 ", %" PRId64 "] = [%" PRId64 ", %" PRId64 ", %" PRId64 ", %" PRId64 "] * [%" PRId64 ", %" PRId64 ", %" PRId64 ", %" PRId64 "]\n",
m->ne[0], m->ne[1], m->ne[2], m->ne[3],
x[1]->ne[0], x[1]->ne[1], x[1]->ne[2], x[1]->ne[3],
x[0]->ne[0], x[0]->ne[1], x[0]->ne[2], x[0]->ne[3]);
Expand Down

0 comments on commit 00b49ec

Please sign in to comment.