zhiics commented on a change in pull request #4919: [Relay][Pass] Don't consider constants as free vars in MergeComposite URL: https://github.com/apache/incubator-tvm/pull/4919#discussion_r382711559
########## File path: src/relay/pass/merge_composite.cc ########## @@ -40,37 +40,34 @@ class MergeCompositeWrapper : public ExprMutator { explicit MergeCompositeWrapper(const std::string& pattern_name, const Expr& pattern) : pattern_name_(pattern_name), pattern_(pattern) {} - Expr ExtractPattern(const Var& pattern, const Expr& root, - Map<std::string, Array<Expr>>* var_map) { - if (var_map->find(pattern->name_hint()) == var_map->end()) { + Expr ExtractPattern(const Var& pattern, const Expr& root) { + if (var_map_.find(pattern->name_hint()) == var_map_.end()) { // if we haven't encountered this var yet, make a new free var and associate // it with the value at 'root' auto free_var = VarNode::make(pattern->name_hint(), Type()); - var_map->Set(pattern->name_hint(), Array<Expr>({free_var, root})); + var_map_.Set(pattern->name_hint(), Array<Expr>({free_var, root})); return std::move(free_var); } else { // if we have encountered this var already, return the free var that was created - auto vars = (*var_map)[pattern->name_hint()]; + auto vars = var_map_[pattern->name_hint()]; auto free_var = vars[0]; auto graph_expr = vars[1]; // make sure to first check they both map to the same node in the graph if (graph_expr != root) { return Expr(); } - return (*var_map)[pattern->name_hint()][0]; + return var_map_[pattern->name_hint()][0]; } } - Expr ExtractPattern(const Constant& pattern, const Expr& root, - Map<std::string, Array<Expr>>* var_map) { + Expr ExtractPattern(const Constant& pattern, const Expr& root) { Review comment: I think this one can be safely removed ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services