-
Notifications
You must be signed in to change notification settings - Fork 22.2k
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
Expose an API to iterate all the registered operators #23207
Conversation
So we can iterate over the operator registry, and check the backward compatiblity. Differential Revision: [D16434335](https://our.internmc.facebook.com/intern/diff/D16434335/)
So we can iterate over the operator registry, and check the backward compatiblity. Differential Revision: [D16434335](https://our.internmc.facebook.com/intern/diff/D16434335/)
So we can iterate over the operator registry, and check the backward compatiblity. Differential Revision: [D16434335](https://our.internmc.facebook.com/intern/diff/D16434335/)
So we can iterate over the operator registry, and check the backward compatiblity. Differential Revision: [D16434335](https://our.internmc.facebook.com/intern/diff/D16434335/)
torch/csrc/jit/operator.cpp
Outdated
const std::vector<std::shared_ptr<Operator>>& getAllOperators() { | ||
std::lock_guard<std::mutex> guard(lock); | ||
registerPendingOperators(); | ||
static std::vector<std::shared_ptr<Operator>> values; |
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.
returning pointer to a static is not a good idea (as it can theoretically race. Since perf doesn't matter - just allocate new vector eac time
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.
interesting... I thought with lock_guard, race should be gone.
Anyway, changed to allocating a new vector.
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.
you return the pointer to values
, someone can read it when guard
is no longer held (but instead if taken by another thread that repopulates values
from scratch)
So we can iterate over the operator registry, and check the backward compatiblity. Differential Revision: [D16434335](https://our.internmc.facebook.com/intern/diff/D16434335/)
torch/csrc/jit/operator.cpp
Outdated
registerPendingOperators(); | ||
std::vector<std::shared_ptr<Operator>> values; | ||
values.clear(); | ||
for (auto it = operators.begin(); it != operators.end(); ++it) { |
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.
make clang-tidy happy please
So we can iterate over the operator registry, and check the backward compatiblity. Differential Revision: [D16434335](https://our.internmc.facebook.com/intern/diff/D16434335/)
So we can iterate over the operator registry, and check the backward compatiblity. Differential Revision: [D16434335](https://our.internmc.facebook.com/intern/diff/D16434335/)
So we can iterate over the operator registry, and check the backward compatiblity. Differential Revision: [D16434335](https://our.internmc.facebook.com/intern/diff/D16434335/)
This pull request has been merged in a6fb6e1. |
Stack from ghstack:
So we can iterate over the operator registry, and check the backward compatiblity.
Differential Revision: D16434335