fused_names_attribute.hpp
Go to the documentation of this file.
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 /**
6  * @brief Defines fused names attribute
7  * @file fused_names_attribute.hpp
8  */
9 
10 #include <assert.h>
11 #include <functional>
12 #include <memory>
13 #include <string>
14 #include <set>
15 
16 #include <ngraph/node.hpp>
17 #include <ngraph/variant.hpp>
18 #include <transformations_visibility.hpp>
19 
20 
21 namespace ngraph {
22 
23 /**
24  * @ingroup ie_runtime_attr_api
25  * @brief FusedName class represents runtime info attribute that stores
26  * all operation names that was fully or partially fused into node
27  */
28 class TRANSFORMATIONS_API FusedNames {
29 private:
30  std::set<std::string> fused_names;
31 
32 public:
33  /**
34  * A default constructor
35  */
36  FusedNames() = default;
37 
38  /**
39  * @brief Constructs a new object consisting of a single name *
40  * @param[in] name The name
41  */
42  explicit FusedNames(const std::string &name) {
43  fused_names.insert(name);
44  }
45 
46  /**
47  * @brief Unites current set of already fused names with another FusedNames object
48  * @param[in] names Another object to fuse with
49  */
50  void fuseWith(const FusedNames &names);
51 
52  /**
53  * @brief return string with operation names separated by coma in alphabetical order
54  */
55  std::string getNames() const;
56 
57  /**
58  * @brief return vector of fused names sorted in alphabetical order
59  * @return vector if strings
60  */
61  std::vector<std::string> getVectorNames() const;
62 };
63 
64 extern template class TRANSFORMATIONS_API VariantImpl<FusedNames>;
65 
66 template<>
67 class TRANSFORMATIONS_API VariantWrapper<FusedNames> : public VariantImpl<FusedNames> {
68 public:
69  static constexpr VariantTypeInfo type_info{"Variant::RuntimeAttribute::FusedNames", 0};
70 
71  const VariantTypeInfo &get_type_info() const override {
72  return type_info;
73  }
74 
75  VariantWrapper(const value_type &value) : VariantImpl<value_type>(value) {}
76 
77  std::shared_ptr<ngraph::Variant> merge(const ngraph::NodeVector & nodes) override;
78 
79  std::shared_ptr<ngraph::Variant> init(const std::shared_ptr<ngraph::Node> & node) override;
80 };
81 
82 /**
83  * @ingroup ie_runtime_attr_api
84  * @brief getFusedNames return string with operation names separated by coma in alphabetical order
85  * @param[in] node The node will be used to get FusedNames attribute
86  */
87 TRANSFORMATIONS_API std::string getFusedNames(const std::shared_ptr<ngraph::Node> & node);
88 
89 /**
90  * @ingroup ie_runtime_attr_api
91  * @brief getFusedNamesVector return vector of fused names sorted in alphabetical order
92  * @param[in] node The node will be used to get FusedNames attribute
93  * @return vector of strings
94  */
95 TRANSFORMATIONS_API std::vector<std::string> getFusedNamesVector(const std::shared_ptr<ngraph::Node> & node);
96 
97 } // namespace ngraph
FusedName class represents runtime info attribute that stores all operation names that was fully or p...
Definition: fused_names_attribute.hpp:28
std::vector< std::string > getVectorNames() const
return vector of fused names sorted in alphabetical order
std::string getNames() const
return string with operation names separated by coma in alphabetical order
FusedNames()=default
void fuseWith(const FusedNames &names)
Unites current set of already fused names with another FusedNames object.
FusedNames(const std::string &name)
Constructs a new object consisting of a single name *.
Definition: fused_names_attribute.hpp:42
Definition: fused_names_attribute.hpp:67
ngraph namespace
Definition: add_fake_quantize_fusion.hpp:14
std::vector< std::string > getFusedNamesVector(const std::shared_ptr< ngraph::Node > &node)
getFusedNamesVector return vector of fused names sorted in alphabetical order
std::string getFusedNames(const std::shared_ptr< ngraph::Node > &node)
getFusedNames return string with operation names separated by coma in alphabetical order