1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * @brief a header file with common functions for graph transformation
7 * @file graph_transformer.h
15 #include <ie_icnn_network.hpp>
16 #include <details/caseless.hpp>
17 #include "cnn_network_impl.hpp"
19 namespace InferenceEngine {
24 class INFERENCE_ENGINE_API_CLASS(ConstTransformer) {
26 explicit ConstTransformer(details::CNNNetworkImpl* _network) {
27 if (!_network) THROW_IE_EXCEPTION << "[ERROR]: Failed to init ConstTransformer with null pointer of network";
29 cnnNetwork = CNNNetwork(network);
33 * @brief calculates const layers, combines const subgraph into a single const layers
35 void foldConstSubgraphs();
38 * @brief folds Const Subgraphs and removes second input of Reshape-like layers (Interp, Gather, Resample, ...)
44 * @brief collect all const layers with marking if it defines shape (1 - for shape, 0 - otherwise)
46 virtual const std::map<std::string, bool> getConstLayers(const std::vector<CNNLayerPtr>& sortedLayers);
52 getConstData(const std::map<std::string, bool>& constLayers, const std::vector<CNNLayerPtr>& sortedLayers);
57 virtual std::vector<std::string>
58 foldConstSubgraphsInternal(const std::map<std::string, bool>& constLayers, const BlobMap& constData,
59 const std::vector<CNNLayerPtr>& sortedLayers);
64 virtual void trimShapeInputs(const std::vector<std::string>& constLayers);
67 const details::caseless_set<std::string> shapeTaking = {"Reshape", "Resample", "Interp"};
68 details::CNNNetworkImpl* network;
69 CNNNetwork cnnNetwork;
72 } // namespace InferenceEngine