-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Fix segmentation fault in grad_fn #9292
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
Conversation
|
Should grad_fn be callable at all? |
|
@zou3519 |
This reverts commit 5ddc3cb. Reverting because this is redundant
apaszke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats still an incomplete fix because it might be called with a wrong number. It would be better to use the information we stash in the forward pass to validate the inputs.
|
@apaszke Is my fix correct - because there are some failing tests which I don't know how to debug? |
|
@pytorchbot retest this please |
|
error looks legit |
|
@vishwakftw can you try to see what Function fails the assertion? It might be the case that there's a bug elsewhere |
|
|
||
| virtual variable_list apply(const variable_list& inputs) override; | ||
|
|
||
| virtual variable_list operator()(const variable_list& inputs) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
apaszke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I didn't notice you added the check at every single function call! Maybe just put it in THPCppFunction_call so that it only applies to Python functions that cause the segfault. The rest of the system should be correct "by design"
|
|
||
| variable_list operator()(const variable_list& inputs) { | ||
| return apply(inputs); | ||
| } |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
Adding it to |
|
Same test error as earlier. @apaszke |
| int num_inputs = PyTuple_GET_SIZE(args); | ||
| int num_inputs_required = ((THPCppFunction*)self)->cdata->num_inputs(); | ||
| std::string self_name = ((THPCppFunction*)self)->cdata->name(); | ||
| if ((self_name.find("Error") == std::string::npos) && (num_inputs != num_inputs_required)) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
…to reflect this change
| DelayedError(std::string msg, int num_inputs) | ||
| : msg(std::move(msg)) { | ||
| for (int i = 0; i < num_inputs; i++) | ||
| input_metadata_.emplace_back(); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
|
||
| std::string msg; | ||
|
|
||
| uint32_t input_nr; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apaszke has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: Fixes #8774 . Reviewed By: soumith Differential Revision: D8836478 Pulled By: apaszke fbshipit-source-id: f113bf47fe493be9f095a5a5490caf08dbb44e38
|
I know that this has been merged... But can we have a test for this? |
|
How do I do it? Should I send in a PR? |
|
That would be great! I can open an issue to track this if you are busy. |
|
I think I should be able to do it; doesn't seem like a lot of effort. :) |
|
PR in at #9457 |
* upstream/master: (24 commits) Implement tensor weak references (pytorch#9363) Nuke TestCollectEnv (pytorch#9459) Add test case for segmentation fault fix in grad_fn (pytorch#9457) Add peephole optimization for type_as operators. (pytorch#9316) Fix out-of-range error for test_neg (pytorch#9431) add depthwise conv support for mkldnn (pytorch#8782) Refactor `_log_sum_exp` (pytorch#9173) Add ModuleDict and ParameterDict containers (pytorch#8463) Introduce SupervisedPtr, delete THAllocator and THCDeviceAllocator (pytorch#9358) Introducing IsInf (pytorch#9169) add device to CUDAEvent (pytorch#9415) Make localScalar error message more intuitive (pytorch#9443) Only accept continguous tensors in TopK for cuda (pytorch#9441) Add support for .norm() pytorch onnx export and ReduceL1/ReduceL2 caffe2 operators (pytorch#9299) Only view() rhs of index_put if we need to (pytorch#9424) Add BatchBucketizeOp in caffe2 (pytorch#9385) Implementation of Wngrad optimizer caffe2 python wrapper and unit test on least square regression (pytorch#9001) Implementation and operator test for Wngrad optimizer (pytorch#8999) Fix segmentation fault in grad_fn (pytorch#9292) update docs (pytorch#9423) ...
Summary: Fixes pytorch#8774 . Reviewed By: soumith Differential Revision: D8836478 Pulled By: apaszke fbshipit-source-id: f113bf47fe493be9f095a5a5490caf08dbb44e38
Summary: Fixes pytorch#8774 . Reviewed By: soumith Differential Revision: D8836478 Pulled By: apaszke fbshipit-source-id: f113bf47fe493be9f095a5a5490caf08dbb44e38
Fixes #8774 .
cc: @soumith @ssnl