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 2020.3")
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) {
57 network->getInputsInfo(inputs);
58 if (!inputs.empty()) {
59 auto& nextLayers = inputs.begin()->second->getInputData()->getInputTo();
60 if (!nextLayers.empty()) {
61 currentLayer = nextLayers.begin()->second;
62 nextLayersTovisit.push_back(currentLayer);
63 visited.insert(currentLayer.get());
72 CNNNetworkIterator& operator++() {
73 currentLayer = next();
81 void operator++(
int) {
82 currentLayer = next();
90 bool operator!=(
const CNNNetworkIterator& that)
const {
91 return !operator==(that);
98 if (
nullptr == currentLayer) {
108 if (
nullptr == currentLayer) {
118 bool operator==(
const CNNNetworkIterator& that)
const {
119 return network == that.network && currentLayer == that.currentLayer;
127 if (nextLayersTovisit.empty()) {
131 auto nextLayer = nextLayersTovisit.front();
132 nextLayersTovisit.pop_front();
135 for (
auto&& output : nextLayer->outData) {
136 for (
auto&& child : output->getInputTo()) {
137 if (visited.find(child.second.get()) == visited.end()) {
138 nextLayersTovisit.push_back(child.second);
139 visited.insert(child.second.get());
145 for (
auto&& parent : nextLayer->insData) {
146 auto parentLayer = parent.lock()->getCreatorLayer().lock();
147 if (parentLayer && visited.find(parentLayer.get()) == visited.end()) {
148 nextLayersTovisit.push_back(parentLayer);
149 visited.insert(parentLayer.get());
153 return nextLayersTovisit.empty() ?
nullptr : nextLayersTovisit.front();
156 IE_SUPPRESS_DEPRECATED_END
#define THROW_IE_EXCEPTION
A macro used to throw the exception with a notable description.
Definition: ie_exception.hpp:25
Inference Engine API.
Definition: ie_argmax_layer.hpp:15
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.
std::shared_ptr< CNNLayer > CNNLayerPtr
A smart pointer to the CNNLayer.
Definition: ie_common.h:39
The macro defines a symbol import/export mechanism essential for Microsoft Windows(R) OS...
std::map< std::string, InputInfo::Ptr > InputsDataMap
A collection that contains string as key, and InputInfo smart pointer as value.
Definition: ie_input_info.hpp:160