|
4 | 4 | from hal_plugins import machine_learning
|
5 | 5 |
|
6 | 6 | # Create the feature context with the netlist
|
7 |
| -fc = machine_learning.gate_feature.FeatureContext(netlist) |
| 7 | +fc = machine_learning.Context(netlist) |
8 | 8 |
|
9 |
| -# Instantiate all available gate pair features |
10 |
| -connected_global_ios = machine_learning.gate_feature.ConnectedGlobalIOs() |
11 |
| -distance_global_io = machine_learning.gate_feature.DistanceGlobalIO(hal_py.PinDirection.output) |
12 |
| -sequnetial_distance_global_io = machine_learning.gate_feature.SequentialDistanceGlobalIO(hal_py.PinDirection.output) |
13 |
| -io_degrees = machine_learning.gate_feature.IODegrees() |
14 |
| -gate_type_one_hot = machine_learning.gate_feature.GateTypeOneHot() |
15 |
| -neighboring_gate_types = machine_learning.gate_feature.NeighboringGateTypes(2, hal_py.PinDirection.output) |
16 | 9 |
|
17 |
| -# Collect all features into a list |
18 | 10 | features = [
|
19 |
| - connected_global_ios, |
20 |
| - distance_global_io, |
21 |
| - #sequnetial_distance_global_io, |
22 |
| - io_degrees, |
23 |
| - #gate_type_one_hot, |
24 |
| - #neighboring_gate_types, |
| 11 | + machine_learning.GateFeature.GateFeatureSingle.ConnectedGlobalIOs(), |
| 12 | + |
| 13 | + machine_learning.GateFeature.GateFeatureSingle.DistanceGlobalIO(hal_py.PinDirection.output, directed=True, forbidden_pin_types=[hal_py.PinType.clock, hal_py.PinType.reset, hal_py.PinType.enable]), |
| 14 | + machine_learning.GateFeature.GateFeatureSingle.DistanceGlobalIO(hal_py.PinDirection.output, directed=False, forbidden_pin_types=[hal_py.PinType.clock, hal_py.PinType.reset, hal_py.PinType.enable]), |
| 15 | + machine_learning.GateFeature.GateFeatureSingle.DistanceGlobalIO(hal_py.PinDirection.input, directed=True, forbidden_pin_types=[hal_py.PinType.clock, hal_py.PinType.reset, hal_py.PinType.enable]), |
| 16 | + machine_learning.GateFeature.GateFeatureSingle.DistanceGlobalIO(hal_py.PinDirection.input, directed=False, forbidden_pin_types=[hal_py.PinType.clock, hal_py.PinType.reset, hal_py.PinType.enable]), |
| 17 | + |
| 18 | + machine_learning.GateFeature.GateFeatureSingle.SequentialDistanceGlobalIO(hal_py.PinDirection.output, directed=True, forbidden_pin_types=[hal_py.PinType.clock, hal_py.PinType.reset, hal_py.PinType.enable]), |
| 19 | + machine_learning.GateFeature.GateFeatureSingle.SequentialDistanceGlobalIO(hal_py.PinDirection.output, directed=False, forbidden_pin_types=[hal_py.PinType.clock, hal_py.PinType.reset, hal_py.PinType.enable]), |
| 20 | + machine_learning.GateFeature.GateFeatureSingle.SequentialDistanceGlobalIO(hal_py.PinDirection.input, directed=True, forbidden_pin_types=[hal_py.PinType.clock, hal_py.PinType.reset, hal_py.PinType.enable]), |
| 21 | + machine_learning.GateFeature.GateFeatureSingle.SequentialDistanceGlobalIO(hal_py.PinDirection.input, directed=False, forbidden_pin_types=[hal_py.PinType.clock, hal_py.PinType.reset, hal_py.PinType.enable]), |
| 22 | + |
| 23 | + machine_learning.GateFeature.GateFeatureSingle.IODegrees(), |
| 24 | + |
| 25 | + machine_learning.GateFeature.GateFeatureSingle.GateTypeOneHot(), |
| 26 | + |
| 27 | + machine_learning.GateFeature.GateFeatureSingle.NeighboringGateTypes(1, hal_py.PinDirection.output, directed=True), |
| 28 | + machine_learning.GateFeature.GateFeatureSingle.NeighboringGateTypes(2, hal_py.PinDirection.output, directed=True), |
| 29 | + machine_learning.GateFeature.GateFeatureSingle.NeighboringGateTypes(3, hal_py.PinDirection.output, directed=True), |
| 30 | + |
| 31 | + machine_learning.GateFeature.GateFeatureSingle.NeighboringGateTypes(1, hal_py.PinDirection.input, directed=True), |
| 32 | + machine_learning.GateFeature.GateFeatureSingle.NeighboringGateTypes(2, hal_py.PinDirection.input, directed=True), |
| 33 | + machine_learning.GateFeature.GateFeatureSingle.NeighboringGateTypes(3, hal_py.PinDirection.input, directed=True), |
| 34 | + |
| 35 | + machine_learning.GateFeature.GateFeatureBulk.BetweennessCentrality(directed = True, cutoff=-1), |
| 36 | + machine_learning.GateFeature.GateFeatureBulk.BetweennessCentrality(directed = True, cutoff=16), |
| 37 | + machine_learning.GateFeature.GateFeatureBulk.BetweennessCentrality(directed = False, cutoff=-1), |
| 38 | + machine_learning.GateFeature.GateFeatureBulk.BetweennessCentrality(directed = False, cutoff=16), |
| 39 | + machine_learning.GateFeature.GateFeatureBulk.SequentialBetweennessCentrality(directed = True, cutoff=-1), |
| 40 | + machine_learning.GateFeature.GateFeatureBulk.SequentialBetweennessCentrality(directed = True, cutoff=16), |
| 41 | + machine_learning.GateFeature.GateFeatureBulk.SequentialBetweennessCentrality(directed = False, cutoff=-1), |
| 42 | + machine_learning.GateFeature.GateFeatureBulk.SequentialBetweennessCentrality(directed = False, cutoff=16), |
| 43 | + |
| 44 | + machine_learning.GateFeature.GateFeatureBulk.HarmonicCentrality(direction=hal_py.PinDirection.output, cutoff=-1), |
| 45 | + machine_learning.GateFeature.GateFeatureBulk.HarmonicCentrality(direction=hal_py.PinDirection.output, cutoff=16), |
| 46 | + machine_learning.GateFeature.GateFeatureBulk.HarmonicCentrality(direction=hal_py.PinDirection.inout, cutoff=-1), |
| 47 | + machine_learning.GateFeature.GateFeatureBulk.HarmonicCentrality(direction=hal_py.PinDirection.inout, cutoff=16), |
| 48 | + machine_learning.GateFeature.GateFeatureBulk.SequentialHarmonicCentrality(direction=hal_py.PinDirection.output, cutoff=-1), |
| 49 | + machine_learning.GateFeature.GateFeatureBulk.SequentialHarmonicCentrality(direction=hal_py.PinDirection.output, cutoff=16), |
| 50 | + machine_learning.GateFeature.GateFeatureBulk.SequentialHarmonicCentrality(direction=hal_py.PinDirection.inout, cutoff=-1), |
| 51 | + machine_learning.GateFeature.GateFeatureBulk.SequentialHarmonicCentrality(direction=hal_py.PinDirection.inout, cutoff=16), |
25 | 52 | ]
|
26 | 53 |
|
27 |
| -gate_a = netlist.get_gate_by_id(21) |
| 54 | +#gates = [netlist.get_gate_by_id(21)] |
| 55 | +gates = netlist.get_gates(lambda g: g.type.has_property(hal_py.sequential)) |
28 | 56 |
|
29 | 57 | # Build the feature vector for the pair of gates
|
30 |
| -feature_vector = machine_learning.gate_feature.build_feature_vec(fc, features, gate_a) |
| 58 | +feature_vector = machine_learning.gate_feature.build_feature_vecs(fc, features, gates) |
31 | 59 |
|
32 | 60 | print("Feature vector:", feature_vector)
|
0 commit comments