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

Fix parsing error caused by dot-separated variable debugNames #1109

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions core/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,15 @@ torch::jit::Module CompileGraph(const torch::jit::Module& mod, CompileSpec cfg)
auto engine = conversion::ConvertBlockToEngine(g->block(), cfg.convert_info, static_params);
AddEngineToGraph(new_mod, new_g, engine, cuda_device);
}
for (auto input : new_g->block()->inputs()) {
LOG_DEBUG("input name:" << input->debugName());
if (input->debugName().find(".") != std::string::npos) {
auto pos = input->debugName().find(".");
auto newName = input->debugName().replace(pos, 1, "_");
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems hacky, @bowang007 thoughts? We might just be doing something wrong upstream causing these issues.

Copy link
Collaborator

Choose a reason for hiding this comment

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

what happens is that when there is any fallback we will copy the Metadata of the inputs of the lowered graph (include debugname()) to the inputs of the new graph through this line As a result, the inputs' names' are same with the Lowered Graph inputs, which has some values as x.1, these names cannot be deserialized by torch.jit.load(). This explains why we are not getting this error when there is no fallback, since all the inputs are substituted by input_0, input_1 when there is no fallback.
Another solution to this error would be simply deleting the mapping here. I did some tests locally which could help resolve this issue. However, not sure if this deletion would induce other issues, will run the test cases to ensure it works.

input->setDebugName(newName);
LOG_DEBUG("changed name:" << input->debugName());
}
}
auto new_method = new_mod._ivalue()->compilation_unit()->create_function(method.name(), new_g);
auto schema = util::GenerateGraphSchema(new_method->name(), new_g);
new_mod.type()->addMethod(new_method);
Expand Down