Commit 9d592140 authored by Juha Reunanen's avatar Juha Reunanen Committed by Davis E. King

Add get_net parameter that allows to call the function without forcing flush to disk (#875)

* Add get_net parameter allowing to call the function without forced flush to disk (see the discussion in #869)

* A blindfolded attempt to fix compile error on the CI server
parent f467236c
......@@ -55,6 +55,10 @@ namespace dlib
}
}
enum class force_flush_to_disk {
no = 0,
yes = 1
};
template <
typename net_type,
......@@ -135,10 +139,11 @@ namespace dlib
}
net_type& get_net (
force_flush_to_disk force_flush = force_flush_to_disk::yes
)
{
wait_for_thread_to_pause();
sync_to_disk(true);
sync_to_disk(force_flush == force_flush_to_disk::yes);
propagate_exception();
return net;
}
......
......@@ -12,6 +12,13 @@
namespace dlib
{
// ----------------------------------------------------------------------------------------
enum class force_flush_to_disk {
no = 0,
yes = 1
};
// ----------------------------------------------------------------------------------------
template <
......@@ -92,6 +99,7 @@ namespace dlib
!*/
net_type& get_net (
force_flush_to_disk force_flush = force_flush_to_disk::yes
);
/*!
ensures
......@@ -102,8 +110,9 @@ namespace dlib
dnn_trainer's constructor.
- This function blocks until all threads inside the dnn_trainer have
stopped touching the net.
- This function will sync the trainer state to disk if the current state
hasn't already been synced to disk since the last network modification.
- If force_flush is yes, then this function will sync the trainer state to
disk if the current state hasn't already been synced to disk since the
last network modification.
!*/
const std::vector<solver_type>& get_solvers (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment