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.