TVM  0.9.4
Inputs.h
Go to the documentation of this file.
1 
3 #pragma once
4 
6 
7 #include <memory>
8 #include <set>
9 #include <unordered_map>
10 #include <unordered_set>
11 
12 namespace tvm
13 {
14 
15 namespace graph
16 {
17 
18 class CallGraph;
19 
20 namespace internal
21 {
22 
25 {
26 public:
27  friend class tvm::graph::CallGraph;
28 
29  virtual ~Inputs() = default;
30 
32  using inputs_t = std::unordered_map<abstract::Outputs *, std::set<int>>;
34  using store_t = std::unordered_set<std::shared_ptr<abstract::Outputs>>;
35 
40  struct TVM_DLLAPI Iterator : public inputs_t::iterator
41  {
43  Iterator(inputs_t::iterator it, inputs_t::iterator end);
45  operator bool();
46 
47  private:
48  inputs_t::iterator end_;
49  };
50 
52  template<typename T, typename EnumI, typename... Args>
53  void addInput(std::shared_ptr<T> source, EnumI i, Args... args);
54 
59  template<typename T,
60  typename EnumI,
61  typename... Args,
62  typename std::enable_if<std::is_base_of<abstract::Outputs, T>::value, int>::type = 0>
63  void addInput(T & source, EnumI i, Args... args);
65  template<typename T>
66  void removeInput(T * source);
68  template<typename T, typename... Args>
69  void removeInput(T * source, Args... args);
71  template<typename T>
72  Iterator getInput(T * source);
74  template<typename T>
75  Iterator getInput(const std::shared_ptr<T> & source);
76 
77 private:
79  void removeInput(Iterator it, abstract::Outputs * source);
80  inputs_t inputs_;
81  store_t store_;
83  template<typename T, typename EnumI>
84  void addInput(T * source, EnumI i);
86  template<typename T>
87  void addInput(T &)
88  {}
89 };
90 
91 } // namespace internal
92 
93 } // namespace graph
94 
95 } // namespace tvm
96 
97 #include "Inputs.hpp"
#define TVM_DLLAPI
Definition: api.h:35
Definition: CallGraph.h:23
Definition: Outputs.h:31
Definition: Inputs.h:25
void addInput(std::shared_ptr< T > source, EnumI i, Args... args)
void removeInput(T *source, Args... args)
std::unordered_map< abstract::Outputs *, std::set< int > > inputs_t
Definition: Inputs.h:32
void addInput(T &source, EnumI i, Args... args)
Iterator getInput(T *source)
std::unordered_set< std::shared_ptr< abstract::Outputs > > store_t
Definition: Inputs.h:34
Iterator getInput(const std::shared_ptr< T > &source)
virtual ~Inputs()=default
Definition: Clock.h:12
Iterator(inputs_t::iterator it, inputs_t::iterator end)