d-smirnov commented on a change in pull request #6655:
URL: https://github.com/apache/incubator-tvm/pull/6655#discussion_r528967519
##########
File path: src/relay/transforms/annotate_target.cc
##########
@@ -61,20 +67,27 @@ class AnnotateTargetRewriter : public ExprRewriter {
std::pair<std::string, Array<Expr>> AnnotateArgs(const Array<Expr>& args,
const std::string& target =
"") {
std::string ref_target = "";
+ Array<Expr> compiler_begins;
Array<Expr> compiler_ends;
for (auto arg : args) {
- std::string arg_target = "default";
+ std::string arg_target = default_target;
const CallNode* call = arg.as<CallNode>();
if (call && call->op == CompilerBeginOp()) {
// Argument is already compiler begin node meaning that this is not
the first time
// running this pass, so we simply remove it and will add a new one
later.
ICHECK_EQ(call->args.size(), 1U);
+ // Do not alter existing annotation if not default
+ if (default_target != call->attrs.as<CompilerAttrs>()->compiler) {
+ compiler_begins.push_back(arg);
+ } else {
+ // Remove default
+ compiler_ends.push_back(call->args[0]);
+ }
Review comment:
Current contract for AnnotateTarget assumes that for non-call op to be
promoted under the target of its arguments it should have all the arguments
annotated with the same target. If I am not mistaken, the targets can be added
at the run-time, and theoretically the situation is possible when after several
subsequent invocations of AnnotateTarget a non-call operation will be annotated
as default and will not be promoted even when all its arguments have same
target. To prevent this the default annotations always removed while specific
targets are preserved. However I am agree that the explanation is a bit
far-fetched.
As for the second part of your comment, do I understand correctly that the
idea is not to alter the AnnotateTarget and instead do the removal of
annotations from non-call ops in a subsequent separate pass? I am not sure I
quite understand the definition of "simple" and the concept of
PruneSimpleRegions as a whole. Could you elaborate this point a bit more,
please?
----------------------------------------------------------------
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:
[email protected]