Skip to content
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

Don't hash the pointer to the real function when generating the offline cache key #6929

Closed
lin-hitonami opened this issue Dec 20, 2022 · 3 comments

Comments

@lin-hitonami
Copy link
Contributor

Describe the bug
When we get the offline cache key, we use the value of Function * as the key of the real function. However, this changes when we reset Taichi. We should use the hash key of the IR of the real function instead.

@taichi-gardener taichi-gardener moved this to Untriaged in Taichi Lang Dec 20, 2022
@lin-hitonami lin-hitonami changed the title Don't use the pointer to the real function when generating the offline cache key Don't hash the pointer to the real function when generating the offline cache key Dec 20, 2022
@PGZXB
Copy link
Contributor

PGZXB commented Dec 20, 2022

FYI, @lin-hitonami

void emit(Function *func) {
TI_ASSERT(func);
auto iter = real_funcs_.find(func);
if (iter != real_funcs_.end()) {
emit(iter->second);
} else {
auto [iter, ok] = real_funcs_.insert({func, real_funcs_.size()});
TI_ASSERT(ok);
emit(iter->second);
}
}

// Serialize dependent real-functions
emit(real_funcs_.size());
for (auto &[func, id] : real_funcs_) {
if (auto &ast_str = func->try_get_ast_serialization_data();
ast_str.has_value()) {
emit_bytes(ast_str->c_str(), ast_str->size());
}
}

@PGZXB
Copy link
Contributor

PGZXB commented Dec 20, 2022

However, the algorithm that generates the AST key for the real function is indeed wrong. See #6877. I will redesign it.

@lin-hitonami
Copy link
Contributor Author

Okay, I missed that part.

Repository owner moved this from Untriaged to Done in Taichi Lang Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants