FranckQC commented on code in PR #11574:
URL: https://github.com/apache/tvm/pull/11574#discussion_r890360708


##########
src/tir/transforms/common_subexpr_elim_tools.cc:
##########
@@ -822,17 +886,19 @@ void 
InsertElemToSortedSemanticComputations(std::vector<std::pair<PrimExpr, size
           decreasing size of the expression) and maintain the vector sorted 
while doing so.
  */
 void InsertVectorToSortedSemanticComputations(std::vector<std::pair<PrimExpr, 
size_t>>* sorted_vec,
-                                              const std::vector<PrimExpr>& 
vec_to_add) {
+                                              const std::vector<PrimExpr>& 
vec_to_add,
+                                              bool identify_equiv_terms) {
   if (sorted_vec == nullptr) {
     return;
   }
   for (auto elem_to_add : vec_to_add) {
     // See if the current element to add (or an equivalent one) is already 
present
     // in the sorted vector
-    auto it_found = std::find_if(sorted_vec->begin(), sorted_vec->end(),
-                                 [elem_to_add](std::pair<PrimExpr, size_t> 
elem) {
-                                   return EquivalentTerms(elem.first, 
elem_to_add);
-                                 });
+    auto it_found =
+        std::find_if(sorted_vec->begin(), sorted_vec->end(),
+                     [elem_to_add, identify_equiv_terms](std::pair<PrimExpr, 
size_t> elem) {
+                       return EquivalentTerms(elem.first, elem_to_add, 
identify_equiv_terms);
+                     });

Review Comment:
   Some context:
   At this stage, we have a small vector (`vec_to_add`), that has been 
generated by looking at the "direct subexpression" of a term (which wasn't 
eligible for being introduced with a let-in, so we look at its direct 
subexpressions), and that we want to add to the (sorted) vector of 
computations, for consideration.
   
   So regardless of if we use the strict equality or the more flexible 
equivalence, we need to look into `sorted_vec `and to see if there's a term 
that's equal (or equivalent if `identify_equiv_terms `is set to true) to the 
current one.
   
   Thankfully, the small vector (`vec_to_add`) has a size that is not a 
function of n (it's typically 1 to 3), so that ends-up doing a couple of times 
something linear, so this part should stay linear.



-- 
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: commits-unsubscr...@tvm.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to