Icemist commented on code in PR #12545:
URL: https://github.com/apache/tvm/pull/12545#discussion_r967756604


##########
python/tvm/autotvm/tuner/ga_tuner.py:
##########
@@ -49,41 +48,29 @@ def __init__(self, task, pop_size=100, elite_num=3, 
mutation_prob=0.1):
 
         assert elite_num <= pop_size, "The number of elites must be less than 
population size"
 
+        # random initialization
+        self.pop_size = min(self.pop_size, task.config_space.filtered_length)
+        self.elite_num = min(self.pop_size, self.elite_num)
+
         # space info
         self.space = task.config_space
-        self.dim_keys = []
-        self.dims = []
-        for k, v in self.space.space_map.items():
-            self.dim_keys.append(k)
-            self.dims.append(len(v))
-
-        self.visited = set([])
+        self.visited = set(self.space.sample_ints(self.pop_size))
 
         # current generation
-        self.genes = []
+        self.genes = [self.space.point2knob(idx) for idx in self.visited]
         self.scores = []
         self.elites = []
         self.elite_scores = []
         self.trial_pt = 0
 
-        # random initialization
-        self.pop_size = min(self.pop_size, len(self.space))
-        self.elite_num = min(self.pop_size, self.elite_num)
-        for _ in range(self.pop_size):
-            tmp_gene = point2knob(np.random.randint(len(self.space)), 
self.dims)
-            while knob2point(tmp_gene, self.dims) in self.visited:
-                tmp_gene = point2knob(np.random.randint(len(self.space)), 
self.dims)
-
-            self.genes.append(tmp_gene)
-            self.visited.add(knob2point(tmp_gene, self.dims))
-
     def next_batch(self, batch_size):
         ret = []
-        for _ in range(batch_size):
+        while len(ret) < batch_size and self.trial_pt < 
self.space.total_length:

Review Comment:
   You're partially right, there should be a filtered_length,  under the 
condition that it actually gets already filtered points. Right now it is.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to