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


##########
python/tvm/autotvm/task/space.py:
##########
@@ -822,6 +830,155 @@ def valid(self):
         """
         return not bool(self.errors)
 
+    def is_index_filtered(self, i):
+        """checks if the index satisfies the multi_filter"""
+        if self._shared_filter is None:
+            return True
+
+        if self._shared_filter_cash is None:
+            self._make_shared_filter_cash()
+
+        return self._shared_filter_cash[i]
+
+    def multi_filter(self, **kwargs):
+        "Keeps arg named 'filter'as function as a multi_filter"
+        if self._collect:
+            self._shared_filter_cash = None
+            self._filtered_length = 0
+            self._shared_filter = kwargs.get("filter", lambda x: True)
+
+    @property
+    def total_length(self):
+        """returns the count of the number of indexes"""
+        if self._total_length is None:
+            self._total_length = int(np.prod([len(x) for x in 
self.space_map.values()]))
+        return self._total_length
+
+    @property
+    def filtered_length(self):
+        """returns the count of the number of indexes satisfying the 
multifilter"""
+        if self._shared_filter is None:
+            return self.total_length
+
+        if self._shared_filter_cash is None:
+            self._make_shared_filter_cash()
+
+        return self._filtered_length
+
+    @property
+    def dims(self):
+        if self._dims is None:
+            self._dims = [len(x) for x in self.space_map.values()]
+        return self._dims
+
+    def filtered_within_range_length(self, s, e):
+        """returns the count of the number of indexes satisfying the 
multi_filter in the range"""
+        assert 0 <= s <= e <= self.total_length
+
+        if self._shared_filter is None:
+            return e - s
+        if self._shared_filter_cash is None:
+            self._make_shared_filter_cash()
+        return self.shared_filter_cash[s:e].count(True)

Review Comment:
   ```suggestion
           return self._shared_filter_cash[s:e].count(True)
   ```
   



-- 
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