Better error message for tensor with grad as constant in tracing#18298
Better error message for tensor with grad as constant in tracing#18298eellison wants to merge 2 commits into
Conversation
| // Didn't find it. Bake in a constant | ||
| if (ten.requires_grad()) { | ||
| std::ostringstream oss; | ||
| oss << "Cannot insert a Tensor that requires grad as a constant:\n"; |
There was a problem hiding this comment.
We should probably have a reference to a specific location in the code, as well as possible remediations (trace the module, pass the parameter in explicitly).
There was a problem hiding this comment.
Do we have access to where in the code we're at?
| std::ostringstream oss; | ||
| oss << "Cannot insert a Tensor that requires grad as a constant. " | ||
| << "Consider making it a parameter or input, or detaching the gradient\n"; | ||
| throw std::runtime_error(oss.str()); |
There was a problem hiding this comment.
I had to remove the print to tensor because printing calls .contiguous which re-enters the tracer, causing a stack trace failure. That should be fixed but should be in a follow up PR
facebook-github-bot
left a comment
There was a problem hiding this comment.
@eellison has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
There was a problem hiding this comment.
@eellison has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
This broke trunk, unlanding. |
Summary: Trying to reland pytorch#18298 Pull Request resolved: pytorch#18535 Differential Revision: D14652391 Pulled By: eellison fbshipit-source-id: 699e30045dd5f14f0a2b98378272045a292e1e2a
…orch#18298) Summary: Fix for pytorch#17583 There's an unrelated issue right now causing a segfault when printing tensor so that might have to fixed first for this to land Pull Request resolved: pytorch#18298 Differential Revision: D14584266 Pulled By: eellison fbshipit-source-id: 4e7850dadc78ef1e98ad40b9d8adc0fef42acf48
Summary: Trying to reland pytorch#18298 Pull Request resolved: pytorch#18535 Differential Revision: D14652391 Pulled By: eellison fbshipit-source-id: 699e30045dd5f14f0a2b98378272045a292e1e2a
Fix for #17583
There's an unrelated issue right now causing a segfault when printing tensor so that might have to fixed first for this to land