13 #include <unordered_set> 27 class INFERENCE_ENGINE_INTERNAL("Migrate to IR v10 and work with
ngraph::Function directly. The method will be removed in 2021.1")
29 IE_SUPPRESS_DEPRECATED_START
31 std::unordered_set<CNNLayer*> visited;
32 std::list<CNNLayerPtr> nextLayersTovisit;
34 ICNNNetwork* network =
nullptr;
40 typedef std::forward_iterator_tag iterator_category;
42 typedef int difference_type;
49 CNNNetworkIterator() =
default;
55 explicit CNNNetworkIterator(
const ICNNNetwork* network) {
58 network->getInputsInfo(inputs);
59 if (!inputs.empty()) {
60 auto& nextLayers = inputs.begin()->second->getInputData()->getInputTo();
61 if (!nextLayers.empty()) {
62 currentLayer = nextLayers.begin()->second;
63 nextLayersTovisit.push_back(currentLayer);
64 visited.insert(currentLayer.get());
73 CNNNetworkIterator& operator++() {
74 currentLayer = next();
82 void operator++(
int) {
83 currentLayer = next();
91 bool operator!=(
const CNNNetworkIterator& that)
const {
92 return !operator==(that);
99 if (
nullptr == currentLayer) {
109 if (
nullptr == currentLayer) {
119 bool operator==(
const CNNNetworkIterator& that)
const {
120 return network == that.network && currentLayer == that.currentLayer;
128 if (nextLayersTovisit.empty()) {
132 auto nextLayer = nextLayersTovisit.front();
133 nextLayersTovisit.pop_front();
136 for (
auto&& output : nextLayer->outData) {
137 for (
auto&& child : output->getInputTo()) {
138 if (visited.find(child.second.get()) == visited.end()) {
139 nextLayersTovisit.push_back(child.second);
140 visited.insert(child.second.get());
146 for (
auto&& parent : nextLayer->insData) {
147 auto parentLayer = parent.lock()->getCreatorLayer().lock();
148 if (parentLayer && visited.find(parentLayer.get()) == visited.end()) {
149 nextLayersTovisit.push_back(parentLayer);
150 visited.insert(parentLayer.get());
154 return nextLayersTovisit.empty() ?
nullptr : nextLayersTovisit.front();
157 IE_SUPPRESS_DEPRECATED_END
#define THROW_IE_EXCEPTION
A macro used to throw the exception with a notable description.
Definition: ie_exception.hpp:25
Definition: cldnn_config.hpp:16
std::shared_ptr< CNNLayer > CNNLayerPtr
A smart pointer to the CNNLayer.
Definition: ie_common.h:39
This is a header file for the ICNNNetwork class.
Definition: ie_cnn_network.h:27
A header file for generic LockedMemory<> and different variations of locks.
The macro defines a symbol import/export mechanism essential for Microsoft Windows(R) OS...