Skip to content

Commit f07f3ff

Browse files
author
mike dupont
committed
now sampling lots of data
1 parent 7778717 commit f07f3ff

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

ggml.cpp

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define _USE_MATH_DEFINES // For M_PI on MSVC
33

44
#include "ggml-impl.h"
5+
56
#include "ggml-quants.h"
67

78

@@ -2947,7 +2948,9 @@ float ggml_get_f32_1d(const struct ggml_tensor * tensor, int i) {
29472948
}
29482949
default:
29492950
{
2950-
GGML_ASSERT(false);
2951+
//return ((float *)(tensor->data))[i];
2952+
return 0;
2953+
//GGML_ASSERT(false);
29512954
}
29522955
}
29532956

@@ -9414,6 +9417,44 @@ static bool ggml_compute_forward_mul_mat_use_blas(
94149417
}
94159418
#endif
94169419

9420+
void ggml_tensor_checksum(const char * name,const struct ggml_tensor * tensor);
9421+
void ggml_tensor_checksum(const char * name,const struct ggml_tensor * tensor) {
9422+
const int64_t ne = ggml_nelements(tensor) ;
9423+
float fmin=0;
9424+
float ffirst=0;
9425+
float fmax=0;
9426+
float fsum=0;
9427+
9428+
for (int64_t j = 0; j < ne; ++j) {
9429+
float f = ggml_get_f32_1d(tensor, j);
9430+
if (j ==0) {
9431+
ffirst = f;
9432+
fmin = f;
9433+
fmax = f;
9434+
}
9435+
fsum += f;
9436+
if (f < fmin){
9437+
fmin = f;
9438+
}
9439+
if (f >fmax){
9440+
fmax = f;
9441+
}
9442+
}
9443+
9444+
auto type_name = ggml_type_name(tensor->type);
9445+
// color_name
9446+
fprintf(stderr, "JSON: { \"name1\" :\"%s\", \"cnt\":\"%ld\", \"first\":\"%f\",\"max\":\"%f\",\"min\":\"%f\",\"sum\":\"%f\", \"name\":\"%s\", \"type\":\"%s\"}\n",
9447+
name,
9448+
ne,
9449+
ffirst,
9450+
fmax,
9451+
fmin,
9452+
fsum,
9453+
tensor->name,
9454+
std::string(type_name).c_str()
9455+
);
9456+
}
9457+
94179458
static void ggml_compute_forward_mul_mat(
94189459
const struct ggml_compute_params * params,
94199460
const struct ggml_tensor * src0,
@@ -9423,6 +9464,9 @@ static void ggml_compute_forward_mul_mat(
94239464
print_fields(*src0);
94249465
print_fields(*src1);
94259466
print_fields(*dst);
9467+
ggml_tensor_checksum("src0",src0);
9468+
ggml_tensor_checksum("src1",src1);
9469+
ggml_tensor_checksum("dst_pre",dst);
94269470
int64_t t0 = ggml_perf_time_us();
94279471
UNUSED(t0);
94289472

@@ -9466,7 +9510,10 @@ static void ggml_compute_forward_mul_mat(
94669510
if (params->ith == 0 && params->type == GGML_TASK_COMPUTE) {
94679511
ggml_cl_mul_mat(src0, src1, dst, params->wdata, params->wsize);
94689512
}
9513+
9514+
94699515
print_fields(*dst);
9516+
ggml_tensor_checksum("after1",dst);
94709517
return;
94719518
}
94729519
#endif
@@ -9475,6 +9522,7 @@ static void ggml_compute_forward_mul_mat(
94759522
if (ggml_compute_forward_mul_mat_use_blas(src0, src1, dst)) {
94769523
if (params->ith != 0) {
94779524
print_fields(*dst);
9525+
ggml_tensor_checksum("after_accel",dst);
94789526
return;
94799527
}
94809528

@@ -9522,6 +9570,7 @@ static void ggml_compute_forward_mul_mat(
95229570

95239571
//printf("CBLAS = %f ms, %d x %d x %d x %d\n", (ggml_perf_time_us() - t0)/1000.0, ne0, ne1, ne2, ne3);
95249572
print_fields(*dst);
9573+
ggml_tensor_checksum("after_blas",dst);
95259574
return;
95269575
}
95279576
#endif
@@ -9541,11 +9590,13 @@ static void ggml_compute_forward_mul_mat(
95419590
}
95429591
}
95439592
print_fields(*dst);
9593+
ggml_tensor_checksum("after3",dst);
95449594
return;
95459595
}
95469596

95479597
if (params->type == GGML_TASK_FINALIZE) {
95489598
print_fields(*dst);
9599+
ggml_tensor_checksum("after_final",dst);
95499600
return;
95509601
}
95519602

@@ -9633,6 +9684,7 @@ static void ggml_compute_forward_mul_mat(
96339684
}
96349685
}
96359686
print_fields(*dst);
9687+
ggml_tensor_checksum("last",dst);
96369688
}
96379689

96389690
// ggml_compute_forward_out_prod
@@ -13741,6 +13793,8 @@ static void ggml_compute_forward(struct ggml_compute_params * params, struct ggm
1374113793
if (tensor->op == GGML_OP_NONE) {
1374213794
return;
1374313795
}
13796+
print_fields(*params);
13797+
print_fields(*tensor);
1374413798

1374513799
#ifdef GGML_USE_CUBLAS
1374613800
bool skip_cpu = ggml_cuda_compute_forward(params, tensor);

print.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ namespace runtime2
679679

680680
if (compact) os << ' ';
681681
indent(os, depth);
682-
os << '}';
682+
os << "}\n";
683683
}
684684

685685
template <typename CharT, typename T>

0 commit comments

Comments
 (0)