From f7f3eb5196d1614a7191e3c4b4e20710ba4446d4 Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Mon, 12 Mar 2018 13:38:46 +0100 Subject: [PATCH] Add a warning for networks with in-place layers. --- src/Simulator.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Simulator.cpp b/src/Simulator.cpp index 4745826..21cd0bb 100644 --- a/src/Simulator.cpp +++ b/src/Simulator.cpp @@ -33,6 +33,8 @@ struct Simulator::Impl void computeLayerInfo(); void loadMeans(const string &means_file); + + void ensureNoInPlaceLayers(); }; // Create simple forwarding functions. @@ -50,6 +52,7 @@ Simulator::Impl::Impl(const string& model_file, const string& weights_file, cons net(model_file, TEST) { net.CopyTrainedLayersFrom(weights_file); + ensureNoInPlaceLayers(); auto input_layer = net.input_blobs()[0]; input_geometry = cv::Size(input_layer->width(), input_layer->height()); @@ -206,6 +209,17 @@ void Simulator::Impl::computeLayerInfo() } } +void Simulator::Impl::ensureNoInPlaceLayers() +{ + auto blobList = net.top_vecs(); + typeof(blobList) uniqueVecs; + unique_copy(blobList.begin(), blobList.end(), back_inserter(uniqueVecs)); + + LOG_IF(ERROR, blobList.size() != uniqueVecs.size()) + << "Network file contains in-place layers, layer-state will not be accurate\n" + << "If accurate results are desired, see the deinplace script in tools." << endl; +} + Simulator::~Simulator() { // Empty but defined constructor.