-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Relay][Pass] SimplifyCastLike/Cast and ConcretizeFullLikeRewrite rewrites for SimplifyExpr #7827
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM
/*! | ||
* \brief SimplifyCast matches the pattern of cast data to the same dtype. | ||
*/ | ||
class SimplifyCast : public DFPatternRewrite { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like these two patterns be merged to one?
pattern_ = IsOp("cast_like")({data_pat_, like_pat_}) || IsOp("cast")({data_pat_});
And both patterns can use like_ty = pre->checked_type().as<TensorTypeNode>();
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as @comaniac , otherwise LGTM
src/relay/backend/build_module.cc
Outdated
@@ -300,6 +300,7 @@ class RelayBuildModule : public runtime::ModuleNode { | |||
} | |||
}); | |||
pass_seqs.push_back(transform::EliminateCommonSubexpr(fskip)); | |||
pass_seqs.push_back(transform::InferType()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this? InferType is already in the requirement of SimplifyExpr. Other existing patterns also refer to checked_type_ so it should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emmm... I dont know why Ci fails, just try it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the CI it does look like the type is missing. Since InferType is executed before and after SimplifyExpr, one possibility is your data
is already mutated by previous patterns in this pass and that callback didn't manually specify the type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…rites for SimplifyExpr (apache#7827)
…rites for SimplifyExpr (apache#7827)
…rites for SimplifyExpr (apache#7827)
…rites for SimplifyExpr (apache#7827)
ConcretizeFullLikeRewrite
:full_like
->full
when known shapeSimplifyCastLike/Cast
:cast(data, dtype)
orcast_like(data, dtype_like)
->data
, when the input and output have the same dtype@yzhliu @comaniac @altanh