Skip to content

Add api usage log to transforms #5007

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

Merged
merged 12 commits into from
Dec 21, 2021
Merged

Add api usage log to transforms #5007

merged 12 commits into from
Dec 21, 2021

Conversation

kazhang
Copy link
Contributor

@kazhang kazhang commented Nov 29, 2021

cc @vfdev-5 @datumbox

@facebook-github-bot
Copy link

facebook-github-bot commented Nov 29, 2021

💊 CI failures summary and remediations

As of commit 5d46f89 (more details on the Dr. CI page):


  • 1/1 failures introduced in this PR

1 failure not recognized by patterns:

Job Step Action
CircleCI cmake_linux_gpu Build torchvision C++ distribution and test 🔁 rerun

1 job timed out:

  • cmake_linux_gpu

This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@kazhang kazhang requested review from datumbox and fmassa November 29, 2021 23:29
@kazhang
Copy link
Contributor Author

kazhang commented Nov 30, 2021

Currently we can't log Compose because it breaks this test
test/test_transforms_tensor.py - test_composee.g., which asserts Compose is not scriptable, however, the torchscript type check error suppresses the origin runtime error.

IMO we could skip Compose because the wrapped transforms will be logged anyway. If we do want to log it, we could split _log_api_usage_once into _log_api_usage_once(api: str) and _log_instantiation_usage_once(obj: object) to make torchscript happy. Or we can delete this test, Compose is not scriptable anyway.

@kazhang kazhang marked this pull request as ready for review November 30, 2021 07:09
@datumbox
Copy link
Contributor

@kazhang @fmassa The policy on whether the call should be added on a constructor VS functional part changes from area to area. On the operators, I believe Francisco opted for adding the call only once, carefully adding it mainly on functional and secondary on constructors (only for those Ops with no functional component). On the other hand Kai proposes to add it to all constructor and functions but excludes those that are too simple (like ToTensor). I think that this change of policy on different parts of the code can be confusing. Shall we align it everywhere? Personally I would favour a simple approach were we add the calls in every constructor and method call we want to log without any exceptions. Thoughts?

@kazhang
Copy link
Contributor Author

kazhang commented Nov 30, 2021

Personally I would favour a simple approach were we add the calls in every constructor and method call we want to log without any exceptions. Thoughts?

Agree with this simple approach, log API is only called once and pretty lightweight. We could further dedup in the downstream if needed.
@fmassa WDYT?

Copy link
Contributor

@datumbox datumbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kazhang, overall looks good. Just one comment, let me know what you think.

Copy link
Contributor

@datumbox datumbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @kazhang

@datumbox datumbox merged commit 55f7faf into pytorch:main Dec 21, 2021
@github-actions
Copy link

Hey @datumbox!

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

@kazhang kazhang deleted the log-transforms-usage branch December 21, 2021 17:27
facebook-github-bot pushed a commit that referenced this pull request Dec 21, 2021
Summary:
* add api usage log to functional transforms

* add log to transforms

* fix for scriptablity

* skip Compose for scriptability

* follow the new policy

* torchscriptbility

* adopt new API

* make Compose scriptable

* move from __call__ to __init__

Reviewed By: prabhat00155

Differential Revision: D33253462

fbshipit-source-id: c9e27e573869c84f2c0df295ec9f5542a327126f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API usage logging within TorchVision Add _log_api_usage_once() calls on remaining endpoints
4 participants