FranckQC commented on code in PR #11574:
URL: https://github.com/apache/tvm/pull/11574#discussion_r890353098
##########
src/tir/transforms/common_subexpr_elim.cc:
##########
@@ -120,6 +120,39 @@ bool
CommonSubexpressionEliminator::CanContainEligibleComputations(const PrimExp
return true;
}
+/*!
+ * \brief Implements an order on pairs (expression,frequency). First attempts
to compare them
+ using the size of the expression. If the is the same, decides
something else still
+ deterministic.
+ * \param a The first pair
+ * \param b The second pair
+ * \return A boolean telling if the first pair `a` comes before the second
pair `b`
+ * \note We need this order to be deterministic in order to have a fully
deterministic pass,
+ * as we will deal with elements that are coming from a hashtable, but
the order in which
+ * they appeared in the hashtable was based on some runtime addresses,
so it can potentially
+ * change with every execution.
+ */
+bool
CommonSubexpressionEliminator::OrderOnExprAndFrequency(std::pair<PrimExpr,
size_t> a,
+
std::pair<PrimExpr, size_t> b) {
+ size_t a_size = CalculateExprComplexity(a.first);
+ size_t b_size = CalculateExprComplexity(b.first);
+
+ // Criteria 1 - Size of the expression comes first
+ // `a` comes before `b` if the size of `a` is bigger
+ if (a_size > b_size) return true;
+ // `a` does NOT come before `b` if the size of `b` is bigger
+ else if (b_size > a_size)
+ return false;
Review Comment:
Sure, will do. Thank you!
--
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]