Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit 7db5b4f

Browse files
committed
fix overflow when model size > 2^31
1 parent 26c13b2 commit 7db5b4f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

ffm-train.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ string train_help() {
2727
"-r <eta>: set learning rate (default 0.2)\n"
2828
"-s <nr_threads>: set number of threads (default 1)\n"
2929
"-p <path>: set path to the validation set\n"
30-
"--quiet: quiet model (no output)\n"
30+
"--quiet: quiet mode (no output)\n"
3131
"--no-norm: disable instance-wise normalization\n"
3232
"--auto-stop: stop at the iteration that achieves the best validation loss (must be used with -p)\n");
3333
}

ffm.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ inline ffm_float wTx(
106106
if(j2 >= model.n || f2 >= model.m)
107107
continue;
108108

109-
ffm_float *w1_base = model.W + j1*align1 + f2*align0;
110-
ffm_float *w2_base = model.W + j2*align1 + f1*align0;
109+
ffm_float *w1_base = model.W + (ffm_long)j1*align1 + f2*align0;
110+
ffm_float *w2_base = model.W + (ffm_long)j2*align1 + f1*align0;
111111

112112
__m128 XMMv = _mm_set1_ps(v1*v2*r);
113113

@@ -206,8 +206,8 @@ inline ffm_float wTx(
206206
if(j2 >= model.n || f2 >= model.m)
207207
continue;
208208

209-
ffm_float *w1 = model.W + j1*align1 + f2*align0;
210-
ffm_float *w2 = model.W + j2*align1 + f1*align0;
209+
ffm_float *w1 = model.W + (ffm_long)j1*align1 + f2*align0;
210+
ffm_float *w2 = model.W + (ffm_long)j2*align1 + f1*align0;
211211

212212
ffm_float v = v1 * v2 * r;
213213

@@ -516,7 +516,7 @@ void ffm_read_problem_to_disk(string txt_path, string bin_path) {
516516

517517
Timer timer;
518518

519-
cout << "First check if the text file has already converted to binary format " << flush;
519+
cout << "First check if the text file has already been converted to binary format " << flush;
520520
bool same_file = check_same_txt_bin(txt_path, bin_path);
521521
cout << "(" << fixed << setprecision(1) << timer.toc() << " seconds)" << endl;
522522

0 commit comments

Comments
 (0)