Lunderberg commented on code in PR #15694: URL: https://github.com/apache/tvm/pull/15694#discussion_r1321618281
########## src/relax/ir/dataflow_matcher.cc: ########## @@ -443,6 +444,92 @@ bool DFPatternMatcher::VisitDFPattern_(const ShapePatternNode* op, const Expr& e return false; } +Optional<Bool> SameShapeConstraintNode::IsConstraintSatisfied( Review Comment: In the current API, the return `Optional<Bool>` can only contain true/false/nullopt. The potential use case for having a full predicate expression be returned would be to allow constraints to interact with each other. Currently, the API uses the three possible values of `Optional<Bool>` to decide whether to backtrack due to a failed condition (`Bool(false)`), mark a condition as satisfied (`Bool(true)`), or to mark a condition as uncheckable (`NullOpt`). If we instead returned a `std::tuple<PrimExpr, bool>`, where the `PrimExpr` gives a necessary condition for the constraint to be satisfied, and the boolean indicates whether the condition is also sufficient for the constraint to be satisfied. That would allow constraints to respond that the constraint is satisfied, so long as the returned expression evaluates to true. The pattern matcher could then take the AND of all the necessary conditions, checking if the entire expression can be validated. For example, suppose we have tensors `A: R.Tensor(shape=[16, 16])` and `B: R.Tensor(shape=[16, n])`. The current pattern matcher is conservative, and cannot verify that `SameShapeConstraint([pat_A, pat_B])` should match, because it cannot prove that `n==16`. Returning a `PrimExpr` would allow the calling scope to determine whether this should impose additional constraints by binding the value of `n`, or to treat it as a mismatch. -- 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]
