Add a warning for networks with in-place layers.
This commit is contained in:
@@ -33,6 +33,8 @@ struct Simulator::Impl
|
|||||||
void computeLayerInfo();
|
void computeLayerInfo();
|
||||||
|
|
||||||
void loadMeans(const string &means_file);
|
void loadMeans(const string &means_file);
|
||||||
|
|
||||||
|
void ensureNoInPlaceLayers();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create simple forwarding functions.
|
// 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(model_file, TEST)
|
||||||
{
|
{
|
||||||
net.CopyTrainedLayersFrom(weights_file);
|
net.CopyTrainedLayersFrom(weights_file);
|
||||||
|
ensureNoInPlaceLayers();
|
||||||
|
|
||||||
auto input_layer = net.input_blobs()[0];
|
auto input_layer = net.input_blobs()[0];
|
||||||
input_geometry = cv::Size(input_layer->width(), input_layer->height());
|
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()
|
Simulator::~Simulator()
|
||||||
{
|
{
|
||||||
// Empty but defined constructor.
|
// Empty but defined constructor.
|
||||||
|
|||||||
Reference in New Issue
Block a user