-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[PyTorch] Update Synchronized<T>::withLock() to return the type/value from the aceepted callable #74060
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
… from the aceepted callable Currently, `void c10::Synchronized<T>::withLock(CB)` accepts a callback but returns `void`. For a callback (CB) returning a value, `withLock()` can not be used to retrieve the returned value. This change makes it possible for the caller to retrieve that value. The only gotcha is that if the value has only move semantics (such as `std::unique_ptr<T>`, then this won't work as currently written). To be able to do that, one needs to use `std::enable_if<T>` to enable a separate overload that works only for moveable types (detectable using `std::is_move_constructible<T>`). Differential Revision: [D34645509](https://our.internmc.facebook.com/intern/diff/D34645509/) [ghstack-poisoned]
CI Flow Status⚛️ CI FlowRuleset - Version:
|
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 2529fa2 (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. |
… type/value from the aceepted callable" Currently, `void c10::Synchronized<T>::withLock(CB)` accepts a callback but returns `void`. For a callback (CB) returning a value, `withLock()` can not be used to retrieve the returned value. This change makes it possible for the caller to retrieve that value. The only gotcha is that if the value has only move semantics (such as `std::unique_ptr<T>`, then this won't work as currently written). To be able to do that, one needs to use `std::enable_if<T>` to enable a separate overload that works only for moveable types (detectable using `std::is_move_constructible<T>`). Differential Revision: [D34645509](https://our.internmc.facebook.com/intern/diff/D34645509/) [ghstack-poisoned]
… from the aceepted callable (#74060) Summary: Pull Request resolved: #74060 Currently, `void c10::Synchronized<T>::withLock(CB)` accepts a callback but returns `void`. For a callback (CB) returning a value, `withLock()` can not be used to retrieve the returned value. This change makes it possible for the caller to retrieve that value. The only gotcha is that if the value has only move semantics (such as `std::unique_ptr<T>`, then this won't work as currently written). To be able to do that, one needs to use `std::enable_if<T>` to enable a separate overload that works only for moveable types (detectable using `std::is_move_constructible<T>`). ghstack-source-id: 150555297 Test Plan: Built model tracer using the command: ``` buck build -c pt.disable_per_op_profiling=0 -c pt.enable_record_kernel_dtype=1 --show-output xplat/caffe2/fb/model_tracer:model_tracer ``` Reviewed By: JacobSzwejbka Differential Revision: D34645509 fbshipit-source-id: 9a4bd5d1d78a5026826c7ed9ee04ea743cafcc10
|
This pull request has been reverted by a554fc6. To re-land this change, please open another pull request, assignthe same reviewers, fix the CI failures that caused the revert and make sure that the failing CI runs on the PR by applying the proper ciflow label (e.g., ciflow/trunk). |
|
This pull request has been reverted by a554fc6. To re-land this change, please open another pull request, assignthe same reviewers, fix the CI failures that caused the revert and make sure that the failing CI runs on the PR by applying the proper ciflow label (e.g., ciflow/trunk). |
Stack from ghstack (oldest at bottom):
Currently,
void c10::Synchronized<T>::withLock(CB)accepts a callback but returnsvoid. For a callback (CB) returning a value,withLock()can not be used to retrieve the returned value. This change makes it possible for the caller to retrieve that value. The only gotcha is that if the value has only move semantics (such asstd::unique_ptr<T>, then this won't work as currently written). To be able to do that, one needs to usestd::enable_if<T>to enable a separate overload that works only for moveable types (detectable usingstd::is_move_constructible<T>).Differential Revision: D34645509