Skip to content

Commit

Permalink
fix calloc realloc failure
Browse files Browse the repository at this point in the history
  • Loading branch information
cyyever committed Sep 13, 2019
1 parent 011eed6 commit f10c84c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/avgpool_layer.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "avgpool_layer.h"
#include "dark_cuda.h"
#include "utils.h"
#include <stdio.h>

avgpool_layer make_avgpool_layer(int batch, int w, int h, int c)
Expand Down
1 change: 1 addition & 0 deletions src/batchnorm_layer.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "batchnorm_layer.h"
#include "blas.h"
#include "utils.h"
#include <stdio.h>

layer make_batchnorm_layer(int batch, int w, int h, int c)
Expand Down
3 changes: 2 additions & 1 deletion src/blas.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "blas.h"
#include "utils.h"

#include <math.h>
#include <assert.h>
Expand Down Expand Up @@ -358,4 +359,4 @@ void fix_nan_and_inf_cpu(float *input, size_t size)
if (isnan(val) || isinf(val))
input[i] = 1.0f / i; // pseudo random value
}
}
}
12 changes: 6 additions & 6 deletions src/gru_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,36 @@ layer make_gru_layer(int batch, int inputs, int outputs, int steps, int batch_no
l.steps = steps;
l.inputs = inputs;

l.input_z_layer = (layer*)malloc(sizeof(layer));
l.input_z_layer = (layer*)xcalloc(1,sizeof(layer));
fprintf(stderr, "\t\t");
*(l.input_z_layer) = make_connected_layer(batch, steps, inputs, outputs, LINEAR, batch_normalize);
l.input_z_layer->batch = batch;

l.state_z_layer = (layer*)malloc(sizeof(layer));
l.state_z_layer = (layer*)xcalloc(1,sizeof(layer));
fprintf(stderr, "\t\t");
*(l.state_z_layer) = make_connected_layer(batch, steps, outputs, outputs, LINEAR, batch_normalize);
l.state_z_layer->batch = batch;



l.input_r_layer = (layer*)malloc(sizeof(layer));
l.input_r_layer = (layer*)xcalloc(1,sizeof(layer));
fprintf(stderr, "\t\t");
*(l.input_r_layer) = make_connected_layer(batch, steps, inputs, outputs, LINEAR, batch_normalize);
l.input_r_layer->batch = batch;

l.state_r_layer = (layer*)malloc(sizeof(layer));
l.state_r_layer = (layer*)xcalloc(1,sizeof(layer));
fprintf(stderr, "\t\t");
*(l.state_r_layer) = make_connected_layer(batch, steps, outputs, outputs, LINEAR, batch_normalize);
l.state_r_layer->batch = batch;



l.input_h_layer = (layer*)malloc(sizeof(layer));
l.input_h_layer = (layer*)xcalloc(1,sizeof(layer));
fprintf(stderr, "\t\t");
*(l.input_h_layer) = make_connected_layer(batch, steps, inputs, outputs, LINEAR, batch_normalize);
l.input_h_layer->batch = batch;

l.state_h_layer = (layer*)malloc(sizeof(layer));
l.state_h_layer = (layer*)xcalloc(1,sizeof(layer));
fprintf(stderr, "\t\t");
*(l.state_h_layer) = make_connected_layer(batch, steps, outputs, outputs, LINEAR, batch_normalize);
l.state_h_layer->batch = batch;
Expand Down

0 comments on commit f10c84c

Please sign in to comment.