Skip to content

Commit

Permalink
[easy] Fix .sizes() call in saved_variable.cpp for nested tensor (pyt…
Browse files Browse the repository at this point in the history
…orch#83356)

Small fix so that TestMultipleDispatch in the above PR will throw the correct error when using an inplace operation on a saved nested input

Pull Request resolved: pytorch#83356
Approved by: https://github.com/albanD
  • Loading branch information
mikaylagawarecki authored and pytorchmergebot committed Aug 16, 2022
1 parent 7e7afca commit 92a0058
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion torch/csrc/autograd/saved_variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ Variable SavedVariable::unpack(std::shared_ptr<Node> saved_for) const {
message
<< "one of the variables needed for gradient computation has been "
"modified by an inplace operation: ["
<< data_.toString() << " " << data_.sizes() << "]";
<< data_.toString() << " ";
if (data_.is_nested()) {
message << data_._nested_tensor_size() << "]";
} else {
message << data_.sizes() << "]";
}
if (grad_fn) {
message << ", which is output " << output_nr_ << " of "
<< grad_fn->name() << ",";
Expand Down

0 comments on commit 92a0058

Please sign in to comment.