Skip to content

Commit ec2b03e

Browse files
author
mike dupont
committed
now printing tensors
1 parent af698c6 commit ec2b03e

File tree

6 files changed

+141
-59
lines changed

6 files changed

+141
-59
lines changed

binding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
cxxClientRoot = "/home/mdupont/experiments/llama.cpp/"
1515

1616
fileList = [
17-
# "ggml.cpp",
17+
"ggml.cpp",
1818
# "llama.cpp",
19-
"examples/server/server.cpp",
19+
# "examples/server/server.cpp",
2020
]
2121

2222
typeList = [

examples/main/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
#if defined(_MSC_VER)
3131
#pragma warning(disable: 4244 4267) // possible loss of data
3232
#endif
33-
33+
#include "ggml-internal.hpp"
34+
#include "llama-internal.hpp"
3435
#include "print.hpp"
3536

3637
static llama_context ** g_ctx;

examples/server/server.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <thread>
2525
#include <mutex>
2626
#include <chrono>
27+
#include "llama-internal.hpp"
2728
#include "print.hpp"
2829

2930
#ifndef SERVER_VERBOSE

ggml.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "ggml-impl.h"
55
#include "ggml-quants.h"
66

7+
78
#if defined(_MSC_VER) || defined(__MINGW32__)
89
#include <malloc.h> // using malloc.h with MSC/MINGW
910
#elif !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
@@ -46,6 +47,12 @@ void type_traits_init();
4647
void GGUF_TYPE_SIZE_init();
4748
void GGUF_TYPE_NAME_init();
4849

50+
#include "llama.h"
51+
struct ggml_allocr;
52+
//#include "ggml-internal.hpp"
53+
#include "llama-internal.hpp"
54+
#include "print.hpp"
55+
4956
#if defined(_WIN32)
5057

5158
#include <windows.h>
@@ -9412,7 +9419,10 @@ static void ggml_compute_forward_mul_mat(
94129419
const struct ggml_tensor * src0,
94139420
const struct ggml_tensor * src1,
94149421
struct ggml_tensor * dst) {
9415-
9422+
print_fields(*params);
9423+
print_fields(*src0);
9424+
print_fields(*src1);
9425+
print_fields(*dst);
94169426
int64_t t0 = ggml_perf_time_us();
94179427
UNUSED(t0);
94189428

@@ -9456,17 +9466,20 @@ static void ggml_compute_forward_mul_mat(
94569466
if (params->ith == 0 && params->type == GGML_TASK_COMPUTE) {
94579467
ggml_cl_mul_mat(src0, src1, dst, params->wdata, params->wsize);
94589468
}
9469+
print_fields(*dst);
94599470
return;
94609471
}
94619472
#endif
94629473

94639474
#if defined(GGML_USE_ACCELERATE) || defined(GGML_USE_OPENBLAS)
94649475
if (ggml_compute_forward_mul_mat_use_blas(src0, src1, dst)) {
94659476
if (params->ith != 0) {
9477+
print_fields(*dst);
94669478
return;
94679479
}
94689480

94699481
if (params->type == GGML_TASK_INIT) {
9482+
94709483
return;
94719484
}
94729485

@@ -9508,7 +9521,7 @@ static void ggml_compute_forward_mul_mat(
95089521
}
95099522

95109523
//printf("CBLAS = %f ms, %d x %d x %d x %d\n", (ggml_perf_time_us() - t0)/1000.0, ne0, ne1, ne2, ne3);
9511-
9524+
print_fields(*dst);
95129525
return;
95139526
}
95149527
#endif
@@ -9527,11 +9540,12 @@ static void ggml_compute_forward_mul_mat(
95279540
}
95289541
}
95299542
}
9530-
9543+
print_fields(*dst);
95319544
return;
95329545
}
95339546

95349547
if (params->type == GGML_TASK_FINALIZE) {
9548+
print_fields(*dst);
95359549
return;
95369550
}
95379551

@@ -9565,6 +9579,7 @@ static void ggml_compute_forward_mul_mat(
95659579
// threads with no work simply yield (not sure if it helps)
95669580
if (ir010 >= ir011 || ir110 >= ir111) {
95679581
sched_yield();
9582+
95689583
return;
95699584
}
95709585

@@ -9617,6 +9632,7 @@ static void ggml_compute_forward_mul_mat(
96179632
}
96189633
}
96199634
}
9635+
print_fields(*dst);
96209636
}
96219637

96229638
// ggml_compute_forward_out_prod

llama-internal.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#include <set>
22
#include <queue>
3+
#include <map>
4+
#include <random>
5+
#include <functional>
6+
#include <unordered_map>
7+
#include <memory>
38
enum llm_arch {
49
LLM_ARCH_LLAMA,
510
LLM_ARCH_FALCON,
@@ -451,6 +456,7 @@ struct llama_model {
451456
}
452457
};
453458

459+
struct ggml_allocr;
454460
struct llama_context {
455461
llama_context(const llama_model & model) : model(model), t_start_us(model.t_start_us), t_load_us(model.t_load_us) {}
456462
~llama_context();

0 commit comments

Comments
 (0)