masahi commented on code in PR #16128:
URL: https://github.com/apache/tvm/pull/16128#discussion_r1396250704
##########
python/tvm/relax/transform/transform.py:
##########
@@ -647,19 +647,21 @@ class FusionPattern(Object):
pattern: DFPattern
annotation_patterns: Mapping[str, DFPattern]
check: Callable[[PatternCheckContext], bool]
+ attrs_getter: Callable[[PatternCheckContext], Dict[str, str]]
def __init__(
self,
name: str,
pattern: DFPattern,
annotation_patterns: Optional[Mapping[str, DFPattern]] = None,
check: Optional[Callable[[Mapping[str, Expr]], bool]] = None,
+ attrs_getter: Optional[Callable[[Mapping[str, Expr]], Dict[str, str]]]
= None,
Review Comment:
Please use the same type annotation.
##########
include/tvm/relax/transform.h:
##########
@@ -322,11 +322,20 @@ class FusionPatternNode : public Object {
*/
Optional<PackedFunc> check;
+ /*!
+ * \brief The function to get attributes for fused function
+ *
+ * It should have signature
+ * Map<String, String>(const PatternCheckContext& context)
Review Comment:
At first glance I don't understand why it needs to take
`PatternCheckContext` as argument.
##########
src/relax/transform/fuse_ops.cc:
##########
@@ -1102,6 +1106,13 @@ class PatternBasedPartitioner : ExprVisitor {
auto parent_group = GetGroupForBoundVar(binding->var);
ICHECK(parent_group);
parent_group->attrs.Set(attr::kComposite, pat_name_);
+ if (attrs_getter_ != nullptr) {
+ const auto& custom_attrs =
+ attrs_getter_(CreatePatternCheckContext(call,
matches_opt.value()));
Review Comment:
A dup call to `CreatePatternCheckContext`
https://github.com/apache/tvm/blob/c3f6c07021d0b857d4340e7699f14dceba17b228/src/relax/transform/fuse_ops.cc#L1077
--
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]