Skip to content

Commit

Permalink
fix possible bug
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyAB committed Jul 4, 2021
1 parent 335ac66 commit be39852
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/convolutional_kernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ half *cuda_make_f16_from_f32_array(float *src, size_t n)

void forward_convolutional_layer_gpu(convolutional_layer l, network_state state)
{
state.train = l.train;
if (l.train == 0) state.train = 0;

if (l.stream >= 0) {
switch_stream(l.stream);
}
Expand Down
33 changes: 19 additions & 14 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1413,16 +1413,18 @@ network parse_network_cfg_custom(char *filename, int batch, int time_steps)
// find l.stopbackward = option_find_int_quiet(options, "stopbackward", 0);
node *n_tmp = n;
int count_tmp = 0;
while (n_tmp) {
s = (section *)n_tmp->val;
options = s->options;
int stopbackward = option_find_int_quiet(options, "stopbackward", 0);
if (stopbackward == 1) {
last_stop_backward = count_tmp;
printf("last_stop_backward = %d \n", last_stop_backward);
if (params.train == 1) {
while (n_tmp) {
s = (section *)n_tmp->val;
options = s->options;
int stopbackward = option_find_int_quiet(options, "stopbackward", 0);
if (stopbackward == 1) {
last_stop_backward = count_tmp;
printf("last_stop_backward = %d \n", last_stop_backward);
}
n_tmp = n_tmp->next;
++count_tmp;
}
n_tmp = n_tmp->next;
++count_tmp;
}

int old_params_train = params.train;
Expand Down Expand Up @@ -1700,15 +1702,18 @@ network parse_network_cfg_custom(char *filename, int batch, int time_steps)
for (k = 0; k < last_stop_backward; ++k) {
layer l = net.layers[k];
if (l.keep_delta_gpu) {
if (!l.delta) l.delta = (float*)xcalloc(l.outputs*l.batch, sizeof(float));
if (!l.delta) {
net.layers[k].delta = (float*)xcalloc(l.outputs*l.batch, sizeof(float));
}
#ifdef GPU
if (!l.delta_gpu) l.delta_gpu = (float *)cuda_make_array(NULL, l.outputs*l.batch);
if (!l.delta_gpu) {
net.layers[k].delta_gpu = (float *)cuda_make_array(NULL, l.outputs*l.batch);
}
#endif
}

l.onlyforward = 1;
l.train = 0;
net.layers[k] = l;
net.layers[k].onlyforward = 1;
net.layers[k].train = 0;
}
}

Expand Down

0 comments on commit be39852

Please sign in to comment.