Skip to content

Commit 1fe65b0

Browse files
Russell StewartRussell Stewart
authored andcommitted
Merge pull request #2 from SergeyDidenko/patch-1
Fixed memory allocation bugs: no space for biases
2 parents cfc29a4 + af4039a commit 1fe65b0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/glove.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ void initialize_parameters() {
6464
vector_size++; // Temporarily increment to allocate space for bias
6565

6666
/* Allocate space for word vectors and context word vectors, and correspodning gradsq */
67-
a = posix_memalign((void **)&W, 128, 2 * vocab_size * vector_size * sizeof(real)); // Might perform better than malloc
67+
a = posix_memalign((void **)&W, 128, 2 * vocab_size * (vector_size + 1) * sizeof(real)); // Might perform better than malloc
6868
if (W == NULL) {
6969
fprintf(stderr, "Error allocating memory for W\n");
7070
exit(1);
7171
}
72-
a = posix_memalign((void **)&gradsq, 128, 2 * vocab_size * vector_size * sizeof(real)); // Might perform better than malloc
72+
a = posix_memalign((void **)&gradsq, 128, 2 * vocab_size * (vector_size + 1) * sizeof(real)); // Might perform better than malloc
7373
if (gradsq == NULL) {
7474
fprintf(stderr, "Error allocating memory for gradsq\n");
7575
exit(1);

0 commit comments

Comments
 (0)