-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Add logging to torchvision ops #4799
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
Conversation
💊 CI failures summary and remediationsAs of commit 693ea25 (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
Great, need to fix lint :-) |
Ok, I'll have to fight with torchscript then :-) |
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, thanks!
We could consider adding also on LastLevelMaxPool, LastLevelP6P7, ExtraFPNBlock but it's also OK without it. Can be merged once a scriptable operator for the logging is added as discussed offline.
May I ask, why are we logging functions? I see such addition in many PRs by Francisco. (If the reason is confidential to FB, please ignore) Edit |
Hi @oke-aditya This function provides similar functionality as We log which methods are called for debugging purposes and it's used only in FB infra. By no means this collects any data from our open-source users, and is pretty-much a no-op for external users. This PR in PyTorch introduced this logging functionality, and has more information on the lower-levels of it pytorch/pytorch#20745 |
torchvision/utils.py
Outdated
|
||
def _log_api_usage_once(obj: object) -> None: | ||
torch._C._log_api_usage_once(f"{obj.__module__}.{obj.__class__.__name__}") | ||
@torch.jit.ignore |
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.
Maybe @torch.jit.unused
and using
if not torch.jit.is_scripting():
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.
Yeah, I'm changing it now to use torch.jit.is_scripting() or torch.jit.is_tracing()
Thank you for the information :) My additional doubt was if this would cause additional overhead. But benchmarks indicate it does not affect (as per the PR you linked). |
Maybe we should make this crystal clear in the docstring of |
Hey @fmassa! You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py |
Summary: * Add logging to torchvision ops * Hack to make torchscript work * Bugfix * Bugfix * Lint * mypy... let's silence it * Fighting with mymy * One more try Reviewed By: datumbox Differential Revision: D32064710 fbshipit-source-id: a8f46074acba8fcc4cd06efc155f670faa737bba
* Add logging to torchvision ops * Hack to make torchscript work * Bugfix * Bugfix * Lint * mypy... let's silence it * Fighting with mymy * One more try
This PR adds logging to the public ops in torchvision.
I haven't tried making it useinspect
to automatically find the name of the function as there is no chance this is supported in torchscript.This function isn't supported in torchscript anyway, so let's make it a no-op in torchscript for now.
A quick benchmark shows ~900ns of overhead, which should be fine