yelite opened a new pull request, #14310:
URL: https://github.com/apache/tvm/pull/14310
This PR change the interface of the check function in FuseOpsByPattern, in
order to make it possible to broader types of check during fusion. In
particular,
1. The old check function signature is `bool(const Map<DFPattern, Expr>&
match_result, const Expr& matched_expr)`, which isn't very useful because:
- The `Map<DFPattern, Expr> match_result` is hard to consume. To
retrieve the wanted expr from this map, one has to either keep track of the
DFPattern that matches the expr, or to iterate through the map values and
filter by expr type.
- The `matched_expr` provides little help because one cannot traverse to
other expressions from `matched_expr`, without the help from things like
`var2val`.
2. The new signature is `bool(const PatternCheckFunctionInput&)`, A node
`PatternCheckFunctionInput` is created for passing information to the check
function. This prevents old check functions from breaking when new input needs
to be supplied to the check function. Currently `PatternCheckFunctionInput` has
```
/*!
* \brief A map which contains all expressions matched by the sub patterns
in
* FuseOpsPatternNode::annotation_patterns.
*/
Map<String, Expr> annotated_expr;
/*!
* \brief A map mapping variable definitions to a set of uses.
*/
Map<Var, Array<Var>> var_usages;
/*!
* \brief Map from value to its bound variable.
*/
Map<Expr, Var> value_to_bound_var;
```
This PR also improves the check function of cutlass conv2d residual block
pattern, as an example on how the new signature of check function can be useful.
cc @vinx13 @masahi
--
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]