Skip to content

cleanup tmp name generation #25065

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

Closed
wants to merge 2 commits into from
Closed

Conversation

zdevito
Copy link
Contributor

@zdevito zdevito commented Aug 23, 2019

Stack from ghstack:

Using global atomic variables is bad because sending the same AST through
the compiler twice will produce different graphs. This makes it a
member of the translation struct.

Differential Revision: D16975355

Using global atomic variables is bad because sending the same AST through
the compiler twice will produce different graphs. This makes it a
member of the translation struct.
@pytorchbot pytorchbot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Aug 23, 2019
@zdevito zdevito requested a review from eellison August 23, 2019 00:08
Copy link
Contributor

@eellison eellison left a comment

Choose a reason for hiding this comment

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

looks good

@@ -522,6 +522,10 @@ struct to_ir {
// `next` that points to the most immediate enclosing scope's value.
std::shared_ptr<Environment> environment_stack;
std::vector<DefContext> def_stack_;
size_t temp_name_count_ = 0;
std::string createTempName(const std::string& prefix) {
return prefix + std::to_string(temp_name_count_);
Copy link
Contributor

Choose a reason for hiding this comment

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

i think you dropped a ++

static std::atomic<size_t> tmp_count{0};
const auto tmp_name =
std::string("___list_acc") + std::to_string(tmp_count++);
const auto tmp_name = createTempName("___list_acc");
Copy link
Contributor

Choose a reason for hiding this comment

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

unrelated to your diff but it's better practice to prefix the names with $ so that there is no possibility of user collision

cleanup tmp name generation

Using global atomic variables is bad because sending the same AST through
the compiler twice will produce different graphs. This makes it a
member of the translation struct.

gh-metadata: pytorch pytorch 25065 gh/zdevito/93/head
@zou3519 zou3519 deleted the gh/zdevito/93/head branch August 23, 2019 05:49
@facebook-github-bot
Copy link
Contributor

@zdevito merged this pull request in 5254b12.

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