masahi commented on code in PR #14417:
URL: https://github.com/apache/tvm/pull/14417#discussion_r1152471948
##########
src/relax/ir/dataflow_matcher.cc:
##########
@@ -541,15 +541,21 @@ struct RNode {
* \brief This method try to match a real node and a pattern node along with
its neighbors.
*/
static bool try_match(PNode* p, RNode* r, DFPatternMatcher* m,
- const std::map<const VarNode*, std::set<const
VarNode*>>& def2use,
+ const std::map<const VarNode*, std::vector<const
VarNode*>>& def2use,
const std::map<const VarNode*, std::vector<const
VarNode*>>& use2def) {
- if (nullptr != p->matched && p->matched == r->ptr) return true; // matched
before.
+ if (p->matched != nullptr && p->matched == r->ptr) return true; // matched
before.
if (!m->Match(GetRef<DFPattern>(p->ptr), GetRef<Var>(r->ptr))) return false;
std::stack<std::pair<PNode*, RNode*>> undo_stack{};
const auto commit = [&undo_stack](PNode* p, RNode* r) {
// match with each other.
+ // TODO(ganler, masahi): Why commit on the same p-r pair happens more than
once?
Review Comment:
ok :) I'll share my thought in the meantime.
Looking at an example in
https://github.com/apache/tvm/blob/unity/tests/python/relax/test_dataflow_pattern.py#L540-L545,
I cannot imagine how one would use `start_hint` in practice. Here, you wrote
the input mod by hand, so you know `dfb.bindings[0].var` is associated to the
"left" branch of the CBRx2. But in general, we don't have such information,
especially in e2e scenarios for real world models.
Even if there was a good use case for it, I claim that it doesn't justify
making API and the implementation more complicated (two additional params +
`try_match` loop on parants). If one has such advanced knowledge of model
structure and variables, they may as well have a different way to match &
extract such subgraph.
--
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]