1 // Copyright (C) 2018 Intel Corporation
3 // SPDX-License-Identifier: Apache-2.0
6 #include "graph_tools.hpp"
7 #include "details/ie_cnn_network_tools.h"
12 namespace InferenceEngine {
15 std::vector<CNNLayerPtr> CNNNetSortTopologically(const ICNNNetwork & network) {
16 std::vector<CNNLayerPtr> stackOfVisited;
17 bool res = CNNNetForestDFS(CNNNetGetAllInputLayers(network), [&](CNNLayerPtr current){
18 stackOfVisited.push_back(current);
22 THROW_IE_EXCEPTION << "Sorting not possible, due to existed loop.";
25 std::reverse(std::begin(stackOfVisited), std::end(stackOfVisited));
27 return stackOfVisited;
30 } // namespace details
31 } // namespace InferenceEngine