Skip to content

Commit 548e7c8

Browse files
committed
clean up of single and bulk features
1 parent 1625b08 commit 548e7c8

File tree

10 files changed

+567
-482
lines changed

10 files changed

+567
-482
lines changed

plugins/gui/include/gui/plugin_relay/gui_plugin_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ namespace hal {
156156
void loadFeature(FacExtensionInterface::Feature ft, const QString& extension=QString());
157157
SupportedFileFormats listFacFeature(FacExtensionInterface::Feature ft) const;
158158
GuiPluginEntry* at(int irow) const;
159-
void addExternalPlugin(const QString& path);
159+
int addExternalPlugin(const QString& path);
160160
void removeEntry(int irow);
161161
};
162162

plugins/machine_learning/include/machine_learning/features/gate_feature.h

Lines changed: 141 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
1-
#pragma once
1+
// #pragma once
22

3-
#include "machine_learning/features/gate_feature.h"
3+
// #include "machine_learning/features/gate_feature.h"
44

5-
namespace hal
6-
{
7-
namespace machine_learning
8-
{
9-
namespace gate_feature
10-
{
11-
class BetweennessCentrality : public GateFeatureBulk
12-
{
13-
public:
14-
BetweennessCentrality(const bool directed = true, const i32 cutoff = -1, const bool normalize = true) : m_directed(directed), m_cutoff(cutoff), m_normalize(normalize){};
5+
// namespace hal
6+
// {
7+
// namespace machine_learning
8+
// {
9+
// namespace gate_feature
10+
// {
11+
// class BetweennessCentrality : public GateFeatureBulk
12+
// {
13+
// public:
14+
// BetweennessCentrality(const bool directed = true, const i32 cutoff = -1, const bool normalize = true) : m_directed(directed), m_cutoff(cutoff), m_normalize(normalize){};
1515

16-
Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature(Context& ctx, const std::vector<Gate*>& gates) const override;
17-
std::string to_string() const override;
16+
// Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature(Context& ctx, const std::vector<Gate*>& gates) const override;
17+
// std::string to_string() const override;
1818

19-
private:
20-
const bool m_directed;
21-
const i32 m_cutoff;
22-
const bool m_normalize;
23-
};
19+
// private:
20+
// const bool m_directed;
21+
// const i32 m_cutoff;
22+
// const bool m_normalize;
23+
// };
2424

25-
class HarmonicCentrality : public GateFeatureBulk
26-
{
27-
public:
28-
HarmonicCentrality(const PinDirection& direction, const i32 cutoff = -1, const bool normalize = true) : m_direction(direction), m_cutoff(cutoff), m_normalize(normalize){};
25+
// class HarmonicCentrality : public GateFeatureBulk
26+
// {
27+
// public:
28+
// HarmonicCentrality(const PinDirection& direction, const i32 cutoff = -1, const bool normalize = true) : m_direction(direction), m_cutoff(cutoff), m_normalize(normalize){};
2929

30-
Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature(Context& ctx, const std::vector<Gate*>& gates) const override;
31-
std::string to_string() const override;
30+
// Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature(Context& ctx, const std::vector<Gate*>& gates) const override;
31+
// std::string to_string() const override;
3232

33-
private:
34-
const PinDirection m_direction;
35-
const i32 m_cutoff;
36-
const bool m_normalize;
37-
};
33+
// private:
34+
// const PinDirection m_direction;
35+
// const i32 m_cutoff;
36+
// const bool m_normalize;
37+
// };
3838

39-
class SequentialBetweennessCentrality : public GateFeatureBulk
40-
{
41-
public:
42-
SequentialBetweennessCentrality(const bool directed = true, const i32 cutoff = -1, const bool normalize = true) : m_directed(directed), m_cutoff(cutoff), m_normalize(normalize){};
39+
// class SequentialBetweennessCentrality : public GateFeatureBulk
40+
// {
41+
// public:
42+
// SequentialBetweennessCentrality(const bool directed = true, const i32 cutoff = -1, const bool normalize = true) : m_directed(directed), m_cutoff(cutoff), m_normalize(normalize){};
4343

44-
Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature(Context& ctx, const std::vector<Gate*>& gates) const override;
45-
std::string to_string() const override;
44+
// Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature(Context& ctx, const std::vector<Gate*>& gates) const override;
45+
// std::string to_string() const override;
4646

47-
private:
48-
const bool m_directed;
49-
const i32 m_cutoff;
50-
const bool m_normalize;
51-
};
47+
// private:
48+
// const bool m_directed;
49+
// const i32 m_cutoff;
50+
// const bool m_normalize;
51+
// };
5252

53-
class SequentialHarmonicCentrality : public GateFeatureBulk
54-
{
55-
public:
56-
SequentialHarmonicCentrality(const PinDirection& direction, const i32 cutoff = -1, const bool normalize = true) : m_direction(direction), m_cutoff(cutoff), m_normalize(normalize){};
53+
// class SequentialHarmonicCentrality : public GateFeatureBulk
54+
// {
55+
// public:
56+
// SequentialHarmonicCentrality(const PinDirection& direction, const i32 cutoff = -1, const bool normalize = true) : m_direction(direction), m_cutoff(cutoff), m_normalize(normalize){};
5757

58-
Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature(Context& ctx, const std::vector<Gate*>& gates) const override;
59-
std::string to_string() const override;
58+
// Result<std::vector<std::vector<FEATURE_TYPE>>> calculate_feature(Context& ctx, const std::vector<Gate*>& gates) const override;
59+
// std::string to_string() const override;
6060

61-
private:
62-
const PinDirection m_direction;
63-
const i32 m_cutoff;
64-
const bool m_normalize;
65-
};
66-
} // namespace gate_feature
67-
} // namespace machine_learning
68-
} // namespace hal
61+
// private:
62+
// const PinDirection m_direction;
63+
// const i32 m_cutoff;
64+
// const bool m_normalize;
65+
// };
66+
// } // namespace gate_feature
67+
// } // namespace machine_learning
68+
// } // namespace hal

0 commit comments

Comments
 (0)