Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / src / inference_engine / cnn_network_impl.cpp
index 620fe34..2918da1 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Intel Corporation
+// Copyright (C) 2018-2019 Intel Corporation
 // SPDX-License-Identifier: Apache-2.0
 //
 
@@ -22,6 +22,14 @@ using namespace InferenceEngine::details;
 CNNNetworkImpl::CNNNetworkImpl(): _targetDevice(TargetDevice::eDefault), _stats(new CNNNetworkStatsImpl()) {
 }
 
+CNNNetworkImpl::~CNNNetworkImpl() {
+    for (auto& data : _data) {
+        for (auto& input : data.second->getInputTo()) {
+            input.second.reset();
+        }
+    }
+}
+
 void CNNNetworkImpl::getOutputsInfo(std::map<std::string, DataPtr>& out) const noexcept {
     out = _outputData;
 }
@@ -34,6 +42,16 @@ void CNNNetworkImpl::addLayer(const CNNLayerPtr& layer) noexcept {
     _layers[layer->name] = layer;
 }
 
+void CNNNetworkImpl::removeLayer(const string& layerName) {
+    auto it = _layers.find(layerName);
+    if (it != _layers.end()) { _layers.erase(it); }
+}
+
+void CNNNetworkImpl::removeData(const string& dataName) {
+    auto it = _data.find(dataName);
+    if (it != _data.end()) { _data.erase(it); }
+}
+
 void CNNNetworkImpl::validate(int version) {
     if (version != 1) {
         std::set<std::string> layerNames;