-
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
[Unity] Add instruments to relay translator #15601
[Unity] Add instruments to relay translator #15601
Conversation
Sometimes its useful to instrument relay passes that are run during relay to relax translation, and this patch adds a new argument to relay translator to accept an instruments list argument that gets passed onto the PassContext used while running relay prefix passes
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.
Generated by tvm-bot |
@tvm-bot rerun |
Failed to re-run CI in https://github.com/apache/tvm/actions/runs/5934313794
with response
|
@tvm-bot rerun |
Failed to re-run CI in https://github.com/apache/tvm/actions/runs/5934428367
with response
|
@tvm-bot rerun |
Failed to re-run CI in https://github.com/apache/tvm/actions/runs/5935375081
with response
|
21af3e2
to
685cc76
Compare
@@ -255,6 +261,7 @@ def visit_func(node): | |||
opt_level=opt_level, | |||
config=pass_config, | |||
disabled_pass=disabled_pass, | |||
instruments=instruments, |
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.
I like it, though I'm wondering if we should have it forward the instrumentation of the existing PassContext
, rather than explicitly accept it as an argument. That way, debug instrumentation set by a much higher scope would also be preserved, without requiring an update to the immediately-calling scope.
instruments = tvm.transform.PassCurrent().instruments
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.
Thanks for your review @Lunderberg.
I actually did it that way initially, but since the other arguments to PassContext
such as opt_level
and pass_config
were taken as arguments to the relay translator, I modified it take instruments as an argument as well.
I can change it back to be forwarded from current PassContext as you've suggested, either way is fine with me, but in that case, should we also remove opt_level
and pass_config
from being arguments and forward them from current context as well? Since that would be a breaking change, I'm a bit hesitant to do that.
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.
Hmm, good point. Since the other arguments are currently specified explicitly, probably better to keep it that way for consistency.
In the long-term, I think that entering a PassContext should probably distinguish between options that override the previous (opt_level
), options that append to the previous (instruments
, disabled_passes
).
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.
Approved after discussion. Long-term, the PassContext
constructed here should probably take all options other than pass_config
from the current pass context.
Sure, I agree that in the long term, it might be better to pick it up from PassContext. Perhaps to avoid a breaking change initially, we can keep the arguments and prioritize them when provided, but when they're not provided, they can be picked up from the current PassContext. |
Sometimes it is useful to instrument relay passes that are run during relay to relax translation, and this patch adds a new argument to relay translator to accept instruments list.
The instruments can be passed on as