11#pragma once
22
33#include " hal_core/defines.h"
4- #include " hal_core/netlist/decorators/netlist_abstraction_decorator.h"
54#include " machine_learning/types.h"
65
76#include < optional>
@@ -17,28 +16,11 @@ namespace hal
1716 {
1817 namespace gate_pair_feature
1918 {
20-
21- struct FeatureContext
22- {
23- public:
24- FeatureContext () = delete ;
25- FeatureContext (const Netlist* netlist) : nl(netlist){};
26-
27- const Result<NetlistAbstraction*> get_original_abstraction ();
28- const Result<NetlistAbstraction*> get_sequential_abstraction ();
29-
30- const Netlist* nl;
31-
32- private:
33- std::optional<NetlistAbstraction> m_original_abstraction;
34- std::optional<NetlistAbstraction> m_seqential_abstraction;
35- };
36-
3719 class GatePairFeature
3820 {
3921 public:
40- virtual Result<std::vector<u32 >> calculate_feature (FeatureContext& fc , const Gate* g_a, const Gate* g_b) const = 0;
41- virtual std::string to_string () const = 0;
22+ virtual Result<std::vector<u32 >> calculate_feature (Context& ctx , const Gate* g_a, const Gate* g_b) const = 0;
23+ virtual std::string to_string () const = 0;
4224 };
4325
4426 class LogicalDistance : public GatePairFeature
@@ -47,7 +29,7 @@ namespace hal
4729 LogicalDistance (const PinDirection direction, const bool directed = true , const std::vector<PinType>& forbidden_pin_types = {})
4830 : m_direction(direction), m_directed(directed), m_forbidden_pin_types(forbidden_pin_types){};
4931
50- Result<std::vector<u32 >> calculate_feature (FeatureContext& fc , const Gate* g_a, const Gate* g_b) const override ;
32+ Result<std::vector<u32 >> calculate_feature (Context& ctx , const Gate* g_a, const Gate* g_b) const override ;
5133 std::string to_string () const override ;
5234
5335 private:
@@ -62,7 +44,7 @@ namespace hal
6244 SequentialDistance (const PinDirection direction, const bool directed = true , const std::vector<PinType>& forbidden_pin_types = {})
6345 : m_direction(direction), m_directed(directed), m_forbidden_pin_types(forbidden_pin_types){};
6446
65- Result<std::vector<u32 >> calculate_feature (FeatureContext& fc , const Gate* g_a, const Gate* g_b) const override ;
47+ Result<std::vector<u32 >> calculate_feature (Context& ctx , const Gate* g_a, const Gate* g_b) const override ;
6648 std::string to_string () const override ;
6749
6850 private:
@@ -76,7 +58,7 @@ namespace hal
7658 public:
7759 PhysicalDistance (){};
7860
79- Result<std::vector<u32 >> calculate_feature (FeatureContext& fc , const Gate* g_a, const Gate* g_b) const override ;
61+ Result<std::vector<u32 >> calculate_feature (Context& ctx , const Gate* g_a, const Gate* g_b) const override ;
8062 std::string to_string () const override ;
8163 };
8264
@@ -85,7 +67,7 @@ namespace hal
8567 public:
8668 SharedControlSignals (){};
8769
88- Result<std::vector<u32 >> calculate_feature (FeatureContext& fc , const Gate* g_a, const Gate* g_b) const override ;
70+ Result<std::vector<u32 >> calculate_feature (Context& ctx , const Gate* g_a, const Gate* g_b) const override ;
8971 std::string to_string () const override ;
9072 };
9173
@@ -99,7 +81,7 @@ namespace hal
9981 const std::vector<PinType>& forbidden_pin_types = {})
10082 : m_depth(depth), m_direction(direction), m_directed(directed), m_starting_pin_types(starting_pin_types), m_forbidden_pin_types(forbidden_pin_types){};
10183
102- Result<std::vector<u32 >> calculate_feature (FeatureContext& fc , const Gate* g_a, const Gate* g_b) const override ;
84+ Result<std::vector<u32 >> calculate_feature (Context& ctx , const Gate* g_a, const Gate* g_b) const override ;
10385 std::string to_string () const override ;
10486
10587 private:
@@ -120,7 +102,7 @@ namespace hal
120102 const std::vector<PinType>& forbidden_pin_types = {})
121103 : m_depth(depth), m_direction(direction), m_directed(directed), m_starting_pin_types(starting_pin_types), m_forbidden_pin_types(forbidden_pin_types){};
122104
123- Result<std::vector<u32 >> calculate_feature (FeatureContext& fc , const Gate* g_a, const Gate* g_b) const override ;
105+ Result<std::vector<u32 >> calculate_feature (Context& ctx , const Gate* g_a, const Gate* g_b) const override ;
124106 std::string to_string () const override ;
125107
126108 private:
@@ -132,13 +114,13 @@ namespace hal
132114 };
133115
134116 Result<std::vector<u32 >> build_feature_vec (const std::vector<const GatePairFeature*>& features, const Gate* g_a, const Gate* g_b);
135- Result<std::vector<u32 >> build_feature_vec (FeatureContext& fc , const std::vector<const GatePairFeature*>& features, const Gate* g_a, const Gate* g_b);
117+ Result<std::vector<u32 >> build_feature_vec (Context& ctx , const std::vector<const GatePairFeature*>& features, const Gate* g_a, const Gate* g_b);
136118
137119 Result<std::vector<u32 >> build_feature_vec (const std::vector<const GatePairFeature*>& features, const std::pair<Gate*, Gate*>& gate_pair);
138- Result<std::vector<u32 >> build_feature_vec (FeatureContext& fc , const std::vector<const GatePairFeature*>& features, const std::pair<Gate*, Gate*>& gate_pair);
120+ Result<std::vector<u32 >> build_feature_vec (Context& ctx , const std::vector<const GatePairFeature*>& features, const std::pair<Gate*, Gate*>& gate_pair);
139121
140122 Result<std::vector<std::vector<u32 >>> build_feature_vecs (const std::vector<const GatePairFeature*>& features, const std::vector<std::pair<Gate*, Gate*>>& gate_pairs);
141- Result<std::vector<std::vector<u32 >>> build_feature_vecs (FeatureContext& fc , const std::vector<const GatePairFeature*>& features, const std::vector<std::pair<Gate*, Gate*>>& gate_pairs);
123+ Result<std::vector<std::vector<u32 >>> build_feature_vecs (Context& ctx , const std::vector<const GatePairFeature*>& features, const std::vector<std::pair<Gate*, Gate*>>& gate_pairs);
142124 } // namespace gate_pair_feature
143125 } // namespace machine_learning
144126} // namespace hal
0 commit comments