From 8690ffdb9b9b3df40ac081d8120048bffcfccb9b Mon Sep 17 00:00:00 2001 From: MathieuFavreau Date: Sun, 10 Nov 2019 21:16:28 -0500 Subject: [PATCH] Allow to sleep between layer forward in order to reduce load --- include/darknet.h | 2 ++ src/network.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/include/darknet.h b/include/darknet.h index 79d2feff..83110de0 100644 --- a/include/darknet.h +++ b/include/darknet.h @@ -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; diff --git a/src/network.c b/src/network.c index 338ceed5..410e5cbf 100644 --- a/src/network.c +++ b/src/network.c @@ -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);