Skip to content

Expose an API to iterate all the registered operators#23207

Closed
houseroad wants to merge 8 commits intogh/houseroad/10/basefrom
gh/houseroad/10/head
Closed

Expose an API to iterate all the registered operators#23207
houseroad wants to merge 8 commits intogh/houseroad/10/basefrom
gh/houseroad/10/head

Conversation

@houseroad
Copy link
Member

@houseroad houseroad commented Jul 23, 2019

Stack from ghstack:

So we can iterate over the operator registry, and check the backward compatiblity.

Differential Revision: 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/)
So we can iterate over the operator registry, and check the backward compatiblity.

Differential Revision: [D16434335](https://our.internmc.facebook.com/intern/diff/D16434335/)
const std::vector<std::shared_ptr<Operator>>& getAllOperators() {
std::lock_guard<std::mutex> guard(lock);
registerPendingOperators();
static std::vector<std::shared_ptr<Operator>> values;
Copy link
Collaborator

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

Copy link
Member Author

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.

Copy link
Collaborator

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/)
registerPendingOperators();
std::vector<std::shared_ptr<Operator>> values;
values.clear();
for (auto it = operators.begin(); it != operators.end(); ++it) {
Copy link
Collaborator

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/)
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in a6fb6e1.

@facebook-github-bot facebook-github-bot deleted the gh/houseroad/10/head branch October 28, 2019 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants