Allow to sleep between layer forward in order to reduce load

This commit is contained in:
MathieuFavreau 2019-11-10 21:16:28 -05:00
parent 09f769097a
commit 8690ffdb9b
2 changed files with 11 additions and 0 deletions

View File

@ -486,6 +486,8 @@ typedef struct network{
float *cost;
float clip;
int sleep_between_layers_forward_us;
#ifdef GPU
float *input_gpu;
float *truth_gpu;

View File

@ -206,6 +206,9 @@ void forward_network(network *netp)
if(l.truth) {
net.truth = l.output;
}
if(net.sleep_between_layers_forward_us > 0){
usleep(net.sleep_between_layers_forward_us);
}
}
calc_network_cost(netp);
}
@ -788,6 +791,9 @@ void forward_network_gpu(network *netp)
net.truth_gpu = l.output_gpu;
net.truth = l.output;
}
if(net.sleep_between_layers_forward_us > 0){
usleep(net.sleep_between_layers_forward_us);
}
}
pull_network_output(netp);
calc_network_cost(netp);
@ -832,6 +838,9 @@ void forward_network_gpu_device_input(network *netp)
if(l.truth) {
net.truth_gpu = l.output_gpu;
}
if(net.sleep_between_layers_forward_us > 0){
usleep(net.sleep_between_layers_forward_us);
}
}
pull_network_output(netp);
calc_network_cost(netp);