mirror of
https://github.com/karpathy/llm.c.git
synced 2026-07-28 20:35:09 -04:00
change fabs to fabsf
This commit is contained in:
parent
add9e77daa
commit
e1e0a08035
2 changed files with 7 additions and 7 deletions
|
|
@ -7,7 +7,7 @@ int check_tensor(float *a, float *b, int n, char* label) {
|
|||
int ok = 1;
|
||||
printf("%s\n", label);
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (fabs(a[i] - b[i]) <= 1e-2) {
|
||||
if (fabsf(a[i] - b[i]) <= 1e-2) {
|
||||
if (i < print_upto) { printf("OK "); }
|
||||
} else {
|
||||
if (i < print_upto) { printf("NOT OK "); }
|
||||
|
|
@ -91,7 +91,7 @@ int main(int argc, char *argv[]) {
|
|||
if(i < 3) {
|
||||
printf("%f %f\n", expected_logits[i], model.acts.logits[i]);
|
||||
}
|
||||
if (fabs(expected_logits[i] - model.acts.logits[i]) >= 1e-2) {
|
||||
if (fabsf(expected_logits[i] - model.acts.logits[i]) >= 1e-2) {
|
||||
printf("MISMATCH AT INDEX %d: ", i);
|
||||
printf("%f %f\n", expected_logits[i],model.acts.logits[i]);
|
||||
logits_ok = 0;
|
||||
|
|
@ -103,7 +103,7 @@ int main(int argc, char *argv[]) {
|
|||
allok = allok && logits_ok;
|
||||
|
||||
// compare the achieved loss
|
||||
if (fabs(model.mean_loss - *expected_loss) >= 1e-2) {
|
||||
if (fabsf(model.mean_loss - *expected_loss) >= 1e-2) {
|
||||
printf("LOSS MISMATCH: %f %f\n", model.mean_loss, *expected_loss);
|
||||
allok = 0;
|
||||
} else {
|
||||
|
|
@ -156,7 +156,7 @@ int main(int argc, char *argv[]) {
|
|||
};
|
||||
// compare
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (fabs(losses[i] - expected_losses[i]) >= 1e-2) {
|
||||
if (fabsf(losses[i] - expected_losses[i]) >= 1e-2) {
|
||||
printf("LOSS MISMATCH AT STEP %d: %f %f\n", i, losses[i], expected_losses[i]);
|
||||
allok = 0;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ int check_tensor(float *a, float *b, int n, char* label) {
|
|||
int ok = 1;
|
||||
printf("%s\n", label);
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (fabs(a[i] - b[i]) <= 1e-2) {
|
||||
if (fabsf(a[i] - b[i]) <= 1e-2) {
|
||||
if (i < print_upto) { printf("OK "); }
|
||||
} else {
|
||||
if (i < print_upto) { printf("NOT OK "); }
|
||||
|
|
@ -89,7 +89,7 @@ int main(int argc, char *argv[]) {
|
|||
if(i < 3) {
|
||||
printf("%f %f\n", expected_logits[i], logits_cpu[i]);
|
||||
}
|
||||
if (fabs(expected_logits[i] - logits_cpu[i]) >= 1e-2) {
|
||||
if (fabsf(expected_logits[i] - logits_cpu[i]) >= 1e-2) {
|
||||
printf("MISMATCH AT INDEX %d: ", i);
|
||||
printf("%f %f\n", expected_logits[i],logits_cpu[i]);
|
||||
logits_ok = 0;
|
||||
|
|
@ -102,7 +102,7 @@ int main(int argc, char *argv[]) {
|
|||
free(logits_cpu);
|
||||
|
||||
// compare the achieved loss
|
||||
if (fabs(model.mean_loss - *expected_loss) >= 1e-2) {
|
||||
if (fabsf(model.mean_loss - *expected_loss) >= 1e-2) {
|
||||
printf("LOSS MISMATCH: %f %f\n", model.mean_loss, *expected_loss);
|
||||
allok = 0;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue