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


##########
src/tir/transforms/common_subexpr_elim_tools.cc:
##########
@@ -762,21 +807,40 @@ std::vector<std::pair<PrimExpr, size_t>> 
SyntacticToSemanticComputations(
          return a_stream.str().compare(b_stream.str()) < 0;
        });
 
-  // For each element in the hashtable
-  for (auto elem : sorted_map_items) {
-    // We try to see if a semantically equivalent term is already in the 
resulting vector
-    auto it_found = std::find_if(result.begin(), result.end(),
-                                 [elem](std::pair<PrimExpr, size_t> 
already_seen) {
-                                   return EquivalentTerms(already_seen.first, 
elem.first);
-                                 });
-    // And if so, we increase (by `elem.second`) its count
-    if (it_found != result.end()) {
-      it_found->second += elem.second;
+  for (const auto& elem : sorted_items_of_table) {
+    PrimExpr norm_elem = NormalizeTerm(elem.first, identify_equiv_terms);
+    // If the normalized term is not already a key in the normalized table
+    auto it_found = norm_table.find(norm_elem);

Review Comment:
   I think you're right, good catch!
   Now that we have brought the `identify_equiv_terms` information to the 
function `SyntacticToSemanticComputations` we should be able to do this 
syntactic->semantic transformation even faster when 
`identify_equiv_terms==false`, as we know that each element will stay the same 
(i.e. no elements will be merged, and there will be the same number of elements 
in the output vector than there was in the input hashtable).
   
   I'll do that this evening.



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