@@ -19,31 +19,160 @@ namespace hal
1919 class GateFeature
2020 {
2121 public:
22- virtual Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature (Context& ctx, const std::vector<Gate*>& gates) const = 0;
23- virtual std::string to_string () const = 0;
22+ virtual Result<std::vector<FEATURE_TYPE>> calculate_feature (Context& ctx, const Gate* g) const ;
23+ virtual Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature (Context& ctx, const std::vector<Gate*>& gates) const ;
24+ virtual std::string to_string () const = 0;
2425 };
2526
26- class GateFeatureSingle : public GateFeature
27+ // class GateFeatureSingle : public GateFeature
28+ // {
29+ // public:
30+ // virtual Result<std::vector<FEATURE_TYPE>> calculate_feature(Context& ctx, const Gate* g) const = 0;
31+ // virtual std::string to_string() const = 0;
32+
33+ // virtual Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature(Context& ctx, const std::vector<Gate*>& gates) const override;
34+ // };
35+
36+ // class GateFeature : public GateFeature
37+ // {
38+ // public:
39+ // virtual Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature(Context& ctx, const std::vector<Gate*>& gates) const = 0;
40+ // virtual std::string to_string() const = 0;
41+ // };
42+
43+ class ConnectedGlobalIOs : public GateFeature
44+ {
45+ public:
46+ ConnectedGlobalIOs (){};
47+
48+ Result<std::vector<FEATURE_TYPE>> calculate_feature (Context& ctx, const Gate* g) const override ;
49+ std::string to_string () const override ;
50+ };
51+
52+ class DistanceGlobalIO : public GateFeature
53+ {
54+ public:
55+ DistanceGlobalIO (const PinDirection& direction, const bool directed = true , const std::vector<PinType>& forbidden_pin_types = {})
56+ : m_direction(direction), m_directed(directed), m_forbidden_pin_types(forbidden_pin_types){};
57+
58+ Result<std::vector<FEATURE_TYPE>> calculate_feature (Context& ctx, const Gate* g) const override ;
59+ std::string to_string () const override ;
60+
61+ private:
62+ const PinDirection m_direction;
63+ const bool m_directed;
64+ const std::vector<PinType> m_forbidden_pin_types;
65+ };
66+
67+ class SequentialDistanceGlobalIO : public GateFeature
68+ {
69+ public:
70+ SequentialDistanceGlobalIO (const PinDirection& direction, const bool directed = true , const std::vector<PinType>& forbidden_pin_types = {})
71+ : m_direction(direction), m_directed(directed), m_forbidden_pin_types(forbidden_pin_types){};
72+
73+ Result<std::vector<FEATURE_TYPE>> calculate_feature (Context& ctx, const Gate* g) const override ;
74+ std::string to_string () const override ;
75+
76+ private:
77+ const PinDirection m_direction;
78+ const bool m_directed;
79+ const std::vector<PinType> m_forbidden_pin_types;
80+ };
81+
82+ class IODegrees : public GateFeature
83+ {
84+ public:
85+ IODegrees (){};
86+
87+ Result<std::vector<FEATURE_TYPE>> calculate_feature (Context& ctx, const Gate* g) const override ;
88+ std::string to_string () const override ;
89+ };
90+
91+ class GateTypeOneHot : public GateFeature
92+ {
93+ public:
94+ GateTypeOneHot (){};
95+
96+ Result<std::vector<FEATURE_TYPE>> calculate_feature (Context& ctx, const Gate* g) const override ;
97+ std::string to_string () const override ;
98+ };
99+
100+ class NeighboringGateTypes : public GateFeature
101+ {
102+ public:
103+ NeighboringGateTypes (const u32 depth, const PinDirection& direction, const bool directed = true ) : m_depth(depth), m_direction(direction), m_directed(directed){};
104+
105+ Result<std::vector<FEATURE_TYPE>> calculate_feature (Context& ctx, const Gate* g) const override ;
106+ std::string to_string () const override ;
107+
108+ private:
109+ const u32 m_depth;
110+ const PinDirection m_direction;
111+ const bool m_directed;
112+ };
113+
114+
115+ class BetweennessCentrality : public GateFeature
116+ {
117+ public:
118+ BetweennessCentrality (const bool directed = true , const i32 cutoff = -1 , const bool normalize = true ) : m_directed(directed), m_cutoff(cutoff), m_normalize(normalize){};
119+
120+ Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature (Context& ctx, const std::vector<Gate*>& gates) const override ;
121+ std::string to_string () const override ;
122+
123+ private:
124+ const bool m_directed;
125+ const i32 m_cutoff;
126+ const bool m_normalize;
127+ };
128+
129+ class HarmonicCentrality : public GateFeature
27130 {
28131 public:
29- virtual Result<std::vector<FEATURE_TYPE>> calculate_feature (Context& ctx, const Gate* g) const = 0;
30- virtual std::string to_string () const = 0;
132+ HarmonicCentrality (const PinDirection& direction, const i32 cutoff = -1 , const bool normalize = true ) : m_direction(direction), m_cutoff(cutoff), m_normalize(normalize){};
31133
32- virtual Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature (Context& ctx, const std::vector<Gate*>& gates) const override ;
134+ Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature (Context& ctx, const std::vector<Gate*>& gates) const override ;
135+ std::string to_string () const override ;
136+
137+ private:
138+ const PinDirection m_direction;
139+ const i32 m_cutoff;
140+ const bool m_normalize;
33141 };
34142
35- class GateFeatureBulk : public GateFeature
143+ class SequentialBetweennessCentrality : public GateFeature
36144 {
37145 public:
38- virtual Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature (Context& ctx, const std::vector<Gate*>& gates) const = 0;
39- virtual std::string to_string () const = 0;
146+ SequentialBetweennessCentrality (const bool directed = true , const i32 cutoff = -1 , const bool normalize = true ) : m_directed(directed), m_cutoff(cutoff), m_normalize(normalize){};
147+
148+ Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature (Context& ctx, const std::vector<Gate*>& gates) const override ;
149+ std::string to_string () const override ;
150+
151+ private:
152+ const bool m_directed;
153+ const i32 m_cutoff;
154+ const bool m_normalize;
155+ };
156+
157+ class SequentialHarmonicCentrality : public GateFeature
158+ {
159+ public:
160+ SequentialHarmonicCentrality (const PinDirection& direction, const i32 cutoff = -1 , const bool normalize = true ) : m_direction(direction), m_cutoff(cutoff), m_normalize(normalize){};
161+
162+ Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature (Context& ctx, const std::vector<Gate*>& gates) const override ;
163+ std::string to_string () const override ;
164+
165+ private:
166+ const PinDirection m_direction;
167+ const i32 m_cutoff;
168+ const bool m_normalize;
40169 };
41170
42- // Feature ideas
43171
44- // number of sequential predecessors/successors (this is somewhat encoded in the neighboring gate types)
172+ // Feature ideas:
173+ // - number of sequential predecessors/successors (this is somewhat encoded in the neighboring gate types)
45174
46- // distance to nearest type/module (e.g. RAM, DSP)
175+ // - distance to nearest type/module (e.g. RAM, DSP)
47176 // - distance to nearest shift register
48177 // - distance to nearest bus register
49178
0 commit comments