Skip to content

Commit d117c95

Browse files
keli78danpovey
authored andcommitted
[src] Some style-related fixes (and fix compiler warnings) in src/lm/
1 parent e8e5928 commit d117c95

3 files changed

Lines changed: 29 additions & 29 deletions

File tree

src/lm/arpa-file-parser-test.cc

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,18 @@ ngram 2=2\n\
165165
ngram 3=2\n\
166166
\n\
167167
\\1-grams:\n\
168-
-5.2 4 -3.3\n\
169-
-3.4 5\n\
170-
0 1 -2.5\n\
171-
-4.3 2\n\
168+
-5.2\t4\t-3.3\n\
169+
-3.4\t5\n\
170+
0\t1\t-2.5\n\
171+
-4.3\t2\n\
172172
\n\
173173
\\2-grams:\n\
174-
-1.4 4 5 -3.2\n\
175-
-1.3 1 4 -4.2\n\
174+
-1.4\t4 5\t-3.2\n\
175+
-1.3\t1 4\t-4.2\n\
176176
\n\
177177
\\3-grams:\n\
178-
-0.3 1 4 5\n\
179-
-0.2 4 5 2\n\
178+
-0.3\t1 4 5\n\
179+
-0.2\t4 5 2\n\
180180
\n\
181181
\\end\\";
182182

@@ -220,18 +220,18 @@ ngram 2=2\n\
220220
ngram 3=2\n\
221221
\n\
222222
\\1-grams: \n\
223-
-5.2 a -3.3\n\
224-
-3.4 \xCE\xB2\n\
225-
0.0 <s> -2.5\n\
226-
-4.3 </s>\n\
223+
-5.2\ta\t-3.3\n\
224+
-3.4\t\xCE\xB2\n\
225+
0.0\t<s>\t-2.5\n\
226+
-4.3\t</s>\n\
227227
\n\
228228
\\2-grams:\t\n\
229-
-1.5 a \xCE\xB2 -3.2\n\
230-
-1.3 <s> a -4.2\n\
229+
-1.5\ta \xCE\xB2\t-3.2\n\
230+
-1.3\t<s> a\t-4.2\n\
231231
\n\
232232
\\3-grams:\n\
233-
-0.3 <s> a \xCE\xB2\n\
234-
-0.2 <s> a </s>\n\
233+
-0.3\t<s> a \xCE\xB2\n\
234+
-0.2\t<s> a </s>\n\
235235
\\end\\";
236236

237237
// Symbol table that is created with predefined test symbols, "a" but no "b".

src/lm/mikolov-rnnlm-lib.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,13 @@ void CRnnLM::initNet() {
376376
}
377377

378378
syn_d =
379-
reinterpret_cast<direct_t *>(calloc(static_cast<int64>(direct_size),
379+
reinterpret_cast<direct_t *>(calloc(static_cast<long long>(direct_size),
380380
sizeof(direct_t)));
381381

382382
if (syn_d == NULL) {
383383
printf("Memory allocation for direct"
384-
" connections failed (requested %ld bytes)\n",
385-
static_cast<int64>(direct_size) * static_cast<int64>(sizeof(direct_t)));
384+
" connections failed (requested %lld bytes)\n",
385+
static_cast<long long>(direct_size) * static_cast<long long>(sizeof(direct_t)));
386386
exit(1);
387387
}
388388

@@ -461,7 +461,7 @@ void CRnnLM::initNet() {
461461
}
462462
}
463463

464-
int64 aa;
464+
long long aa;
465465
for (aa = 0; aa < direct_size; aa++) {
466466
syn_d[aa] = 0;
467467
}
@@ -621,7 +621,7 @@ void CRnnLM::restoreNet() { // will read whole network structure
621621
fscanf(fi, "%d", &layer2_size);
622622
if (ver > 5) {
623623
goToDelimiter(':', fi);
624-
fscanf(fi, "%ld", &direct_size);
624+
fscanf(fi, "%lld", &direct_size);
625625
}
626626
if (ver > 6) {
627627
goToDelimiter(':', fi);
@@ -760,14 +760,14 @@ void CRnnLM::restoreNet() { // will read whole network structure
760760
}
761761
if (filetype == TEXT) {
762762
goToDelimiter(':', fi); // direct conenctions
763-
int64 aa;
763+
long long aa;
764764
for (aa = 0; aa < direct_size; aa++) {
765765
fscanf(fi, "%lf", &d);
766766
syn_d[aa] = d;
767767
}
768768
}
769769
if (filetype == BINARY) {
770-
int64 aa;
770+
long long aa;
771771
for (aa = 0; aa < direct_size; aa++) {
772772
fread(&fl, 4, 1, fi);
773773
syn_d[aa] = fl;
@@ -982,7 +982,7 @@ void CRnnLM::computeNet(int last_word, int word) {
982982

983983
// apply direct connections to classes
984984
if (direct_size > 0) {
985-
uint64 hash[MAX_NGRAM_ORDER];
985+
unsigned long long hash[MAX_NGRAM_ORDER];
986986
// this will hold pointers to syn_d that contains hash parameters
987987

988988
for (a = 0; a < direct_order; a++) {
@@ -997,7 +997,7 @@ void CRnnLM::computeNet(int last_word, int word) {
997997

998998
for (b = 1; b <= a; b++) {
999999
hash[a] += PRIMES[(a * PRIMES[b] + b) % PRIMES_SIZE]
1000-
* static_cast<uint64>(history[b - 1] + 1);
1000+
* static_cast<unsigned long long>(history[b - 1] + 1);
10011001
}
10021002
// update hash value based on words from the history
10031003

@@ -1061,7 +1061,7 @@ void CRnnLM::computeNet(int last_word, int word) {
10611061

10621062
// apply direct connections to words
10631063
if (word != -1) if (direct_size > 0) {
1064-
uint64 hash[MAX_NGRAM_ORDER];
1064+
unsigned long long hash[MAX_NGRAM_ORDER];
10651065

10661066
for (a = 0; a < direct_order; a++) {
10671067
hash[a] = 0;
@@ -1072,11 +1072,11 @@ void CRnnLM::computeNet(int last_word, int word) {
10721072
if (a > 0) if (history[a - 1] == -1) break;
10731073
hash[a] =
10741074
PRIMES[0] * PRIMES[1] *
1075-
static_cast<uint64>(vocab[word].class_index + 1);
1075+
static_cast<unsigned long long>(vocab[word].class_index + 1);
10761076

10771077
for (b = 1; b <= a; b++) {
10781078
hash[a] += PRIMES[(a * PRIMES[b] + b) % PRIMES_SIZE]
1079-
* static_cast<uint64>(history[b - 1] + 1);
1079+
* static_cast<unsigned long long>(history[b - 1] + 1);
10801080
}
10811081
hash[a] = (hash[a] % (direct_size / 2)) + (direct_size) / 2;
10821082
}

src/lm/mikolov-rnnlm-lib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class CRnnLM {
143143
int layerc_size;
144144
int layer2_size;
145145

146-
int64 direct_size;
146+
long long direct_size;
147147
int direct_order;
148148
int history[MAX_NGRAM_ORDER];
149149

0 commit comments

Comments
 (0)