Skip to content

Commit bb575f6

Browse files
update move_utils and RL_agent_util with vtr::RngContainer args
1 parent e1c7379 commit bb575f6

File tree

5 files changed

+86
-60
lines changed

5 files changed

+86
-60
lines changed

vpr/src/place/RL_agent_util.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
std::pair<std::unique_ptr<MoveGenerator>, std::unique_ptr<MoveGenerator>> create_move_generators(PlacerState& placer_state,
66
const t_placer_opts& placer_opts,
77
int move_lim,
8-
double noc_attraction_weight) {
8+
double noc_attraction_weight,
9+
vtr::RngContainer& rng) {
910
e_reward_function reward_fun = string_to_reward(placer_opts.place_reward_fun);
1011
std::pair<std::unique_ptr<MoveGenerator>, std::unique_ptr<MoveGenerator>> move_generators;
1112

@@ -66,12 +67,14 @@ std::pair<std::unique_ptr<MoveGenerator>, std::unique_ptr<MoveGenerator>> create
6667
VTR_LOG("Using simple RL 'Epsilon Greedy agent' for choosing move and block types\n");
6768
karmed_bandit_agent1 = std::make_unique<EpsilonGreedyAgent>(first_state_avail_moves,
6869
e_agent_space::MOVE_BLOCK_TYPE,
69-
placer_opts.place_agent_epsilon);
70+
placer_opts.place_agent_epsilon,
71+
rng);
7072
} else {
7173
VTR_LOG("Using simple RL 'Epsilon Greedy agent' for choosing move types\n");
7274
karmed_bandit_agent1 = std::make_unique<EpsilonGreedyAgent>(first_state_avail_moves,
7375
e_agent_space::MOVE_TYPE,
74-
placer_opts.place_agent_epsilon);
76+
placer_opts.place_agent_epsilon,
77+
rng);
7578
}
7679
karmed_bandit_agent1->set_step(placer_opts.place_agent_gamma, move_lim);
7780
move_generators.first = std::make_unique<SimpleRLMoveGenerator>(placer_state,
@@ -82,7 +85,8 @@ std::pair<std::unique_ptr<MoveGenerator>, std::unique_ptr<MoveGenerator>> create
8285
//agent's 2nd state
8386
karmed_bandit_agent2 = std::make_unique<EpsilonGreedyAgent>(second_state_avail_moves,
8487
e_agent_space::MOVE_TYPE,
85-
placer_opts.place_agent_epsilon);
88+
placer_opts.place_agent_epsilon,
89+
rng);
8690
karmed_bandit_agent2->set_step(placer_opts.place_agent_gamma, move_lim);
8791
move_generators.second = std::make_unique<SimpleRLMoveGenerator>(placer_state,
8892
reward_fun,
@@ -95,11 +99,13 @@ std::pair<std::unique_ptr<MoveGenerator>, std::unique_ptr<MoveGenerator>> create
9599
if (placer_opts.place_agent_space == e_agent_space::MOVE_BLOCK_TYPE) {
96100
VTR_LOG("Using simple RL 'Softmax agent' for choosing move and block types\n");
97101
karmed_bandit_agent1 = std::make_unique<SoftmaxAgent>(first_state_avail_moves,
98-
e_agent_space::MOVE_BLOCK_TYPE);
102+
e_agent_space::MOVE_BLOCK_TYPE,
103+
rng);
99104
} else {
100105
VTR_LOG("Using simple RL 'Softmax agent' for choosing move types\n");
101106
karmed_bandit_agent1 = std::make_unique<SoftmaxAgent>(first_state_avail_moves,
102-
e_agent_space::MOVE_TYPE);
107+
e_agent_space::MOVE_TYPE,
108+
rng);
103109
}
104110
karmed_bandit_agent1->set_step(placer_opts.place_agent_gamma, move_lim);
105111
move_generators.first = std::make_unique<SimpleRLMoveGenerator>(placer_state,
@@ -109,7 +115,8 @@ std::pair<std::unique_ptr<MoveGenerator>, std::unique_ptr<MoveGenerator>> create
109115
placer_opts.place_high_fanout_net);
110116
//agent's 2nd state
111117
karmed_bandit_agent2 = std::make_unique<SoftmaxAgent>(second_state_avail_moves,
112-
e_agent_space::MOVE_TYPE);
118+
e_agent_space::MOVE_TYPE,
119+
rng);
113120
karmed_bandit_agent2->set_step(placer_opts.place_agent_gamma, move_lim);
114121
move_generators.second = std::make_unique<SimpleRLMoveGenerator>(placer_state,
115122
reward_fun,

vpr/src/place/RL_agent_util.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ enum class e_agent_state {
2020
* @param move_lim represents the num of moves per temp.
2121
* @param noc_attraction_weight The attraction weight by which the NoC-biased centroid move adjust the computed location
2222
* towards reachable NoC routers from the moving block.
23+
* @param rng A reference to a random number generator to be used by move generators.
2324
*
2425
* @return Two unique pointers referring to move generators. These move generators are supposed to be used
2526
* in the first and second states of the agent.
@@ -28,7 +29,8 @@ enum class e_agent_state {
2829
std::pair<std::unique_ptr<MoveGenerator>, std::unique_ptr<MoveGenerator>> create_move_generators(PlacerState& placer_state,
2930
const t_placer_opts& placer_opts,
3031
int move_lim,
31-
double noc_attraction_weight);
32+
double noc_attraction_weight,
33+
vtr::RngContainer& rng);
3234

3335
/**
3436
* @brief copy one of the available move_generators to be the current move_generator that would be used in the placement based on the placer_options and the agent state

0 commit comments

Comments
 (0)